Skip to content

Commit

Permalink
Possible fix for mem leak (#685)
Browse files Browse the repository at this point in the history
* Possible fix for mem leak

Better fix for mem leak

* apply fmt

Signed-off-by: Roman Khapov <[email protected]>

---------

Signed-off-by: Roman Khapov <[email protected]>
Co-authored-by: Kirill Reshke <[email protected]>
Co-authored-by: Roman Khapov <[email protected]>
  • Loading branch information
3 people authored Sep 17, 2024
1 parent d7a32b7 commit a5256c1
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions sources/frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -1060,19 +1060,23 @@ static od_frontend_status_t od_frontend_deploy_prepared_stmt(
}
}

static inline od_frontend_status_t od_frontend_deploy_prepared_stmt_msg(
od_server_t *server, od_relay_t *relay, char *ctx,
machine_msg_t *msg /* to adcance or to write? */
)
static inline od_frontend_status_t
od_frontend_deploy_prepared_stmt_msg(od_server_t *server, od_relay_t *relay,
char *ctx)
{
char *data = machine_msg_data(msg);
int size = machine_msg_size(msg);
od_frontend_status_t rc;
char *data = machine_msg_data(server->parse_msg);
int size = machine_msg_size(server->parse_msg);

od_hash_t body_hash = od_murmur_hash(data, size);
char opname[OD_HASH_LEN];
od_snprintf(opname, OD_HASH_LEN, "%08x", body_hash);
return od_frontend_deploy_prepared_stmt(server, relay, ctx, data, size,
body_hash, opname, OD_HASH_LEN);
rc = od_frontend_deploy_prepared_stmt(server, relay, ctx, data, size,
body_hash, opname, OD_HASH_LEN);

machine_msg_free(server->parse_msg);
server->parse_msg = NULL;
return rc;
}

static od_frontend_status_t od_frontend_remote_client(od_relay_t *relay,
Expand Down Expand Up @@ -1731,12 +1735,11 @@ static od_frontend_status_t od_frontend_remote(od_client_t *client)

/* fill internals structs in */
if (od_frontend_deploy_prepared_stmt_msg(
server, &server->relay, "sync-point-deploy",
server->parse_msg) != OD_OK) {
server, &server->relay,
"sync-point-deploy") != OD_OK) {
status = OD_ESERVER_WRITE;
break;
}
server->parse_msg = NULL;

machine_msg_t *msg;
msg = kiwi_fe_write_sync(NULL);
Expand Down

0 comments on commit a5256c1

Please sign in to comment.