diff --git a/kernel/mars_net.c b/kernel/mars_net.c index 2fb3a741..23c8dfec 100644 --- a/kernel/mars_net.c +++ b/kernel/mars_net.c @@ -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; diff --git a/kernel/mars_server.c b/kernel/mars_server.c index 41ade4a4..69371fd4 100644 --- a/kernel/mars_server.c +++ b/kernel/mars_server.c @@ -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; diff --git a/kernel/mars_server.h b/kernel/mars_server.h index 73750117..5b6b4186 100644 --- a/kernel/mars_server.h +++ b/kernel/mars_server.h @@ -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; };