chiark / gitweb /
service: drop the per-distro ifdefs in service.c
[elogind.git] / src / core / service.c
index 34d24ffa92b54ea1eb843809d200df7a26aea9de..3ab05508472ce90ec6c455ecc3e200a580bae3d2 100644 (file)
@@ -249,7 +249,7 @@ static void service_handle_watchdog(Service *s) {
                 return;
         }
 
-        r = unit_watch_timer(UNIT(s), s->watchdog_usec - offset, &s->watchdog_watch);
+        r = unit_watch_timer(UNIT(s), CLOCK_MONOTONIC, true, s->watchdog_usec - offset, &s->watchdog_watch);
         if (r < 0)
                 log_warning("%s failed to install watchdog timer: %s", UNIT(s)->id, strerror(-r));
 }
@@ -321,16 +321,12 @@ static char *sysv_translate_name(const char *name) {
         if (!(r = new(char, strlen(name) + sizeof(".service"))))
                 return NULL;
 
-#if defined(TARGET_DEBIAN) || defined(TARGET_UBUNTU) || defined(TARGET_ANGSTROM)
         if (endswith(name, ".sh"))
                 /* Drop Debian-style .sh suffix */
                 strcpy(stpcpy(r, name) - 3, ".service");
-#endif
-#ifdef TARGET_FRUGALWARE
         if (startswith(name, "rc."))
                 /* Drop Frugalware-style rc. prefix */
                 strcpy(stpcpy(r, name + 3), ".service");
-#endif
         else
                 /* Normal init scripts */
                 strcpy(stpcpy(r, name), ".service");
@@ -349,14 +345,11 @@ static int sysv_translate_facility(const char *name, const char *filename, char
         static const char * const table[] = {
                 /* LSB defined facilities */
                 "local_fs",             SPECIAL_LOCAL_FS_TARGET,
-#if defined(TARGET_MANDRIVA) || defined(TARGET_MAGEIA)
-#else
                 /* Due to unfortunate name selection in Mandriva,
                  * $network is provided by network-up which is ordered
                  * after network which actually starts interfaces.
                  * To break the loop, just ignore it */
                 "network",              SPECIAL_NETWORK_TARGET,
-#endif
                 "named",                SPECIAL_NSS_LOOKUP_TARGET,
                 "portmap",              SPECIAL_RPCBIND_TARGET,
                 "remote_fs",            SPECIAL_REMOTE_FS_TARGET,
@@ -367,14 +360,8 @@ static int sysv_translate_facility(const char *name, const char *filename, char
                 "mail-transfer-agent",  SPECIAL_MAIL_TRANSFER_AGENT_TARGET,
                 "x-display-manager",    SPECIAL_DISPLAY_MANAGER_SERVICE,
                 "null",                 NULL,
-
-#if defined(TARGET_DEBIAN) || defined(TARGET_UBUNTU) || defined(TARGET_ANGSTROM)
                 "mail-transport-agent", SPECIAL_MAIL_TRANSFER_AGENT_TARGET,
-#endif
-
-#ifdef TARGET_SUSE
                 "smtp",                 SPECIAL_MAIL_TRANSFER_AGENT_TARGET,
-#endif
         };
 
         unsigned i;
@@ -990,15 +977,9 @@ static int service_load_sysv_name(Service *s, const char *name) {
 
         /* For SysV services we strip the rc.* and *.sh
          * prefixes/suffixes. */
-#if defined(TARGET_DEBIAN) || defined(TARGET_UBUNTU) || defined(TARGET_ANGSTROM)
         if (endswith(name, ".sh.service"))
                 return -ENOENT;
-#endif
-
-#ifdef TARGET_FRUGALWARE
         if (startswith(name, "rc."))
-                return -ENOENT;
-#endif
 
         STRV_FOREACH(p, UNIT(s)->manager->lookup_paths.sysvinit_path) {
                 char *path;
@@ -1013,16 +994,13 @@ static int service_load_sysv_name(Service *s, const char *name) {
 
                 r = service_load_sysv_path(s, path);
 
-#if defined(TARGET_DEBIAN) || defined(TARGET_UBUNTU) || defined(TARGET_ANGSTROM)
                 if (r >= 0 && UNIT(s)->load_state == UNIT_STUB) {
                         /* Try Debian style *.sh source'able init scripts */
                         strcat(path, ".sh");
                         r = service_load_sysv_path(s, path);
                 }
-#endif
                 free(path);
 
-#ifdef TARGET_FRUGALWARE
                 if (r >= 0 && UNIT(s)->load_state == UNIT_STUB) {
                         /* Try Frugalware style rc.* init scripts */
 
@@ -1035,12 +1013,11 @@ static int service_load_sysv_name(Service *s, const char *name) {
                         r = service_load_sysv_path(s, path);
                         free(path);
                 }
-#endif
 
                 if (r < 0)
                         return r;
 
-                if ((UNIT(s)->load_state != UNIT_STUB))
+                if (UNIT(s)->load_state != UNIT_STUB)
                         break;
         }
 
@@ -1599,7 +1576,8 @@ static int service_coldplug(Unit *u) {
 
                                 k = s->deserialized_state == SERVICE_AUTO_RESTART ? s->restart_usec : s->timeout_start_usec;
 
-                                if ((r = unit_watch_timer(UNIT(s), k, &s->timer_watch)) < 0)
+                                r = unit_watch_timer(UNIT(s), CLOCK_MONOTONIC, true, k, &s->timer_watch);
+                                if (r < 0)
                                         return r;
                         }
                 }
@@ -1744,7 +1722,7 @@ static int service_spawn(
         }
 
         if (timeout && s->timeout_start_usec) {
-                r = unit_watch_timer(UNIT(s), s->timeout_start_usec, &s->timer_watch);
+                r = unit_watch_timer(UNIT(s), CLOCK_MONOTONIC, true, s->timeout_start_usec, &s->timer_watch);
                 if (r < 0)
                         goto fail;
         } else
@@ -1899,7 +1877,7 @@ static void service_enter_dead(Service *s, ServiceResult f, bool allow_restart)
              !set_contains(s->restart_ignore_status.signal, INT_TO_PTR(s->main_exec_status.status)))
                 ) {
 
-                r = unit_watch_timer(UNIT(s), s->restart_usec, &s->timer_watch);
+                r = unit_watch_timer(UNIT(s), CLOCK_MONOTONIC, true, s->restart_usec, &s->timer_watch);
                 if (r < 0)
                         goto fail;
 
@@ -2012,7 +1990,7 @@ static void service_enter_signal(Service *s, ServiceState state, ServiceResult f
 
         if (wait_for_exit) {
                 if (s->timeout_stop_usec > 0) {
-                        r = unit_watch_timer(UNIT(s), s->timeout_stop_usec, &s->timer_watch);
+                        r = unit_watch_timer(UNIT(s), CLOCK_MONOTONIC, true, s->timeout_stop_usec, &s->timer_watch);
                         if (r < 0)
                                 goto fail;
                 }
@@ -2262,7 +2240,7 @@ static void service_enter_restart(Service *s) {
                 /* Don't restart things if we are going down anyway */
                 log_info("Stop job pending for unit, delaying automatic restart.");
 
-                r = unit_watch_timer(UNIT(s), s->restart_usec, &s->timer_watch);
+                r = unit_watch_timer(UNIT(s), CLOCK_MONOTONIC, true, s->restart_usec, &s->timer_watch);
                 if (r < 0)
                         goto fail;