summaryrefslogtreecommitdiff
path: root/source3/modules/vfs_default.c
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2012-11-02 12:52:51 +0100
committerVolker Lendecke <vl@samba.org>2012-11-05 19:01:13 +0100
commitc2ca9e02106108c024b0daf27325e8eba35437f2 (patch)
tree876ddf899690f96f8ef9c1f6ffaacd16e166d6b6 /source3/modules/vfs_default.c
parent719595b6f7f8745f2608dddb2b86476b9cc2f598 (diff)
downloadsamba-c2ca9e02106108c024b0daf27325e8eba35437f2.tar.gz
samba-c2ca9e02106108c024b0daf27325e8eba35437f2.tar.bz2
samba-c2ca9e02106108c024b0daf27325e8eba35437f2.zip
s3:vfs_default: optimize vfswrap_asys_finished() and read as much as we can
Signed-off-by: Stefan Metzmacher <metze@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Mon Nov 5 19:01:13 CET 2012 on sn-devel-104
Diffstat (limited to 'source3/modules/vfs_default.c')
-rw-r--r--source3/modules/vfs_default.c49
1 files changed, 33 insertions, 16 deletions
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)