]> arthur.barton.de Git - netatalk.git/commitdiff
Spotlight: move init to the right place
authorRalph Boehme <rb@sernet.de>
Fri, 8 Aug 2014 11:58:08 +0000 (13:58 +0200)
committerRalph Boehme <rb@sernet.de>
Fri, 8 Aug 2014 11:58:08 +0000 (13:58 +0200)
Signed-off-by: Ralph Boehme <rb@sernet.de>
etc/afpd/afp_dsi.c
etc/afpd/spotlight.c

index a6de766aad2d54c92ab17778a685a2261e0a7220..8b5187b881778ee398e8c4c62ae428eba43e7f01 100644 (file)
@@ -493,13 +493,6 @@ void afp_over_dsi(AFPObj *obj)
     int flag = 1;
     setsockopt(dsi->socket, SOL_TCP, TCP_NODELAY, &flag, sizeof(flag));
 
     int flag = 1;
     setsockopt(dsi->socket, SOL_TCP, TCP_NODELAY, &flag, sizeof(flag));
 
-#ifdef HAVE_TRACKER
-    /* Initialize Spotlight */
-    if (obj->options.flags & OPTION_SPOTLIGHT) {
-        spotlight_init(obj);
-    }
-#endif
-
     ipc_child_state(obj, DSI_RUNNING);
 
     /* get stuck here until the end */
     ipc_child_state(obj, DSI_RUNNING);
 
     /* get stuck here until the end */
index 3755e41d1326d9d289da5ef90ea0ecbff1b8d8b8..7551bc7174f1ed2b655fb6d664e06ce7c5f6f02c 100644 (file)
@@ -1192,9 +1192,14 @@ EC_CLEANUP:
 
 int spotlight_init(AFPObj *obj)
 {
 
 int spotlight_init(AFPObj *obj)
 {
+    static bool initialized = false;
     const char *attributes;
     struct sl_ctx *sl_ctx;
 
     const char *attributes;
     struct sl_ctx *sl_ctx;
 
+    if (initialized) {
+        return 0;
+    }
+
     LOG(log_info, logtype_sl, "Initializing Spotlight");
 
     sl_ctx = talloc_zero(NULL, struct sl_ctx);
     LOG(log_info, logtype_sl, "Initializing Spotlight");
 
     sl_ctx = talloc_zero(NULL, struct sl_ctx);
@@ -1220,6 +1225,7 @@ int spotlight_init(AFPObj *obj)
     tracker_sparql_connection_get_async(sl_ctx->cancellable,
                                         tracker_con_cb, sl_ctx);
 
     tracker_sparql_connection_get_async(sl_ctx->cancellable,
                                         tracker_con_cb, sl_ctx);
 
+    initialized = true;
     return 0;
 }
 
     return 0;
 }
 
@@ -1247,6 +1253,8 @@ int afp_spotlight_rpc(AFPObj *obj, char *ibuf, size_t ibuflen,
         return AFPERR_NOOP;
     }
 
         return AFPERR_NOOP;
     }
 
+    spotlight_init(obj);
+
     /*
      * Process finished glib events
      */
     /*
      * Process finished glib events
      */