]> err.no Git - systemd/commitdiff
def: centralize definition of default timeout in one place
authorLennart Poettering <lennart@poettering.net>
Thu, 17 Mar 2011 03:02:35 +0000 (04:02 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 17 Mar 2011 03:02:35 +0000 (04:02 +0100)
14 files changed:
Makefile.am
src/cgroup-util.h
src/cryptsetup.c
src/dbus-common.c
src/def.h [new file with mode: 0644]
src/device.c
src/execute.c
src/execute.h
src/main.c
src/mount.c
src/service.c
src/socket.c
src/swap.c
src/unit.h

index 3bac47849e18f70e169148b93934210ab29bffaa..8d2343038ea9a6f8b98cec03c54862a3906fa142 100644 (file)
@@ -501,6 +501,7 @@ EXTRA_DIST += \
        ${libsystemd_core_la_SOURCES:.c=.h} \
        ${libsystemd_daemon_la_SOURCES:.c=.h} \
        src/macro.h \
+        src/def.h \
        src/ioprio.h \
        src/missing.h \
        src/list.h \
index 1eccbc9fd74d73f180ab1e0251035d503eff5760..d142af34bcbf4abf37b2397908257265eefa5392 100644 (file)
@@ -27,8 +27,7 @@
 #include <dirent.h>
 
 #include "set.h"
-
-#define SYSTEMD_CGROUP_CONTROLLER "name=systemd"
+#include "def.h"
 
 int cg_enumerate_processes(const char *controller, const char *path, FILE **_f);
 int cg_enumerate_tasks(const char *controller, const char *path, FILE **_f);
index 989734be1bc44badb3ca130ea14daaece34d1afd..3aa822a1d020591f618e5f6e18b8faab467d65f4 100644 (file)
@@ -31,6 +31,7 @@
 #include "util.h"
 #include "strv.h"
 #include "ask-password-api.h"
+#include "def.h"
 
 static const char *opt_type = NULL; /* LUKS1 or PLAIN */
 static char *opt_cipher = NULL;
@@ -308,7 +309,7 @@ int main(int argc, char *argv[]) {
                 if (opt_readonly)
                         flags |= CRYPT_ACTIVATE_READONLY;
 
-                until = now(CLOCK_MONOTONIC) + (opt_timeout > 0 ? opt_timeout : 60 * USEC_PER_SEC);
+                until = now(CLOCK_MONOTONIC) + (opt_timeout > 0 ? opt_timeout : DEFAULT_TIMEOUT_USEC);
 
                 opt_tries = opt_tries > 0 ? opt_tries : 3;
                 opt_key_size = (opt_key_size > 0 ? opt_key_size : 256);
index bb9cf2e2abfdec0acbc6f354c6456f10b07faafb..e352b8cf996d5475ff9dbf1e096ba9338d1727e3 100644 (file)
@@ -30,6 +30,7 @@
 #include "log.h"
 #include "dbus-common.h"
 #include "util.h"
+#include "def.h"
 
 int bus_check_peercred(DBusConnection *c) {
         int fd;
@@ -57,8 +58,6 @@ int bus_check_peercred(DBusConnection *c) {
         return 1;
 }
 
-#define TIMEOUT_USEC (60*USEC_PER_SEC)
-
 static int sync_auth(DBusConnection *bus, DBusError *error) {
         usec_t begin, tstamp;
 
@@ -71,13 +70,13 @@ static int sync_auth(DBusConnection *bus, DBusError *error) {
         begin = tstamp = now(CLOCK_MONOTONIC);
         for (;;) {
 
-                if (tstamp > begin + TIMEOUT_USEC)
+                if (tstamp > begin + DEFAULT_TIMEOUT_USEC)
                         break;
 
                 if (dbus_connection_get_is_authenticated(bus))
                         break;
 
-                if (!dbus_connection_read_write_dispatch(bus, ((begin + TIMEOUT_USEC - tstamp) + USEC_PER_MSEC - 1) / USEC_PER_MSEC))
+                if (!dbus_connection_read_write_dispatch(bus, ((begin + DEFAULT_TIMEOUT_USEC - tstamp) + USEC_PER_MSEC - 1) / USEC_PER_MSEC))
                         break;
 
                 tstamp = now(CLOCK_MONOTONIC);
diff --git a/src/def.h b/src/def.h
new file mode 100644 (file)
index 0000000..c23cd33
--- /dev/null
+++ b/src/def.h
@@ -0,0 +1,35 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+#ifndef foodefhfoo
+#define foodefhfoo
+
+/***
+  This file is part of systemd.
+
+  Copyright 2010 Lennart Poettering
+
+  systemd is free software; you can redistribute it and/or modify it
+  under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  systemd is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include "util.h"
+
+#define DEFAULT_TIMEOUT_USEC (3*USEC_PER_MINUTE)
+#define DEFAULT_RESTART_USEC (100*USEC_PER_MSEC)
+
+#define SYSTEMD_CGROUP_CONTROLLER "name=systemd"
+
+#define SIGNALS_CRASH_HANDLER SIGSEGV,SIGILL,SIGFPE,SIGBUS,SIGQUIT,SIGABRT
+#define SIGNALS_IGNORE SIGKILL,SIGPIPE
+
+#endif
index ccf2935a91cac4d3d05076c676f3077258c81f8d..41c96cef03f0c2344df2a8302977862275534676 100644 (file)
@@ -29,6 +29,7 @@
 #include "log.h"
 #include "unit-name.h"
 #include "dbus-device.h"
+#include "def.h"
 
 static const UnitActiveState state_translation_table[_DEVICE_STATE_MAX] = {
         [DEVICE_DEAD] = UNIT_INACTIVE,
index 556ff9bda94f4140f768b607dd3616207cba64fe..c1edf61fb1677d1ecbe3a78560595ea755cfd5c9 100644 (file)
@@ -55,6 +55,7 @@
 #include "exit-status.h"
 #include "missing.h"
 #include "utmp-wtmp.h"
+#include "def.h"
 
 /* This assumes there is a 'tty' group */
 #define TTY_MODE 0620
index e77cdcf0bb290a42445614f9e85d9776dbb7093a..755dea35af513cafcfa5b1312c6105ccba12cf53 100644 (file)
@@ -42,10 +42,6 @@ struct CGroupBonding;
 /* Abstract namespace! */
 #define LOGGER_SOCKET "/dev/.run/systemd/logger"
 
-/* This doesn't really belong here, but I couldn't find a better place to put this. */
-#define SIGNALS_CRASH_HANDLER SIGSEGV,SIGILL,SIGFPE,SIGBUS,SIGQUIT,SIGABRT
-#define SIGNALS_IGNORE SIGKILL,SIGPIPE
-
 typedef enum KillMode {
         KILL_CONTROL_GROUP = 0,
         KILL_PROCESS_GROUP,
index 5154b575ffeca60d9419472e40e86e471ef1d3d1..7edd6b5811b145d312ac0f0ced09945e6b72d7cb 100644 (file)
@@ -51,6 +51,7 @@
 #include "label.h"
 #include "build.h"
 #include "strv.h"
+#include "def.h"
 
 static enum {
         ACTION_RUN,
index 00780101a0c1edbced14f97a2ce6c0371416a33f..39525b66509964e12cc8080772434bab1363aaf0 100644 (file)
@@ -37,6 +37,7 @@
 #include "special.h"
 #include "bus-errors.h"
 #include "exit-status.h"
+#include "def.h"
 
 static const UnitActiveState state_translation_table[_MOUNT_STATE_MAX] = {
         [MOUNT_DEAD] = UNIT_INACTIVE,
index e7a9e7c586c15c0f106f0cd4d62c583d983043cd..0f28312b380dc6c549e020fecc43e4aee76fe680 100644 (file)
 #include "special.h"
 #include "bus-errors.h"
 #include "exit-status.h"
-
-#define COMMENTS "#;\n"
-#define NEWLINES "\n\r"
+#include "def.h"
+#include "util.h"
 
 #ifdef HAVE_SYSV_COMPAT
 
-#define DEFAULT_SYSV_TIMEOUT_USEC (3*USEC_PER_MINUTE)
+#define DEFAULT_SYSV_TIMEOUT_USEC (5*USEC_PER_MINUTE)
 
 typedef enum RunlevelType {
         RUNLEVEL_UP,
index 130f51c0789927ded5e5375ede69498a372bcac0..9045a2fc85a3c7c454bcc8ccd4408676bb91236d 100644 (file)
@@ -42,6 +42,7 @@
 #include "bus-errors.h"
 #include "label.h"
 #include "exit-status.h"
+#include "def.h"
 
 static const UnitActiveState state_translation_table[_SOCKET_STATE_MAX] = {
         [SOCKET_DEAD] = UNIT_INACTIVE,
index f59b0fb18d6561d157f1a1d55bfed9f7a4786e4b..035efbaf4b1a941d5cc68adefbd5b3e732a08bc3 100644 (file)
@@ -37,6 +37,7 @@
 #include "special.h"
 #include "bus-errors.h"
 #include "exit-status.h"
+#include "def.h"
 
 static const UnitActiveState state_translation_table[_SWAP_STATE_MAX] = {
         [SWAP_DEAD] = UNIT_INACTIVE,
index 9b7eb5e854ca3c8bc0c59336f7418734e24e2760..4245f3cf1ca7875b6963fd2566169d98d74f3b30 100644 (file)
@@ -40,9 +40,6 @@ typedef enum UnitDependency UnitDependency;
 #include "execute.h"
 #include "condition.h"
 
-#define DEFAULT_TIMEOUT_USEC (3*USEC_PER_MINUTE)
-#define DEFAULT_RESTART_USEC (100*USEC_PER_MSEC)
-
 enum UnitType {
         UNIT_SERVICE = 0,
         UNIT_SOCKET,