s3:smbd: don't use async dosmode if per-thread cwd is not available
[samba.git] / source3 / smbd / smb2_query_directory.c
index 1a3447c3a828ed06bbd941db5a822f5a42f754c4..fdb87188f93386018ec2eefe920d220ad596bf3e 100644 (file)
@@ -125,7 +125,7 @@ NTSTATUS smbd_smb2_request_process_query_directory(struct smbd_smb2_request *req
                return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED);
        }
 
-       subreq = smbd_smb2_query_directory_send(req, req->ev_ctx,
+       subreq = smbd_smb2_query_directory_send(req, req->sconn->ev_ctx,
                                     req, in_fsp,
                                     in_file_info_class,
                                     in_flags,
@@ -275,7 +275,7 @@ static struct tevent_req *smbd_smb2_query_directory_send(TALLOC_CTX *mem_ctx,
        if (req == NULL) {
                return NULL;
        }
-       state->ev = fsp->conn->sconn->raw_ev_ctx;
+       state->ev = ev;
        state->fsp = fsp;
        state->smb2req = smb2req;
        state->in_output_buffer_length = in_output_buffer_length;
@@ -515,7 +515,10 @@ static struct tevent_req *smbd_smb2_query_directory_send(TALLOC_CTX *mem_ctx,
        if (state->async_dosmode) {
                size_t max_threads;
 
-               max_threads = pthreadpool_tevent_max_threads(conn->sconn->raw_thread_pool);
+               max_threads = pthreadpool_tevent_max_threads(conn->sconn->pool);
+               if (max_threads == 0 || !per_thread_cwd_supported()) {
+                       state->async_dosmode = false;
+               }
 
                state->max_async_dosmode_active = lp_smbd_max_async_dosmode(
                                                        SNUM(conn));
@@ -660,7 +663,7 @@ static bool smb2_query_directory_next_entry(struct tevent_req *req)
                state->async_dosmode_active++;
 
                outstanding_aio = pthreadpool_tevent_queued_jobs(
-                                       state->fsp->conn->sconn->raw_thread_pool);
+                                       state->fsp->conn->sconn->pool);
 
                if (outstanding_aio > state->max_async_dosmode_active) {
                        stop = true;