From 6ddf97a3f0cda0ca1704b5b069004ce279e1a4d0 Mon Sep 17 00:00:00 2001 From: Jae-young Date: Tue, 28 May 2013 16:52:58 +0900 Subject: [PATCH] Add patch for reboot delay issue Because of some processes are not closed when received signal In order to solve that, timout_usec separate up timeout_start_usec and timeout_stop_usec and add config_parse_service_timeout function Change-Id: I584e0cc7c34a214dbb05e6a44af4fedf25751dbe Signed-off-by: Jae-young Hwang --- packaging/reboot-delay.patch | 199 +++++++++++++++++++++++++++++++++++++++++++ packaging/systemd.spec | 2 + 2 files changed, 201 insertions(+) create mode 100644 packaging/reboot-delay.patch diff --git a/packaging/reboot-delay.patch b/packaging/reboot-delay.patch new file mode 100644 index 0000000..9ac8351 --- /dev/null +++ b/packaging/reboot-delay.patch @@ -0,0 +1,199 @@ +diff --git a/Makefile.am b/Makefile.am +index 9762da1..76e5355 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -472,10 +472,12 @@ libsystemd_basic_la_SOURCES = \ + + libsystemd_basic_la_CFLAGS = \ + $(AM_CFLAGS) \ ++ $(DBUS_CFLAGS) \ + $(SELINUX_CFLAGS) + + libsystemd_basic_la_LIBADD = \ + $(SELINUX_LIBS) \ ++ $(DBUS_LIBS) \ + $(CAP_LIBS) + + libsystemd_core_la_SOURCES = \ +diff --git a/src/conf-parser.c b/src/conf-parser.c +index c7dd01a..44268d1 100644 +--- a/src/conf-parser.c ++++ b/src/conf-parser.c +@@ -30,6 +30,7 @@ + #include "macro.h" + #include "strv.h" + #include "log.h" ++#include "service.h" + + int config_item_table_lookup( + void *table, +@@ -775,6 +776,41 @@ int config_parse_usec( + return 0; + } + ++int config_parse_service_timeout( ++ const char *filename, ++ unsigned line, ++ const char *section, ++ const char *lvalue, ++ int ltype, ++ const char *rvalue, ++ void *data, ++ void *userdata) { ++ ++ Service *s = userdata; ++ ++ usec_t usec; ++ ++ assert(filename); ++ assert(lvalue); ++ assert(rvalue); ++ assert(data); ++ ++ if (parse_usec(rvalue, &usec) < 0) { ++ log_error("[%s:%u] Failed to parse time value, ignoring: %s", filename, line, rvalue); ++ return 0; ++ } ++ ++ if (streq(lvalue, "TimeoutStartSec")) { ++ s->timeout_start_usec = usec; ++ } else if (streq(lvalue, "TimeoutStopSec")) { ++ s->timeout_stop_usec = usec; ++ } else { ++ s->timeout_start_usec = usec; ++ s->timeout_stop_usec = usec; ++ } ++ return 0; ++} ++ + int config_parse_mode( + const char *filename, + unsigned line, +diff --git a/src/conf-parser.h b/src/conf-parser.h +index be7d708..1221fd4 100644 +--- a/src/conf-parser.h ++++ b/src/conf-parser.h +@@ -102,6 +102,7 @@ int config_parse_path(const char *filename, unsigned line, const char *section, + int config_parse_strv(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); + int config_parse_path_strv(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); + int config_parse_usec(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); ++int config_parse_service_timeout(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); + int config_parse_mode(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); + + #define DEFINE_CONFIG_PARSE_ENUM(function,name,type,msg) \ +diff --git a/src/dbus-service.c b/src/dbus-service.c +index 7809164..ebb3d04 100644 +--- a/src/dbus-service.c ++++ b/src/dbus-service.c +@@ -125,6 +125,8 @@ static const BusProperty bus_service_properties[] = { + { "RestartUSec", bus_property_append_usec, "t", offsetof(Service, restart_usec) }, + { "TimeoutUSec", bus_property_append_usec, "t", offsetof(Service, timeout_usec) }, + { "WatchdogUSec", bus_property_append_usec, "t", offsetof(Service, watchdog_usec) }, ++ { "TimeoutStartUSec", bus_property_append_usec, "t", offsetof(Service, timeout_start_usec) }, ++ { "TimeoutStopUSec", bus_property_append_usec, "t", offsetof(Service, timeout_stop_usec) }, + { "WatchdogTimestamp", bus_property_append_usec, "t", offsetof(Service, watchdog_timestamp.realtime) }, + { "WatchdogTimestampMonotonic",bus_property_append_usec, "t", offsetof(Service, watchdog_timestamp.monotonic) }, + { "StartLimitInterval", bus_property_append_usec, "t", offsetof(Service, start_limit.interval) }, +diff --git a/src/def.h b/src/def.h +index 20aaa7c..92c5771 100644 +--- a/src/def.h ++++ b/src/def.h +@@ -25,6 +25,8 @@ + #include "util.h" + + #define DEFAULT_TIMEOUT_USEC (90*USEC_PER_SEC) ++#define DEFAULT_TIMEOUT_START_USEC (90*USEC_PER_SEC) ++#define DEFAULT_TIMEOUT_STOP_USEC (5*USEC_PER_SEC) + #define DEFAULT_RESTART_USEC (100*USEC_PER_MSEC) + + #define DEFAULT_EXIT_USEC (5*USEC_PER_MINUTE) +diff --git a/src/load-fragment-gperf.gperf.m4 b/src/load-fragment-gperf.gperf.m4 +index 44ce4bb..d7f1621 100644 +--- a/src/load-fragment-gperf.gperf.m4 ++++ b/src/load-fragment-gperf.gperf.m4 +@@ -134,7 +134,9 @@ Service.ExecReload, config_parse_exec, SERVICE_EXE + Service.ExecStop, config_parse_exec, SERVICE_EXEC_STOP, offsetof(Service, exec_command) + Service.ExecStopPost, config_parse_exec, SERVICE_EXEC_STOP_POST, offsetof(Service, exec_command) + Service.RestartSec, config_parse_usec, 0, offsetof(Service, restart_usec) +-Service.TimeoutSec, config_parse_usec, 0, offsetof(Service, timeout_usec) ++Service.TimeoutSec, config_parse_service_timeout, 0, 0 ++Service.TimeoutStartSec, config_parse_service_timeout, 0, 0 ++Service.TimeoutStopSec, config_parse_service_timeout, 0, 0 + Service.WatchdogSec, config_parse_usec, 0, offsetof(Service, watchdog_usec) + Service.StartLimitInterval, config_parse_usec, 0, offsetof(Service, start_limit.interval) + Service.StartLimitBurst, config_parse_unsigned, 0, offsetof(Service, start_limit.burst) +diff --git a/src/service.c b/src/service.c +index ec2725a..018f31d 100644 +--- a/src/service.c ++++ b/src/service.c +@@ -112,7 +112,9 @@ static void service_init(Unit *u) { + assert(u); + assert(u->load_state == UNIT_STUB); + +- s->timeout_usec = DEFAULT_TIMEOUT_USEC; ++ s->timeout_usec = DEFAULT_TIMEOUT_START_USEC; /* only needed for dbus property */ ++ s->timeout_start_usec = DEFAULT_TIMEOUT_START_USEC; ++ s->timeout_stop_usec = DEFAULT_TIMEOUT_STOP_USEC; + s->restart_usec = DEFAULT_RESTART_USEC; + + s->watchdog_watch.type = WATCH_INVALID; +@@ -887,9 +889,9 @@ static int service_load_sysv_path(Service *s, const char *path) { + UNIT(s)->default_dependencies = false; + + /* Don't timeout special services during boot (like fsck) */ +- s->timeout_usec = 0; ++ s->timeout_start_usec = 0; + } else +- s->timeout_usec = DEFAULT_SYSV_TIMEOUT_USEC; ++ s->timeout_start_usec = DEFAULT_SYSV_TIMEOUT_USEC; + + /* Special setting for all SysV services */ + s->type = SERVICE_FORKING; +@@ -1565,10 +1567,10 @@ static int service_coldplug(Unit *u) { + s->deserialized_state == SERVICE_FINAL_SIGKILL || + s->deserialized_state == SERVICE_AUTO_RESTART) { + +- if (s->deserialized_state == SERVICE_AUTO_RESTART || s->timeout_usec > 0) { ++ if (s->deserialized_state == SERVICE_AUTO_RESTART || s->timeout_start_usec > 0) { + usec_t k; + +- k = s->deserialized_state == SERVICE_AUTO_RESTART ? s->restart_usec : s->timeout_usec; ++ 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) + return r; +@@ -1713,8 +1715,8 @@ static int service_spawn( + } + } + +- if (timeout && s->timeout_usec) { +- if ((r = unit_watch_timer(UNIT(s), s->timeout_usec, &s->timer_watch)) < 0) ++ if (timeout && s->timeout_start_usec) { ++ if ((r = unit_watch_timer(UNIT(s), s->timeout_start_usec, &s->timer_watch)) < 0) + goto fail; + } else + unit_unwatch_timer(UNIT(s), &s->timer_watch); +@@ -1963,8 +1965,8 @@ static void service_enter_signal(Service *s, ServiceState state, ServiceResult f + } + + if (wait_for_exit) { +- if (s->timeout_usec > 0) +- if ((r = unit_watch_timer(UNIT(s), s->timeout_usec, &s->timer_watch)) < 0) ++ if (s->timeout_stop_usec > 0) ++ if ((r = unit_watch_timer(UNIT(s), s->timeout_stop_usec, &s->timer_watch)) < 0) + goto fail; + + service_set_state(s, state); +diff --git a/src/service.h b/src/service.h +index 60b1051..e10d9aa 100644 +--- a/src/service.h ++++ b/src/service.h +@@ -120,6 +120,8 @@ struct Service { + + usec_t restart_usec; + usec_t timeout_usec; ++ usec_t timeout_start_usec; ++ usec_t timeout_stop_usec; + + dual_timestamp watchdog_timestamp; + usec_t watchdog_usec; diff --git a/packaging/systemd.spec b/packaging/systemd.spec index cccc324..13d36f3 100644 --- a/packaging/systemd.spec +++ b/packaging/systemd.spec @@ -24,6 +24,7 @@ Patch11: SMACK-Add-configuration-options.-v3.patch Patch12: reboot_syscall_param.patch Patch13: default_oom_score.patch Patch14: fix-syscall-NR_fanotify_mark-on-arm.patch +Patch15: reboot-delay.patch BuildRequires: pkgconfig(dbus-1) >= 1.4.0 BuildRequires: pkgconfig(dbus-glib-1) @@ -180,6 +181,7 @@ This package includes the man pages for systemd. %patch12 -p1 %patch13 -p1 %patch14 -p1 +%patch15 -p1 %build cp %{SOURCE1001} . -- 2.7.4