cb_args should be allocated

when we fork a thread to handle the callback, the arguments we got from
parsing the callback operations in the callback thread are on the stack.
we need to allocate memory for same-size data structure and copy them,
not just copy the pointer.
This commit is contained in:
U-fast\aglo 2010-10-12 11:20:26 -04:00 committed by unknown
parent ca596054f3
commit cf75520410

View file

@ -183,6 +183,7 @@ static unsigned int WINAPI _handle_cb_recall(void *args)
dprintf(1, "_handle_cb_recall: sending nfs41_delegreturn\n"); dprintf(1, "_handle_cb_recall: sending nfs41_delegreturn\n");
nfs41_delegreturn(cb_args->rpc_clnt->client->session, &path_fh, nfs41_delegreturn(cb_args->rpc_clnt->client->session, &path_fh,
&cb_args->args->stateid); &cb_args->args->stateid);
free(cb_args->args);
free(cb_args); free(cb_args);
dprintf(1, "_handle_cb_recall: end\n"); dprintf(1, "_handle_cb_recall: end\n");
return 1; return 1;
@ -203,7 +204,13 @@ static enum_t handle_cb_recall(
goto out; goto out;
} }
cb_args->rpc_clnt = rpc_clnt; cb_args->rpc_clnt = rpc_clnt;
cb_args->args = args; cb_args->args = calloc(1, sizeof(struct cb_recall_args));
if (cb_args->args == NULL) {
free(cb_args);
res->status = NFS4ERR_RESOURCE;
goto out;
}
memcpy(cb_args->args, args, sizeof(struct cb_recall_args));
_beginthreadex(NULL, 0, _handle_cb_recall, cb_args, 0, NULL); _beginthreadex(NULL, 0, _handle_cb_recall, cb_args, 0, NULL);
out: out:
return res->status; return res->status;