summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Sweet <michael.r.sweet@gmail.com>2016-06-21 11:57:03 -0400
committerMichael Sweet <michael.r.sweet@gmail.com>2016-06-21 11:57:03 -0400
commit1166bf58660ab483d7d743f05f5da84b56202a16 (patch)
tree11944e5b87f518ca0e25c7721a12e7fec3c4a161
parent6ee5217845b2392402a50906b25eb242de753f6a (diff)
downloadcups-1166bf58660ab483d7d743f05f5da84b56202a16.tar.gz
Do some cleanup for the on-demand support - remove old launchd support (no
longer needed), naming/style updates, fix compiler warnings.
-rw-r--r--config-scripts/cups-startup.m411
-rw-r--r--config.h.in15
-rwxr-xr-xconfigure28
-rw-r--r--scheduler/client.h4
-rw-r--r--scheduler/conf.c8
-rw-r--r--scheduler/conf.h4
-rw-r--r--scheduler/cupsd.h4
-rw-r--r--scheduler/listen.c6
-rw-r--r--scheduler/main.c188
-rw-r--r--vcnet/config.h20
-rw-r--r--xcode/config.h28
11 files changed, 117 insertions, 199 deletions
diff --git a/config-scripts/cups-startup.m4 b/config-scripts/cups-startup.m4
index d61bf9cbb..0ab61ec45 100644
--- a/config-scripts/cups-startup.m4
+++ b/config-scripts/cups-startup.m4
@@ -22,12 +22,9 @@ LAUNCHD_DIR=""
AC_SUBST(LAUNCHD_DIR)
if test x$enable_launchd != xno; then
- AC_CHECK_FUNC(launch_msg, AC_DEFINE(HAVE_LAUNCHD))
- if test $uversion -ge 140; then
- AC_CHECK_FUNC(launch_activate_socket, [
- AC_DEFINE(HAVE_LAUNCHD)
- AC_DEFINE(HAVE_LAUNCH_ACTIVATE_SOCKET)])
- fi
+ AC_CHECK_FUNC(launch_activate_socket, [
+ AC_DEFINE(HAVE_LAUNCHD)
+ AC_DEFINE(HAVE_ONDEMAND)])
AC_CHECK_HEADER(launch.h, AC_DEFINE(HAVE_LAUNCH_H))
case "$uname" in
@@ -77,6 +74,7 @@ if test x$enable_systemd != xno; then
if test $have_systemd = yes; then
AC_DEFINE(HAVE_SYSTEMD)
+ AC_DEFINE(HAVE_ONDEMAND)
AC_CHECK_HEADER(systemd/sd-journal.h,AC_DEFINE(HAVE_SYSTEMD_SD_JOURNAL_H))
if test "x$SYSTEMD_DIR" = x; then
SYSTEMD_DIR="`$PKGCONFIG --variable=systemdsystemunitdir systemd`"
@@ -92,6 +90,7 @@ if test "x$enable_upstart" = "xyes"; then
AC_MSG_ERROR(Cannot support both systemd and upstart.)
fi
AC_DEFINE(HAVE_UPSTART)
+ AC_DEFINE(HAVE_ONDEMAND)
fi
dnl Solaris uses smf
diff --git a/config.h.in b/config.h.in
index 05490a519..0323eaace 100644
--- a/config.h.in
+++ b/config.h.in
@@ -480,12 +480,18 @@
/*
+ * Do we have on-demand support (launchd/systemd/upstart)?
+ */
+
+#undef HAVE_ONDEMAND
+
+
+/*
* Do we have launchd support?
*/
#undef HAVE_LAUNCH_H
#undef HAVE_LAUNCHD
-#undef HAVE_LAUNCH_ACTIVATE_SOCKET
/*
@@ -494,6 +500,7 @@
#undef HAVE_SYSTEMD
+
/*
* Do we have upstart support?
*/
@@ -730,10 +737,4 @@ 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) || defined(HAVE_UPSTART)
-# define HAVE_ONDEMAND
-#else
-# undef HAVE_ONDEMAND
-#endif
-
#endif /* !_CUPS_CONFIG_H_ */
diff --git a/configure b/configure
index 9b27eaf19..8185ce472 100755
--- a/configure
+++ b/configure
@@ -8764,7 +8764,7 @@ else
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -8810,7 +8810,7 @@ else
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -8834,7 +8834,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -8879,7 +8879,7 @@ else
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -8903,7 +8903,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -9124,23 +9124,15 @@ LAUNCHD_DIR=""
if test x$enable_launchd != xno; then
- ac_fn_c_check_func "$LINENO" "launch_msg" "ac_cv_func_launch_msg"
-if test "x$ac_cv_func_launch_msg" = xyes; then :
- $as_echo "#define HAVE_LAUNCHD 1" >>confdefs.h
-
-fi
-
- if test $uversion -ge 140; then
- ac_fn_c_check_func "$LINENO" "launch_activate_socket" "ac_cv_func_launch_activate_socket"
+ ac_fn_c_check_func "$LINENO" "launch_activate_socket" "ac_cv_func_launch_activate_socket"
if test "x$ac_cv_func_launch_activate_socket" = xyes; then :
- $as_echo "#define HAVE_LAUNCHD 1" >>confdefs.h
+ $as_echo "#define HAVE_LAUNCHD 1" >>confdefs.h
- $as_echo "#define HAVE_LAUNCH_ACTIVATE_SOCKET 1" >>confdefs.h
+ $as_echo "#define HAVE_ONDEMAND 1" >>confdefs.h
fi
- fi
ac_fn_c_check_header_mongrel "$LINENO" "launch.h" "ac_cv_header_launch_h" "$ac_includes_default"
if test "x$ac_cv_header_launch_h" = xyes; then :
$as_echo "#define HAVE_LAUNCH_H 1" >>confdefs.h
@@ -9210,6 +9202,8 @@ $as_echo "no" >&6; }
if test $have_systemd = yes; then
$as_echo "#define HAVE_SYSTEMD 1" >>confdefs.h
+ $as_echo "#define HAVE_ONDEMAND 1" >>confdefs.h
+
ac_fn_c_check_header_mongrel "$LINENO" "systemd/sd-journal.h" "ac_cv_header_systemd_sd_journal_h" "$ac_includes_default"
if test "x$ac_cv_header_systemd_sd_journal_h" = xyes; then :
$as_echo "#define HAVE_SYSTEMD_SD_JOURNAL_H 1" >>confdefs.h
@@ -9235,6 +9229,8 @@ if test "x$enable_upstart" = "xyes"; then
fi
$as_echo "#define HAVE_UPSTART 1" >>confdefs.h
+ $as_echo "#define HAVE_ONDEMAND 1" >>confdefs.h
+
fi
SMFMANIFESTDIR=""
diff --git a/scheduler/client.h b/scheduler/client.h
index f97f41def..d58d11148 100644
--- a/scheduler/client.h
+++ b/scheduler/client.h
@@ -1,7 +1,7 @@
/*
* Client definitions for the CUPS scheduler.
*
- * Copyright 2007-2014 by Apple Inc.
+ * Copyright 2007-2016 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
@@ -79,7 +79,7 @@ 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_ONDEMAND)
+#ifdef HAVE_ONDEMAND
int on_demand; /* Is this a socket from launchd/systemd/upstart? */
#endif /* HAVE_ONDEMAND */
} cupsd_listener_t;
diff --git a/scheduler/conf.c b/scheduler/conf.c
index 7695f56f4..088501e88 100644
--- a/scheduler/conf.c
+++ b/scheduler/conf.c
@@ -1,7 +1,7 @@
/*
* Configuration routines for the CUPS scheduler.
*
- * Copyright 2007-2015 by Apple Inc.
+ * Copyright 2007-2016 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
@@ -89,7 +89,7 @@ static const cupsd_var_t cupsd_vars[] =
#ifdef HAVE_GSSAPI
{ "GSSServiceName", &GSSServiceName, CUPSD_VARTYPE_STRING },
#endif /* HAVE_GSSAPI */
-#if defined(HAVE_ONDEMAND)
+#ifdef HAVE_ONDEMAND
{ "IdleExitTimeout", &IdleExitTimeout, CUPSD_VARTYPE_TIME },
#endif /* HAVE_ONDEMAND */
{ "JobKillDelay", &JobKillDelay, CUPSD_VARTYPE_TIME },
@@ -810,7 +810,7 @@ cupsdReadConfiguration(void)
DefaultLeaseDuration = 86400;
MaxLeaseDuration = 0;
-#if defined(HAVE_ONDEMAND)
+#ifdef HAVE_ONDEMAND
IdleExitTimeout = 60;
#endif /* HAVE_ONDEMAND */
@@ -3149,7 +3149,7 @@ read_cupsd_conf(cups_file_t *fp) /* I - File to read from */
if (lis)
{
-#if defined(HAVE_ONDEMAND)
+#ifdef HAVE_ONDEMAND
if (!lis->on_demand)
#endif /* HAVE_ONDEMAND */
{
diff --git a/scheduler/conf.h b/scheduler/conf.h
index e11f7c6fe..80250d94d 100644
--- a/scheduler/conf.h
+++ b/scheduler/conf.h
@@ -1,7 +1,7 @@
/*
* Configuration file definitions for the CUPS scheduler.
*
- * Copyright 2007-2015 by Apple Inc.
+ * Copyright 2007-2016 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
@@ -244,7 +244,7 @@ VAR char *ServerKeychain VALUE(NULL);
/* Keychain holding cert + key */
#endif /* HAVE_SSL */
-#if defined(HAVE_ONDEMAND)
+#ifdef HAVE_ONDEMAND
VAR int IdleExitTimeout VALUE(60);
/* Time after which an idle cupsd will exit */
#endif /* HAVE_ONDEMAND */
diff --git a/scheduler/cupsd.h b/scheduler/cupsd.h
index 669560c15..ad37bee43 100644
--- a/scheduler/cupsd.h
+++ b/scheduler/cupsd.h
@@ -1,7 +1,7 @@
/*
* Main header file for the CUPS scheduler.
*
- * Copyright 2007-2014 by Apple Inc.
+ * Copyright 2007-2016 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
@@ -157,7 +157,7 @@ VAR int NeedReload VALUE(RELOAD_ALL),
VAR void *DefaultProfile VALUE(0);
/* Default security profile */
-#if defined(HAVE_ONDEMAND)
+#ifdef HAVE_ONDEMAND
VAR int OnDemand VALUE(0);
/* Launched on demand */
#endif /* HAVE_ONDEMAND */
diff --git a/scheduler/listen.c b/scheduler/listen.c
index 7cfe8dbd1..1103b2510 100644
--- a/scheduler/listen.c
+++ b/scheduler/listen.c
@@ -1,7 +1,7 @@
/*
* Server listening routines for the CUPS scheduler.
*
- * Copyright 2007-2014 by Apple Inc.
+ * Copyright 2007-2016 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products, all rights reserved.
*
* These coded instructions, statements, and computer programs are the
@@ -41,7 +41,7 @@ cupsdDeleteAllListeners(void)
for (lis = (cupsd_listener_t *)cupsArrayFirst(Listeners);
lis;
lis = (cupsd_listener_t *)cupsArrayNext(Listeners))
-#if defined(HAVE_ONDEMAND)
+#ifdef HAVE_ONDEMAND
if (!lis->on_demand)
#endif /* HAVE_ONDEMAND */
{
@@ -281,7 +281,7 @@ cupsdStopListening(void)
lis;
lis = (cupsd_listener_t *)cupsArrayNext(Listeners))
{
-#if defined(HAVE_ONDEMAND)
+#ifdef HAVE_ONDEMAND
if (!lis->on_demand && lis->fd != -1)
{
httpAddrClose(&(lis->address), lis->fd);
diff --git a/scheduler/main.c b/scheduler/main.c
index 26417b9c7..0dcd32de0 100644
--- a/scheduler/main.c
+++ b/scheduler/main.c
@@ -29,11 +29,6 @@
#ifdef HAVE_LAUNCH_H
# include <launch.h>
-# include <libgen.h>
-# ifdef HAVE_LAUNCH_ACTIVATE_SOCKET
-/* Update when we have a public header we can include */
-extern int launch_activate_socket(const char *name, int **fds, size_t *cnt);
-# endif /* HAVE_LAUNCH_ACTIVATE_SOCKET */
#endif /* HAVE_LAUNCH_H */
#ifdef HAVE_SYSTEMD
@@ -72,7 +67,7 @@ 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_ONDEMAND)
+#ifdef HAVE_ONDEMAND
static void service_checkin(void);
static void service_checkout(void);
#endif /* HAVE_ONDEMAND */
@@ -755,10 +750,10 @@ main(int argc, /* I - Number of command-line args */
* Shutdown the server...
*/
-#if defined(HAVE_LAUNCHD) || defined(HAVE_SYSTEMD)
+#ifdef HAVE_ONDEMAND
if (OnDemand)
break;
-#endif /* HAVE_LAUNCHD || HAVE_SYSTEMD */
+#endif /* HAVE_ONDEMAND */
DoingShutdown = 1;
@@ -815,7 +810,7 @@ main(int argc, /* I - Number of command-line args */
if ((timeout = select_timeout(fds)) > 1 && LastEvent)
timeout = 1;
-#if defined(HAVE_ONDEMAND)
+#ifdef HAVE_ONDEMAND
/*
* If no other work is scheduled and we're being controlled by
* launchd then timeout after 'LaunchdTimeout' seconds of
@@ -846,7 +841,6 @@ main(int argc, /* I - Number of command-line args */
cupsd_printer_t *p; /* Current printer */
#endif /* HAVE_DNSSD || HAVE_AVAHI */
-
if (errno == EINTR) /* Just interrupted by a signal */
continue;
@@ -931,10 +925,11 @@ main(int argc, /* I - Number of command-line args */
}
#endif /* !__APPLE__ */
-#if defined(HAVE_ONDEMAND)
+#ifdef HAVE_ONDEMAND
/*
- * If no other work was scheduled and we're being controlled by launchd
- * then timeout after 'LaunchdTimeout' seconds of inactivity...
+ * If no other work was scheduled and we're being controlled by launchd,
+ * systemd, or upstart then timeout after 'LaunchdTimeout' seconds of
+ * inactivity...
*/
if (!fds && service_idle_exit)
@@ -1149,7 +1144,7 @@ main(int argc, /* I - Number of command-line args */
cupsdStopServer();
-#if defined(HAVE_ONDEMAND)
+#ifdef HAVE_ONDEMAND
/*
* Update the keep-alive file as needed...
*/
@@ -1828,38 +1823,34 @@ sigterm_handler(int sig) /* I - Signal number */
}
-#if defined(HAVE_ONDEMAND)
-
+#ifdef HAVE_ONDEMAND
/*
- * 'add_ondemand_listener()' - Bind an open fd as a Listener.
+ * 'service_add_listener()' - Bind an open fd as a Listener.
*/
static void
-add_ondemand_listener(int fd, /* I - Socket file descriptor */
- int idx) /* I - Listener number, for logging */
+service_add_listener(int fd, /* I - Socket file descriptor */
+ int idx) /* I - Listener number, for logging */
{
cupsd_listener_t *lis; /* Listeners array */
http_addr_t addr; /* Address variable */
socklen_t addrlen; /* Length of address */
char s[256]; /* String addresss */
+
addrlen = sizeof(addr);
if (getsockname(fd, (struct sockaddr *)&addr, &addrlen))
{
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "service_checkin: Unable to get local address for listener #%d: %s",
- idx + 1, strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR, "service_add_listener: Unable to get local address for listener #%d: %s", idx + 1, strerror(errno));
return;
}
- cupsdLogMessage(CUPSD_LOG_DEBUG,
- "service_checkin: Listener #%d at fd %d, \"%s\".",
- idx + 1, fd, httpAddrString(&addr, s, sizeof(s)));
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "service_add_listener: Listener #%d at fd %d, \"%s\".", idx + 1, fd, httpAddrString(&addr, s, sizeof(s)));
- /*
- * Try to match the on-demand socket address to one of the listeners...
- */
+ /*
+ * Try to match the on-demand socket address to one of the listeners...
+ */
for (lis = (cupsd_listener_t *)cupsArrayFirst(Listeners);
lis;
@@ -1873,19 +1864,15 @@ add_ondemand_listener(int fd, /* I - Socket file descriptor */
if (lis)
{
- cupsdLogMessage(CUPSD_LOG_DEBUG,
- "service_checkin: Matched existing listener #%d to %s.",
- idx + 1, httpAddrString(&(lis->address), s, sizeof(s)));
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "service_add_listener: Matched existing listener #%d to %s.", idx + 1, httpAddrString(&(lis->address), s, sizeof(s)));
}
else
{
- cupsdLogMessage(CUPSD_LOG_DEBUG,
- "service_checkin: Adding new listener #%d for %s.",
- idx + 1, httpAddrString(&addr, s, sizeof(s)));
+ cupsdLogMessage(CUPSD_LOG_DEBUG, "service_add_listener: Adding new listener #%d for %s.", idx + 1, httpAddrString(&addr, s, sizeof(s)));
if ((lis = calloc(1, sizeof(cupsd_listener_t))) == NULL)
{
- cupsdLogMessage(CUPSD_LOG_ERROR, "service_checkin: Unable to allocate listener: %s.", strerror(errno));
+ cupsdLogMessage(CUPSD_LOG_ERROR, "service_add_listener: Unable to allocate listener: %s.", strerror(errno));
exit(EXIT_FAILURE);
return;
}
@@ -1904,6 +1891,7 @@ add_ondemand_listener(int fd, /* I - Socket file descriptor */
# endif /* HAVE_SSL */
}
+
/*
* 'service_checkin()' - Check-in with launchd and collect the listening fds.
*/
@@ -1911,7 +1899,7 @@ add_ondemand_listener(int fd, /* I - Socket file descriptor */
static void
service_checkin(void)
{
-# ifdef HAVE_LAUNCH_ACTIVATE_SOCKET
+# ifdef HAVE_LAUNCHD
int error; /* Check-in error, if any */
size_t i, /* Looping var */
count; /* Number of listeners */
@@ -1938,100 +1926,10 @@ service_checkin(void)
cupsdLogMessage(CUPSD_LOG_DEBUG, "service_checkin: %d listeners.", (int)count);
for (i = 0; i < count; i ++)
- {
- add_ondemand_listener(ld_sockets[i], i);
- }
+ service_add_listener(ld_sockets[i], (int)i);
free(ld_sockets);
-# elif defined(HAVE_LAUNCHD)
- size_t i, /* Looping var */
- count; /* Number of listeners */
- launch_data_t ld_msg, /* Launch data message */
- ld_resp, /* Launch data response */
- ld_array, /* Launch data array */
- ld_sockets, /* Launch data sockets dictionary */
- tmp; /* Launch data */
- int fd; /* File descriptor */
-
-
- cupsdLogMessage(CUPSD_LOG_DEBUG, "service_checkin: pid=%d", (int)getpid());
-
- /*
- * Check-in with launchd...
- */
-
- ld_msg = launch_data_new_string(LAUNCH_KEY_CHECKIN);
- if ((ld_resp = launch_msg(ld_msg)) == NULL)
- {
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "service_checkin: launch_msg(\"" LAUNCH_KEY_CHECKIN
- "\") IPC failure");
- exit(EXIT_FAILURE);
- return; /* anti-compiler-warning */
- }
-
- if (launch_data_get_type(ld_resp) == LAUNCH_DATA_ERRNO)
- {
- errno = launch_data_get_errno(ld_resp);
- cupsdLogMessage(CUPSD_LOG_ERROR, "service_checkin: Check-in failed: %s",
- strerror(errno));
- exit(EXIT_FAILURE);
- return; /* anti-compiler-warning */
- }
-
- /*
- * Get the sockets dictionary...
- */
-
- if ((ld_sockets = launch_data_dict_lookup(ld_resp, LAUNCH_JOBKEY_SOCKETS))
- == NULL)
- {
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "service_checkin: No sockets found to answer requests on.");
- exit(EXIT_FAILURE);
- return; /* anti-compiler-warning */
- }
-
- /*
- * Get the array of listener sockets...
- */
-
- if ((ld_array = launch_data_dict_lookup(ld_sockets, "Listeners")) == NULL)
- {
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "service_checkin: No sockets found to answer requests on.");
- exit(EXIT_FAILURE);
- return; /* anti-compiler-warning */
- }
-
- /*
- * Add listening fd(s) to the Listener array...
- */
-
- if (launch_data_get_type(ld_array) == LAUNCH_DATA_ARRAY)
- {
- count = launch_data_array_get_count(ld_array);
-
- cupsdLogMessage(CUPSD_LOG_DEBUG, "service_checkin: %d listeners.", (int)count);
-
- for (i = 0; i < count; i ++)
- {
- /*
- * Get the launchd file descriptor and address...
- */
-
- if ((tmp = launch_data_array_get_index(ld_array, i)) != NULL)
- {
- fd = launch_data_get_fd(tmp);
- add_ondemand_listener(fd, i);
- }
- }
- }
-
- launch_data_free(ld_msg);
- launch_data_free(ld_resp);
-
# elif defined(HAVE_SYSTEMD)
int i, /* Looping var */
count; /* Number of listeners */
@@ -2057,52 +1955,52 @@ service_checkin(void)
cupsdLogMessage(CUPSD_LOG_DEBUG, "service_checkin: %d listeners.", count);
for (i = 0; i < count; i ++)
- {
- add_ondemand_listener(SD_LISTEN_FDS_START + i, i);
- }
+ service_add_listener(SD_LISTEN_FDS_START + i, i);
+
# elif defined(HAVE_UPSTART)
const char *e; /* Environment var */
int fd; /* File descriptor */
+
if (!(e = getenv("UPSTART_EVENTS")))
{
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "service_checkin: We did not get started via Upstart.");
+ cupsdLogMessage(CUPSD_LOG_ERROR, "service_checkin: We did not get started via Upstart.");
exit(EXIT_FAILURE);
return;
}
if (strcasecmp(e, "socket"))
{
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "service_checkin: We did not get triggered via an Upstart socket event.");
+ cupsdLogMessage(CUPSD_LOG_ERROR, "service_checkin: We did not get triggered via an Upstart socket event.");
exit(EXIT_FAILURE);
return;
}
- if (!(e = getenv("UPSTART_FDS")))
+ if ((e = getenv("UPSTART_FDS")) == NULL)
{
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "service_checkin: Unable to get listener sockets from UPSTART_FDS.");
+ cupsdLogMessage(CUPSD_LOG_ERROR, "service_checkin: Unable to get listener sockets from UPSTART_FDS.");
exit(EXIT_FAILURE);
return;
}
cupsdLogMessage(CUPSD_LOG_DEBUG, "service_checkin: UPSTART_FDS=%s", e);
- fd = strtol(e, NULL, 10);
- if (fd < 0) {
- cupsdLogMessage(CUPSD_LOG_ERROR,
- "service_checkin: Could not parse UPSTART_FDS: %s", strerror(errno));
+ fd = (int)strtol(e, NULL, 10);
+ if (fd < 0)
+ {
+ cupsdLogMessage(CUPSD_LOG_ERROR, "service_checkin: Could not parse UPSTART_FDS: %s", strerror(errno));
exit(EXIT_FAILURE);
return;
}
- /* Upstart only supportst a single on-demand socket fd */
- add_ondemand_listener(fd, 0);
+ /*
+ * Upstart only supportst a single on-demand socket file descriptor...
+ */
+
+ service_add_listener(fd, 0);
# else
-# error "Error: defined HAVE_ONDEMAND but no launchd/systemd/upstart selection"
+# error "Error: defined HAVE_ONDEMAND but no launchd/systemd/upstart selection"
# endif /* HAVE_LAUNCH_ACTIVATE_SOCKET */
}
@@ -2159,7 +2057,9 @@ usage(int status) /* O - Exit status */
_cupsLangPuts(fp, _(" -f Run in the foreground."));
_cupsLangPuts(fp, _(" -F Run in the foreground but detach from console."));
_cupsLangPuts(fp, _(" -h Show this usage message."));
+#ifdef HAVE_ONDEMAND
_cupsLangPuts(fp, _(" -l Run cupsd on demand."));
+#endif /* HAVE_ONDEMAND */
_cupsLangPuts(fp, _(" -s cups-files.conf Set cups-files.conf file to use."));
_cupsLangPuts(fp, _(" -t Test the configuration file."));
diff --git a/vcnet/config.h b/vcnet/config.h
index 2ded18ba2..30c188e13 100644
--- a/vcnet/config.h
+++ b/vcnet/config.h
@@ -534,6 +534,13 @@ typedef unsigned long useconds_t;
/*
+ * Do we have on-demand support (launchd/systemd/upstart)?
+ */
+
+/* #undef HAVE_ONDEMAND */
+
+
+/*
* Do we have launchd support?
*/
@@ -549,6 +556,13 @@ typedef unsigned long useconds_t;
/*
+ * Do we have upstart support?
+ */
+
+/* #undef HAVE_UPSTART */
+
+
+/*
* Various scripting languages...
*/
@@ -784,10 +798,4 @@ 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) || defined(HAVE_UPSTART)
-# define HAVE_ONDEMAND
-#else
-# undef HAVE_ONDEMAND
-#endif
-
#endif /* !_CUPS_CONFIG_H_ */
diff --git a/xcode/config.h b/xcode/config.h
index 8b106cd96..54117ac5a 100644
--- a/xcode/config.h
+++ b/xcode/config.h
@@ -494,12 +494,32 @@
/*
+ * Do we have on-demand support (launchd/systemd/upstart)?
+ */
+
+#define HAVE_ONDEMAND 1
+
+
+/*
* Do we have launchd support?
*/
#define HAVE_LAUNCH_H 1
#define HAVE_LAUNCHD 1
-#define HAVE_LAUNCH_ACTIVATE_SOCKET 1
+
+
+/*
+ * Do we have systemd support?
+ */
+
+/* #undef HAVE_SYSTEMD */
+
+
+/*
+ * Do we have upstart support?
+ */
+
+/* #undef HAVE_UPSTART */
/*
@@ -740,10 +760,4 @@ 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) || defined(HAVE_UPSTART)
-# define HAVE_ONDEMAND
-#else
-# undef HAVE_ONDEMAND
-#endif
-
#endif /* !_CUPS_CONFIG_H_ */