mirror of https://github.com/schoebel/mars
server: fix memory leak on writes
This was unnoticed for a long time because it simply did not occur in ordinary MARS Light workloads.
This commit is contained in:
parent
ccb5021e0f
commit
c1ee80f9f4
|
@ -1148,7 +1148,7 @@ int mars_recv_mref(struct mars_socket *msock, struct mref_object *mref, struct m
|
|||
|
||||
if (cmd->cmd_code & CMD_FLAG_HAS_DATA) {
|
||||
if (!mref->ref_data)
|
||||
mref->ref_data = brick_zmem_alloc(mref->ref_len);
|
||||
mref->ref_data = brick_block_alloc(0, mref->ref_len);
|
||||
if (!mref->ref_data) {
|
||||
status = -ENOMEM;
|
||||
goto done;
|
||||
|
|
|
@ -124,6 +124,10 @@ int cb_thread(void *data)
|
|||
mars_shutdown_socket(sock);
|
||||
}
|
||||
|
||||
if (mref_a->data) {
|
||||
brick_block_free(mref_a->data, mref_a->len);
|
||||
mref->ref_data = NULL;
|
||||
}
|
||||
if (mref_a->do_put) {
|
||||
GENERIC_INPUT_CALL(brick->inputs[0], mref_put, mref);
|
||||
atomic_dec(&brick->in_flight);
|
||||
|
@ -210,6 +214,8 @@ int server_io(struct server_brick *brick, struct mars_socket *sock, struct mars_
|
|||
}
|
||||
|
||||
mref_a->brick = brick;
|
||||
mref_a->data = mref->ref_data;
|
||||
mref_a->len = mref->ref_len;
|
||||
SETUP_CALLBACK(mref, server_endio, mref_a);
|
||||
|
||||
amount = 0;
|
||||
|
|
|
@ -39,6 +39,8 @@ struct server_mref_aspect {
|
|||
GENERIC_ASPECT(mref);
|
||||
struct server_brick *brick;
|
||||
struct list_head cb_head;
|
||||
void *data;
|
||||
int len;
|
||||
bool do_put;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue