[evolution-data-server] Bug 650524 - Use g_unix_signal_add_watch_full() for SIGTERM
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Bug 650524 - Use g_unix_signal_add_watch_full() for SIGTERM
- Date: Sun, 22 May 2011 03:00:49 +0000 (UTC)
commit ea43a7ad48028dda4d67636b660d7cab9c49e988
Author: Matthew Barnes <mbarnes redhat com>
Date: Sat May 21 22:59:58 2011 -0400
Bug 650524 - Use g_unix_signal_add_watch_full() for SIGTERM
We can't call anything safely except write() inside a signal handler,
g_unix_signal_add_watch_full() handles this for us nicely.
addressbook/libedata-book/e-data-book-factory.c | 39 +++++++++++------------
calendar/libedata-cal/e-data-cal-factory.c | 38 ++++++++++------------
2 files changed, 37 insertions(+), 40 deletions(-)
---
diff --git a/addressbook/libedata-book/e-data-book-factory.c b/addressbook/libedata-book/e-data-book-factory.c
index a4776fb..4fc5fae 100644
--- a/addressbook/libedata-book/e-data-book-factory.c
+++ b/addressbook/libedata-book/e-data-book-factory.c
@@ -24,8 +24,14 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <glib-object.h>
#include <glib/gi18n.h>
+
+#ifdef G_OS_UNIX
+#if GLIB_CHECK_VERSION(2,29,5)
+#include <glib-unix.h>
+#endif
+#endif
+
#include <libebackend/e-data-server-module.h>
#include <libebackend/e-offline-listener.h>
#include "e-book-backend-factory.h"
@@ -576,29 +582,18 @@ on_name_lost (GDBusConnection *connection,
g_mutex_unlock (factory->priv->connections_lock);
}
-#ifndef G_OS_WIN32
-static void
-term_signal (gint sig)
+#ifdef G_OS_UNIX
+#if GLIB_CHECK_VERSION(2,29,5)
+static gboolean
+handle_term_signal (gpointer data)
{
- g_return_if_fail (sig == SIGTERM);
-
g_print ("Received terminate signal...\n");
g_main_loop_quit (loop);
-}
-
-static void
-setup_term_signal (void)
-{
- struct sigaction sa, osa;
- sigaction (SIGTERM, NULL, &osa);
-
- sa.sa_flags = 0;
- sigemptyset (&sa.sa_mask);
- sa.sa_handler = term_signal;
- sigaction (SIGTERM, &sa, NULL);
+ return FALSE;
}
#endif
+#endif
static GOptionEntry entries[] = {
@@ -677,8 +672,12 @@ main (gint argc, gchar **argv)
/* Migrate user data from ~/.evolution to XDG base directories. */
e_data_book_migrate_basedir ();
-#ifndef G_OS_WIN32
- setup_term_signal ();
+#ifdef G_OS_UNIX
+#if GLIB_CHECK_VERSION(2,29,5)
+ g_unix_signal_add_watch_full (
+ SIGTERM, G_PRIORITY_DEFAULT,
+ handle_term_signal, NULL, NULL);
+#endif
#endif
g_print ("Server is up and running...\n");
diff --git a/calendar/libedata-cal/e-data-cal-factory.c b/calendar/libedata-cal/e-data-cal-factory.c
index 7e4bbda..38e1e68 100644
--- a/calendar/libedata-cal/e-data-cal-factory.c
+++ b/calendar/libedata-cal/e-data-cal-factory.c
@@ -29,7 +29,12 @@
#include <string.h>
#include <unistd.h>
#include <glib/gi18n.h>
-#include <glib-object.h>
+
+#ifdef G_OS_UNIX
+#if GLIB_CHECK_VERSION(2,29,5)
+#include <glib-unix.h>
+#endif
+#endif
#include "libedataserver/e-url.h"
#include "libedataserver/e-source.h"
@@ -893,29 +898,18 @@ on_name_lost (GDBusConnection *connection,
}
}
-#ifndef G_OS_WIN32
-static void
-term_signal (gint sig)
+#ifdef G_OS_UNIX
+#if GLIB_CHECK_VERSION(2,29,5)
+static gboolean
+handle_term_signal (gpointer data)
{
- g_return_if_fail (sig == SIGTERM);
-
g_print ("Received terminate signal...\n");
g_main_loop_quit (loop);
-}
-static void
-setup_term_signal (void)
-{
- struct sigaction sa, osa;
-
- sigaction (SIGTERM, NULL, &osa);
-
- sa.sa_flags = 0;
- sigemptyset (&sa.sa_mask);
- sa.sa_handler = term_signal;
- sigaction (SIGTERM, &sa, NULL);
+ return FALSE;
}
#endif
+#endif
static GOptionEntry entries[] = {
@@ -1002,8 +996,12 @@ main (gint argc, gchar **argv)
/* Migrate user data from ~/.evolution to XDG base directories. */
e_data_cal_migrate_basedir ();
-#ifndef G_OS_WIN32
- setup_term_signal ();
+#ifdef G_OS_UNIX
+#if GLIB_CHECK_VERSION(2,29,5)
+ g_unix_signal_add_watch_full (
+ SIGTERM, G_PRIORITY_DEFAULT,
+ handle_term_signal, NULL, NULL);
+#endif
#endif
g_print ("Server is up and running...\n");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]