From c2ca9e02106108c024b0daf27325e8eba35437f2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 2 Nov 2012 12:52:51 +0100 Subject: s3:vfs_default: optimize vfswrap_asys_finished() and read as much as we can Signed-off-by: Stefan Metzmacher Autobuild-User(master): Volker Lendecke Autobuild-Date(master): Mon Nov 5 19:01:13 CET 2012 on sn-devel-104 --- source3/modules/vfs_default.c | 49 +++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 16 deletions(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 8e980e0cbc..0f651dca51 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -637,6 +637,7 @@ static void vfswrap_asys_finished(struct tevent_context *ev, static bool vfswrap_init_asys_ctx(struct smbXsrv_connection *conn) { int ret; + int fd; if (conn->asys_ctx != NULL) { return true; @@ -646,8 +647,12 @@ static bool vfswrap_init_asys_ctx(struct smbXsrv_connection *conn) DEBUG(1, ("asys_context_init failed: %s\n", strerror(ret))); return false; } - conn->asys_fde = tevent_add_fd(conn->ev_ctx, conn, - asys_signalfd(conn->asys_ctx), + + fd = asys_signalfd(conn->asys_ctx); + + set_blocking(fd, false); + + conn->asys_fde = tevent_add_fd(conn->ev_ctx, conn, fd, TEVENT_FD_READ, vfswrap_asys_finished, conn->asys_ctx); @@ -783,24 +788,36 @@ static void vfswrap_asys_finished(struct tevent_context *ev, return; } - res = asys_result(asys_ctx, &ret, &err, &private_data); - if (res == ECANCELED) { - return; - } + while (true) { + res = asys_result(asys_ctx, &ret, &err, &private_data); + if (res == EINTR || res == EAGAIN) { + return; + } +#ifdef EWOULDBLOCK + if (res == EWOULDBLOCK) { + return; + } +#endif - if (res != 0) { - DEBUG(1, ("asys_result returned %s\n", strerror(res))); - return; - } + if (res == ECANCELED) { + return; + } - req = talloc_get_type_abort(private_data, struct tevent_req); - state = tevent_req_data(req, struct vfswrap_asys_state); + if (res != 0) { + DEBUG(1, ("asys_result returned %s\n", strerror(res))); + return; + } + + req = talloc_get_type_abort(private_data, struct tevent_req); + state = tevent_req_data(req, struct vfswrap_asys_state); - talloc_set_destructor(state, NULL); + talloc_set_destructor(state, NULL); - state->ret = ret; - state->err = err; - tevent_req_done(req); + state->ret = ret; + state->err = err; + tevent_req_defer_callback(req, ev); + tevent_req_done(req); + } } static ssize_t vfswrap_asys_ssize_t_recv(struct tevent_req *req, int *err) -- cgit