]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - scheduler/listen.c
More journald/asl logging bug fixes (STR #4661)
[thirdparty/cups.git] / scheduler / listen.c
index b23c5e27bf6172b9702b4e53be0321672d9f5f83..b55d918b01e9c5bf0e515f19ee81653bcf03d831 100644 (file)
@@ -43,10 +43,19 @@ cupsdDeleteAllListeners(void)
   for (lis = (cupsd_listener_t *)cupsArrayFirst(Listeners);
        lis;
        lis = (cupsd_listener_t *)cupsArrayNext(Listeners))
-    free(lis);
+#if defined(HAVE_LAUNCHD) || defined(HAVE_SYSTEMD)
+    if (!lis->on_demand)
+#endif /* HAVE_LAUNCHD || HAVE_SYSTEMD */
+    {
+      cupsArrayRemove(Listeners, lis);
+      free(lis);
+    }
 
-  cupsArrayDelete(Listeners);
-  Listeners = NULL;
+  if (cupsArrayCount(Listeners) == 0)
+  {
+    cupsArrayDelete(Listeners);
+    Listeners = NULL;
+  }
 }
 
 
@@ -275,15 +284,19 @@ cupsdStopListening(void)
        lis = (cupsd_listener_t *)cupsArrayNext(Listeners))
   {
 #if defined(HAVE_LAUNCHD) || defined(HAVE_SYSTEMD)
-    if (lis->fd != -1 && !lis->on_demand)
+    if (!lis->on_demand && lis->fd != -1)
+    {
       httpAddrClose(&(lis->address), lis->fd);
+      lis->fd = -1;
+    }
 
 #else
     if (lis->fd != -1)
+    {
       httpAddrClose(&(lis->address), lis->fd);
+      lis->fd = -1;
+    }
 #endif /* HAVE_LAUNCHD || HAVE_SYSTEMD */
-
-    lis->fd = -1;
   }
 }