]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
mdssvc: fix long running backend queries
authorRalph Boehme <slow@samba.org>
Thu, 23 Mar 2023 15:39:11 +0000 (16:39 +0100)
committerJule Anger <janger@samba.org>
Mon, 31 Jul 2023 08:08:13 +0000 (08:08 +0000)
If a query is still running in the backend and we have no results yet, returning
0 triggers a search termination by the client in latest macOS releases. macOS
returns 0x23 in this case.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15342

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 925fefae20e52a3c89a56bdd0cd5b98cc951db5f)

source3/rpc_server/mdssvc/mdssvc.c

index 1f077bee23ddecace9118c245042ebf463e9887d..c394a180b1aca460575caf1419de2f1dd7a3452f 100644 (file)
@@ -306,10 +306,21 @@ static bool create_result_handle(struct sl_query *slq)
 static bool add_results(sl_array_t *array, struct sl_query *slq)
 {
        sl_filemeta_t *fm;
-       uint64_t status = 0;
+       uint64_t status;
        int result;
        bool ok;
 
+       /*
+        * Taken from a network trace against a macOS SMB Spotlight server. If
+        * the first fetch-query-results has no results yet because the search
+        * is still running, macOS returns 0x23, otherwise 0x0.
+        */
+       if (slq->state >= SLQ_STATE_RESULTS ) {
+               status = 0;
+       } else {
+               status = 0x23;
+       }
+
        /* FileMeta */
        fm = dalloc_zero(array, sl_filemeta_t);
        if (fm == NULL) {