From: Ralph Boehme Date: Fri, 8 Aug 2014 11:58:08 +0000 (+0200) Subject: Spotlight: move init to the right place X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netatalk.git;a=commitdiff_plain;h=7d4c103bcc2f7f9c60eb431a2770cc26d0056552 Spotlight: move init to the right place Signed-off-by: Ralph Boehme --- diff --git a/etc/afpd/afp_dsi.c b/etc/afpd/afp_dsi.c index a6de766a..8b5187b8 100644 --- a/etc/afpd/afp_dsi.c +++ b/etc/afpd/afp_dsi.c @@ -493,13 +493,6 @@ void afp_over_dsi(AFPObj *obj) 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 */ diff --git a/etc/afpd/spotlight.c b/etc/afpd/spotlight.c index 3755e41d..7551bc71 100644 --- a/etc/afpd/spotlight.c +++ b/etc/afpd/spotlight.c @@ -1192,9 +1192,14 @@ EC_CLEANUP: int spotlight_init(AFPObj *obj) { + static bool initialized = false; 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); @@ -1220,6 +1225,7 @@ int spotlight_init(AFPObj *obj) tracker_sparql_connection_get_async(sl_ctx->cancellable, tracker_con_cb, sl_ctx); + initialized = true; return 0; } @@ -1247,6 +1253,8 @@ int afp_spotlight_rpc(AFPObj *obj, char *ibuf, size_t ibuflen, return AFPERR_NOOP; } + spotlight_init(obj); + /* * Process finished glib events */