vfs_default: add sync fallback to fsync_send/recv
[garming/samba-autobuild/.git] / source3 / modules / vfs_default.c
index 57ce0b465ece72b5dd49f5fb1759cad9f6481c5a..8d40cd64540a1fe193da3e9f9ffa7c9cec9ebee6 100644 (file)
@@ -988,8 +988,18 @@ static void vfs_fsync_done(struct tevent_req *subreq)
        TALLOC_FREE(subreq);
        SMBPROFILE_BYTES_ASYNC_END(state->profile_bytes);
        talloc_set_destructor(state, NULL);
-       if (tevent_req_error(req, ret)) {
-               return;
+       if (ret != 0) {
+               if (ret != EAGAIN) {
+                       tevent_req_error(req, ret);
+                       return;
+               }
+               /*
+                * If we get EAGAIN from pthreadpool_tevent_job_recv() this
+                * means the lower level pthreadpool failed to create a new
+                * thread. Fallback to sync processing in that case to allow
+                * some progress for the client.
+                */
+               vfs_fsync_do(state);
        }
 
        tevent_req_done(req);