From: Ross Lagerwall Date: Sun, 10 Aug 2014 11:16:47 +0000 (+0100) Subject: libnfs: Don't perform operations on nfsfh after user callback X-Git-Tag: upstream/1.9.6^2~9^2 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=9cac8a63409f8b6160d3ad48a65a6358372c4fdd;p=deb_libnfs.git libnfs: Don't perform operations on nfsfh after user callback Since the user callback may perform operations on the nfsfh (e.g. it might close it), all updates should be done before the user callback is called. Signed-off-by: Ross Lagerwall --- diff --git a/lib/libnfs.c b/lib/libnfs.c index 5692dc3..06697e1 100644 --- a/lib/libnfs.c +++ b/lib/libnfs.c @@ -1807,6 +1807,8 @@ static void nfs_pread_mcb(struct rpc_context *rpc, int status, void *command_dat struct nfs_cb_data *data = mdata->data; struct nfs_context *nfs = data->nfs; READ3res *res; + int cb_err; + void *cb_data; assert(rpc->magic == RPC_CONTEXT_MAGIC); @@ -1905,9 +1907,11 @@ static void nfs_pread_mcb(struct rpc_context *rpc, int status, void *command_dat if (data->max_offset > data->org_offset + data->org_count) { data->max_offset = data->org_offset + data->org_count; } - data->cb(data->max_offset - data->org_offset, nfs, data->buffer + (data->org_offset - data->offset), data->private_data); + cb_err = data->max_offset - data->org_offset; + cb_data = data->buffer + (data->org_offset - data->offset); } else { - data->cb(res->READ3res_u.resok.count, nfs, res->READ3res_u.resok.data.data_val, data->private_data); + cb_err = res->READ3res_u.resok.count; + cb_data = res->READ3res_u.resok.data.data_val; } data->nfsfh->ra.fh_offset = data->max_offset; @@ -1919,6 +1923,8 @@ static void nfs_pread_mcb(struct rpc_context *rpc, int status, void *command_dat data->nfsfh->ra.buf_ts = time(NULL); data->buffer = NULL; } + + data->cb(cb_err, nfs, cb_data, data->private_data); free_nfs_cb_data(data); }