]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Factor out generic 'HAVE_ONDEMAND' macro flag
authorBrian Norris <briannorris@google.com>
Fri, 27 May 2016 20:06:58 +0000 (13:06 -0700)
committerBrian Norris <briannorris@google.com>
Fri, 27 May 2016 20:06:58 +0000 (13:06 -0700)
HAVE_SYSTEMD and HAVE_LAUNCHD use very similar code for on-demand
launching of cupsd, and if we want to add one more (e.g., upstart) it's
easier to just use a single common flag: HAVE_ONDEMAND.

config.h.in
scheduler/client.h
scheduler/conf.c
scheduler/conf.h
scheduler/cupsd.h
scheduler/listen.c
scheduler/main.c
vcnet/config.h
xcode/config.h

index e242d561185169b2e802bda50a2b7e96936157da..526f91a5eb1611bf2198534b8f733bbc080691ad 100644 (file)
@@ -717,4 +717,10 @@ static __inline int _cups_abs(int i) { return (i < 0 ? -i : i); }
 #  endif /* __GNUC__ || __STDC_VERSION__ */
 #endif /* !HAVE_ABS && !abs */
 
+#if defined(HAVE_LAUNCHD) || defined(HAVE_SYSTEMD)
+#  define HAVE_ONDEMAND
+#else
+#  undef HAVE_ONDEMAND
+#endif
+
 #endif /* !_CUPS_CONFIG_H_ */
index a7811fa781a6c224de8535dcd99cbc711c9b30c3..174b7271e7efb08b56f0bfaa39a8be2c9f292914 100644 (file)
@@ -79,9 +79,9 @@ typedef struct
   int                  fd;             /* File descriptor for this server */
   http_addr_t          address;        /* Bind address of socket */
   http_encryption_t    encryption;     /* To encrypt or not to encrypt... */
-#if defined(HAVE_LAUNCHD) || defined(HAVE_SYSTEMD)
+#if defined(HAVE_ONDEMAND)
   int                  on_demand;      /* Is this a socket from launchd/systemd? */
-#endif /* HAVE_LAUNCHD || HAVE_SYSTEMD */
+#endif /* HAVE_ONDEMAND */
 } cupsd_listener_t;
 
 
index 5f97fa3b8eaa0663497f9b8d134739a00d602eff..7695f56f4a3b5edf9c43fb42c914d7f7690db012 100644 (file)
@@ -89,9 +89,9 @@ static const cupsd_var_t      cupsd_vars[] =
 #ifdef HAVE_GSSAPI
   { "GSSServiceName",          &GSSServiceName,        CUPSD_VARTYPE_STRING },
 #endif /* HAVE_GSSAPI */
-#if defined(HAVE_LAUNCHD) || defined(HAVE_SYSTEMD)
+#if defined(HAVE_ONDEMAND)
   { "IdleExitTimeout",         &IdleExitTimeout,       CUPSD_VARTYPE_TIME },
-#endif /* HAVE_LAUNCHD || HAVE_SYSTEMD */
+#endif /* HAVE_ONDEMAND */
   { "JobKillDelay",            &JobKillDelay,          CUPSD_VARTYPE_TIME },
   { "JobRetryLimit",           &JobRetryLimit,         CUPSD_VARTYPE_INTEGER },
   { "JobRetryInterval",                &JobRetryInterval,      CUPSD_VARTYPE_TIME },
@@ -810,9 +810,9 @@ cupsdReadConfiguration(void)
   DefaultLeaseDuration       = 86400;
   MaxLeaseDuration           = 0;
 
-#if defined(HAVE_LAUNCHD) || defined(HAVE_SYSTEMD)
+#if defined(HAVE_ONDEMAND)
   IdleExitTimeout = 60;
-#endif /* HAVE_LAUNCHD || HAVE_SYSTEMD */
+#endif /* HAVE_ONDEMAND */
 
  /*
   * Setup environment variables...
@@ -3149,9 +3149,9 @@ read_cupsd_conf(cups_file_t *fp)  /* I - File to read from */
 
         if (lis)
        {
-#if defined(HAVE_LAUNCHD) || defined(HAVE_SYSTEMD)
+#if defined(HAVE_ONDEMAND)
          if (!lis->on_demand)
-#endif /* HAVE_LAUNCHD || HAVE_SYSTEMD */
+#endif /* HAVE_ONDEMAND */
          {
            httpAddrString(&lis->address, temp, sizeof(temp));
            cupsdLogMessage(CUPSD_LOG_WARN,
index 076d63db03e3f775c6140a80f7bd9d5353cde415..ff18b775003adc48512d96692d3e707891c14c9a 100644 (file)
@@ -244,10 +244,10 @@ VAR char          *ServerKeychain         VALUE(NULL);
                                        /* Keychain holding cert + key */
 #endif /* HAVE_SSL */
 
-#if defined(HAVE_LAUNCHD) || defined(HAVE_SYSTEMD)
+#if defined(HAVE_ONDEMAND)
 VAR int                        IdleExitTimeout         VALUE(60);
                                        /* Time after which an idle cupsd will exit */
-#endif /* HAVE_LAUNCHD || HAVE_SYSTEMD */
+#endif /* HAVE_ONDEMAND */
 
 #ifdef HAVE_AUTHORIZATION_H
 VAR char               *SystemGroupAuthKey     VALUE(NULL);
index a36ae88d1d709626de0a99ffb5a0357c7f59f83b..669560c15b31f29c015c3e6ac02c0d7a4025d958 100644 (file)
@@ -157,10 +157,10 @@ VAR int                   NeedReload      VALUE(RELOAD_ALL),
 VAR void               *DefaultProfile VALUE(0);
                                        /* Default security profile */
 
-#if defined(HAVE_LAUNCHD) || defined(HAVE_SYSTEMD)
+#if defined(HAVE_ONDEMAND)
 VAR int                        OnDemand        VALUE(0);
                                        /* Launched on demand */
-#endif /* HAVE_LAUNCHD || HAVE_SYSTEMD */
+#endif /* HAVE_ONDEMAND */
 
 
 /*
index 06e2ed6aac081af4565074ed99cee995e18392c3..7cfe8dbd1b8262852b46a8f597ee3f9f03dfc748 100644 (file)
@@ -41,9 +41,9 @@ cupsdDeleteAllListeners(void)
   for (lis = (cupsd_listener_t *)cupsArrayFirst(Listeners);
        lis;
        lis = (cupsd_listener_t *)cupsArrayNext(Listeners))
-#if defined(HAVE_LAUNCHD) || defined(HAVE_SYSTEMD)
+#if defined(HAVE_ONDEMAND)
     if (!lis->on_demand)
-#endif /* HAVE_LAUNCHD || HAVE_SYSTEMD */
+#endif /* HAVE_ONDEMAND */
     {
       cupsArrayRemove(Listeners, lis);
       free(lis);
@@ -281,7 +281,7 @@ cupsdStopListening(void)
        lis;
        lis = (cupsd_listener_t *)cupsArrayNext(Listeners))
   {
-#if defined(HAVE_LAUNCHD) || defined(HAVE_SYSTEMD)
+#if defined(HAVE_ONDEMAND)
     if (!lis->on_demand && lis->fd != -1)
     {
       httpAddrClose(&(lis->address), lis->fd);
@@ -294,6 +294,6 @@ cupsdStopListening(void)
       httpAddrClose(&(lis->address), lis->fd);
       lis->fd = -1;
     }
-#endif /* HAVE_LAUNCHD || HAVE_SYSTEMD */
+#endif /* HAVE_ONDEMAND */
   }
 }
index f9b46bad6ed6f103e2b1c7ae75906b66a6cfdb8b..8b65ae1e43302c1ca59c84a145b167372e9bb4cf 100644 (file)
@@ -71,10 +71,10 @@ static void         sigchld_handler(int sig);
 static void            sighup_handler(int sig);
 static void            sigterm_handler(int sig);
 static long            select_timeout(int fds);
-#if defined(HAVE_LAUNCHD) || defined(HAVE_SYSTEMD)
+#if defined(HAVE_ONDEMAND)
 static void            service_checkin(void);
 static void            service_checkout(void);
-#endif /* HAVE_LAUNCHD || HAVE_SYSTEMD */
+#endif /* HAVE_ONDEMAND */
 static void            usage(int status) __attribute__((noreturn));
 
 
@@ -131,10 +131,10 @@ main(int  argc,                           /* I - Number of command-line args */
 #else
   time_t               netif_time = 0; /* Time since last network update */
 #endif /* __APPLE__ */
-#if defined(HAVE_LAUNCHD) || defined(HAVE_SYSTEMD)
+#if defined(HAVE_ONDEMAND)
   int                  service_idle_exit;
                                        /* Idle exit on select timeout? */
-#endif /* HAVE_LAUNCHD || HAVE_SYSTEMD */
+#endif /* HAVE_ONDEMAND */
 
 
 #ifdef HAVE_GETEUID
@@ -243,7 +243,7 @@ main(int  argc,                             /* I - Number of command-line args */
              break;
 
           case 'l' : /* Started by launchd/systemd... */
-#if defined(HAVE_LAUNCHD) || defined(HAVE_SYSTEMD)
+#if defined(HAVE_ONDEMAND)
              OnDemand   = 1;
              fg         = 1;
              close_all  = 0;
@@ -254,7 +254,7 @@ main(int  argc,                             /* I - Number of command-line args */
               fg         = 0;
              disconnect = 1;
              close_all  = 1;
-#endif /* HAVE_LAUNCHD || HAVE_SYSTEMD */
+#endif /* HAVE_ONDEMAND */
              break;
 
           case 'p' : /* Stop immediately for profiling */
@@ -584,7 +584,7 @@ main(int  argc,                             /* I - Number of command-line args */
 
   cupsdCleanFiles(CacheDir, "*.ipp");
 
-#if defined(HAVE_LAUNCHD) || defined(HAVE_SYSTEMD)
+#if defined(HAVE_ONDEMAND)
   if (OnDemand)
   {
    /*
@@ -595,7 +595,7 @@ main(int  argc,                             /* I - Number of command-line args */
     service_checkin();
     service_checkout();
   }
-#endif /* HAVE_LAUNCHD || HAVE_SYSTEMD */
+#endif /* HAVE_ONDEMAND */
 
  /*
   * Startup the server...
@@ -682,11 +682,11 @@ main(int  argc,                           /* I - Number of command-line args */
   * Send server-started event...
   */
 
-#if defined(HAVE_LAUNCHD) || defined(HAVE_SYSTEMD)
+#if defined(HAVE_ONDEMAND)
   if (OnDemand)
     cupsdAddEvent(CUPSD_EVENT_SERVER_STARTED, NULL, NULL, "Scheduler started on demand.");
   else
-#endif /* HAVE_LAUNCHD || HAVE_SYSTEMD */
+#endif /* HAVE_ONDEMAND */
   if (fg)
     cupsdAddEvent(CUPSD_EVENT_SERVER_STARTED, NULL, NULL, "Scheduler started in foreground.");
   else
@@ -809,7 +809,7 @@ main(int  argc,                             /* I - Number of command-line args */
     if ((timeout = select_timeout(fds)) > 1 && LastEvent)
       timeout = 1;
 
-#if defined(HAVE_LAUNCHD) || defined(HAVE_SYSTEMD)
+#if defined(HAVE_ONDEMAND)
    /*
     * If no other work is scheduled and we're being controlled by
     * launchd then timeout after 'LaunchdTimeout' seconds of
@@ -828,7 +828,7 @@ main(int  argc,                             /* I - Number of command-line args */
     }
     else
       service_idle_exit = 0;
-#endif /* HAVE_LAUNCHD || HAVE_SYSTEMD */
+#endif /* HAVE_ONDEMAND */
 
     if ((fds = cupsdDoSelect(timeout)) < 0)
     {
@@ -925,7 +925,7 @@ main(int  argc,                             /* I - Number of command-line args */
     }
 #endif /* !__APPLE__ */
 
-#if defined(HAVE_LAUNCHD) || defined(HAVE_SYSTEMD)
+#if defined(HAVE_ONDEMAND)
    /*
     * If no other work was scheduled and we're being controlled by launchd
     * then timeout after 'LaunchdTimeout' seconds of inactivity...
@@ -939,7 +939,7 @@ main(int  argc,                             /* I - Number of command-line args */
       stop_scheduler = 1;
       break;
     }
-#endif /* HAVE_LAUNCHD || HAVE_SYSTEMD */
+#endif /* HAVE_ONDEMAND */
 
    /*
     * Resume listening for new connections as needed...
@@ -1143,14 +1143,14 @@ main(int  argc,                         /* I - Number of command-line args */
 
   cupsdStopServer();
 
-#if defined(HAVE_LAUNCHD) || defined(HAVE_SYSTEMD)
+#if defined(HAVE_ONDEMAND)
  /*
   * Update the keep-alive file as needed...
   */
 
   if (OnDemand)
     service_checkout();
-#endif /* HAVE_LAUNCHD || HAVE_SYSTEMD */
+#endif /* HAVE_ONDEMAND */
 
  /*
   * Stop all jobs...
@@ -1822,7 +1822,7 @@ sigterm_handler(int sig)          /* I - Signal number */
 }
 
 
-#if defined(HAVE_LAUNCHD) || defined(HAVE_SYSTEMD)
+#if defined(HAVE_ONDEMAND)
 /*
  * 'service_checkin()' - Check-in with launchd and collect the listening fds.
  */
@@ -2174,7 +2174,7 @@ service_checkout(void)
     unlink(CUPS_KEEPALIVE);
   }
 }
-#endif /* HAVE_LAUNCHD || HAVE_SYSTEMD */
+#endif /* HAVE_ONDEMAND */
 
 
 /*
index e8e73f6b13acf149398042b854dc3e8f2c4e7161..0f1291cc59a8cface894c8a689b7be1fe10741aa 100644 (file)
@@ -777,4 +777,10 @@ static __inline int _cups_abs(int i) { return (i < 0 ? -i : i); }
 #  endif /* __GNUC__ || __STDC_VERSION__ */
 #endif /* !HAVE_ABS && !abs */
 
+#if defined(HAVE_LAUNCHD) || defined(HAVE_SYSTEMD)
+#  define HAVE_ONDEMAND
+#else
+#  undef HAVE_ONDEMAND
+#endif
+
 #endif /* !_CUPS_CONFIG_H_ */
index e16c6667cbaa50488f07e09f363528926a79b041..a0c5c9b3d48c18fbae58441426943490ec701719 100644 (file)
@@ -733,4 +733,10 @@ static __inline int _cups_abs(int i) { return (i < 0 ? -i : i); }
 #  endif /* __GNUC__ || __STDC_VERSION__ */
 #endif /* !HAVE_ABS && !abs */
 
+#if defined(HAVE_LAUNCHD) || defined(HAVE_SYSTEMD)
+#  define HAVE_ONDEMAND
+#else
+#  undef HAVE_ONDEMAND
+#endif
+
 #endif /* !_CUPS_CONFIG_H_ */