From c35fec883cf344a269e65670521e2580a91c24aa Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 24 Mar 2014 14:36:34 +0000 Subject: asys: Allow multiple results to be received This makes use of C99 dynamic arrays. In this performance-sensitive code, I would like to avoid malloc/free, and I think 15 years after the standard we might be able to use this feature. Alternatively, we could use the "results" memory area and store the jobids in the upper range, playing some cast-tricks. Should work as well. Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- source3/modules/vfs_default.c | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 7dd9c0ca3e..02ab35b128 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -793,44 +793,39 @@ static void vfswrap_asys_finished(struct tevent_context *ev, uint16_t flags, void *p) { struct asys_context *asys_ctx = (struct asys_context *)p; - struct tevent_req *req; - struct vfswrap_asys_state *state; - int res; - ssize_t ret; - int err; - void *private_data; if ((flags & TEVENT_FD_READ) == 0) { return; } while (true) { - res = asys_result(asys_ctx, &ret, &err, &private_data); - if (res == EINTR || res == EAGAIN) { + struct tevent_req *req; + struct vfswrap_asys_state *state; + struct asys_result result; + int res; + + res = asys_results(asys_ctx, &result, 1); + if (res < 0) { + DEBUG(1, ("asys_result returned %s\n", + strerror(-res))); return; } -#ifdef EWOULDBLOCK - if (res == EWOULDBLOCK) { - return; - } -#endif - - if (res == ECANCELED) { + if (res == 0) { return; } - if (res != 0) { - DEBUG(1, ("asys_result returned %s\n", strerror(res))); + if ((result.ret == -1) && (result.err == ECANCELED)) { return; } - req = talloc_get_type_abort(private_data, struct tevent_req); + req = talloc_get_type_abort(result.private_data, + struct tevent_req); state = tevent_req_data(req, struct vfswrap_asys_state); talloc_set_destructor(state, NULL); - state->ret = ret; - state->err = err; + state->ret = result.ret; + state->err = result.err; tevent_req_defer_callback(req, ev); tevent_req_done(req); } -- cgit