summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2006-12-20 06:18:19 +0000
committerRay Strode <rstrode@redhat.com>2006-12-20 06:18:19 +0000
commit5d77d1503e61339a971b099b8a4d24ffc502045b (patch)
tree05df7521b31ca52d05826e6229833ecf5379866c
parent3ec4b0f0238f65ed253644a1953cef9e351a3f71 (diff)
2006-12-19 Ray Strode <rstrode@redhat.com>
* bus/bus.c (process_config_every_time): don't overwrite existing bus context activation object until after we've checked that the new activation is valid. * bus/main.c (signal_handler), (handle_reload_watch): don't call exit() on failure, instead make do and keep going. (close_reload_pipe): new function to turn off hangup-causes-config-reload behavior if an unexpected error occurs
-rw-r--r--ChangeLog15
-rw-r--r--bus/bus.c18
-rw-r--r--bus/main.c36
3 files changed, 53 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 7a4ce8b2..f92a5734 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2006-12-19 Ray Strode <rstrode@redhat.com>
+
+ * bus/bus.c (process_config_every_time):
+ don't overwrite existing bus context activation object
+ until after we've checked that the new activation is
+ valid.
+
+ * bus/main.c
+ (signal_handler), (handle_reload_watch):
+ don't call exit() on failure, instead make do and keep
+ going.
+ (close_reload_pipe): new function to turn off
+ hangup-causes-config-reload behavior if an unexpected
+ error occurs
+
2006-12-13 Ralf Habacker <ralf.habacker@freenet.de>
* dbus/dbus-sysdeps-win-thread.c (_dbus_condvar_wait_win32):
diff --git a/bus/bus.c b/bus/bus.c
index 562eb983..26f91adb 100644
--- a/bus/bus.c
+++ b/bus/bus.c
@@ -402,6 +402,7 @@ process_config_every_time (BusContext *context,
{
DBusString full_address;
DBusList *link;
+ BusActivation *new_activation;
char *addr;
dbus_bool_t retval;
@@ -467,19 +468,20 @@ process_config_every_time (BusContext *context,
}
/* Create activation subsystem */
-
- if (is_reload)
- bus_activation_unref (context->activation);
-
- context->activation = bus_activation_new (context, &full_address,
- bus_config_parser_get_service_dirs (parser),
- error);
- if (context->activation == NULL)
+ new_activation = bus_activation_new (context, &full_address,
+ bus_config_parser_get_service_dirs (parser),
+ error);
+ if (new_activation == NULL)
{
_DBUS_ASSERT_ERROR_IS_SET (error);
goto failed;
}
+ if (is_reload)
+ bus_activation_unref (context->activation);
+
+ context->activation = new_activation;
+
/* Drop existing conf-dir watches (if applicable) */
if (is_reload)
diff --git a/bus/main.c b/bus/main.c
index 39bc24f8..0caa2979 100644
--- a/bus/main.c
+++ b/bus/main.c
@@ -37,6 +37,7 @@ static int reload_pipe[2];
#define RELOAD_READ_END 0
#define RELOAD_WRITE_END 1
+static void close_reload_pipe (void);
static void
signal_handler (int sig)
@@ -51,11 +52,12 @@ signal_handler (int sig)
#endif /* DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX */
case SIGHUP:
_dbus_string_init_const (&str, "foo");
- if (!_dbus_write_socket (reload_pipe[RELOAD_WRITE_END], &str, 0, 1))
- {
- _dbus_warn ("Unable to write to reload pipe.\n");
- exit (1);
- }
+ if ((reload_pipe[RELOAD_WRITE_END] > 0) &&
+ !_dbus_write_socket (reload_pipe[RELOAD_WRITE_END], &str, 0, 1))
+ {
+ _dbus_warn ("Unable to write to reload pipe.\n");
+ close_reload_pipe ();
+ }
break;
case SIGTERM:
@@ -150,20 +152,28 @@ handle_reload_watch (DBusWatch *watch,
DBusError error;
DBusString str;
_dbus_string_init (&str);
- if (_dbus_read_socket (reload_pipe[RELOAD_READ_END], &str, 1) != 1)
+ if ((reload_pipe[RELOAD_READ_END] > 0) &&
+ _dbus_read_socket (reload_pipe[RELOAD_READ_END], &str, 1) != 1)
{
_dbus_warn ("Couldn't read from reload pipe.\n");
- exit (1);
+ close_reload_pipe ();
+ return TRUE;
}
_dbus_string_free (&str);
+ /* this can only fail if we don't understand the config file
+ * or OOM. Either way we should just stick with the currently
+ * loaded config.
+ */
dbus_error_init (&error);
if (! bus_context_reload_config (context, &error))
{
+ _DBUS_ASSERT_ERROR_IS_SET (&error);
+ _dbus_assert (dbus_error_has_name (&error, DBUS_ERROR_FAILED) ||
+ dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY));
_dbus_warn ("Unable to reload configuration: %s\n",
error.message);
dbus_error_free (&error);
- exit (1);
}
return TRUE;
}
@@ -219,6 +229,16 @@ setup_reload_pipe (DBusLoop *loop)
}
+static void
+close_reload_pipe (void)
+{
+ _dbus_close_socket (reload_pipe[RELOAD_READ_END], NULL);
+ reload_pipe[RELOAD_READ_END] = -1;
+
+ _dbus_close_socket (reload_pipe[RELOAD_WRITE_END], NULL);
+ reload_pipe[RELOAD_WRITE_END] = -1;
+}
+
int
main (int argc, char **argv)
{