changeset 2222:4de6e7d138c6 trunk

[svn] - make SIGTERM work in a threadsafe manner.
author nenolod
date Fri, 29 Dec 2006 19:51:55 -0800
parents e7ecc79293c8
children e0d7335f56c3
files ChangeLog audacious/main.c audacious/main.h audacious/signals.c
diffstat 4 files changed, 31 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Dec 29 14:33:09 2006 -0800
+++ b/ChangeLog	Fri Dec 29 19:51:55 2006 -0800
@@ -1,3 +1,11 @@
+2006-12-29 22:33:09 +0000  Giacomo Lozito <james@develia.org>
+  revision [3447]
+  - deletion of the last playlist is now handled directly in playlist_remove_playlist (patch by Joker) ; small code changes in playlist manager
+  trunk/audacious/playlist.c         |   10 ++++++++++
+  trunk/audacious/playlist_manager.c |   26 +++++++++++++-------------
+  2 files changed, 23 insertions(+), 13 deletions(-)
+
+
 2006-12-29 17:59:21 +0000  Yoshiki Yazawa <yaz@cc.rim.or.jp>
   revision [3445]
   - fix a typo that kustodian pointed out. (probably it's mine.)
--- a/audacious/main.c	Fri Dec 29 14:33:09 2006 -0800
+++ b/audacious/main.c	Fri Dec 29 19:51:55 2006 -0800
@@ -211,6 +211,7 @@
     FALSE,			/* use XMMS-style file selection */
     TRUE,                       /* use extension probing         */
     255, 255, 255,		/* colorize r, g, b */
+    FALSE,			/* internal: whether or not to terminate */
 };
 
 typedef struct bmp_cfg_boolent_t {
--- a/audacious/main.h	Fri Dec 29 14:33:09 2006 -0800
+++ b/audacious/main.h	Fri Dec 29 19:51:55 2006 -0800
@@ -130,6 +130,7 @@
     gboolean use_xmms_style_fileselector;
     gboolean use_extension_probing;
     gint colorize_r; gint colorize_g; gint colorize_b;
+    gboolean terminate;
 };
 
 typedef struct _BmpConfig BmpConfig;
--- a/audacious/signals.c	Fri Dec 29 14:33:09 2006 -0800
+++ b/audacious/signals.c	Fri Dec 29 19:51:55 2006 -0800
@@ -29,6 +29,8 @@
 #include <sys/types.h>
 #include <signal.h>
 
+#include "main.h"
+#include "mainwin.h"
 #include "signals.h"
 
 typedef void (*SignalHandler) (gint);
@@ -98,7 +100,20 @@
 static void
 sigterm_handler (gint signal_number)
 {
-    mainwin_quit_cb();
+    cfg.terminate = TRUE;
+}
+
+static gboolean
+signal_process_events (gpointer data)
+{
+    if (cfg.terminate == TRUE)
+    {
+        g_message("Audacious has received SIGTERM and is shutting down.");
+        mainwin_quit_cb();
+        return FALSE;
+    }
+
+    return TRUE;
 }
 
 void 
@@ -107,12 +122,14 @@
     char *magic;
     magic = getenv("AUD_ENSURE_BACKTRACE");
 
-    signal_install_handler (SIGPIPE, signal_empty_handler);
-    signal_install_handler (SIGINT, sigterm_handler);
-    signal_install_handler (SIGTERM, sigterm_handler);
+    signal_install_handler(SIGPIPE, signal_empty_handler);
+    signal_install_handler(SIGINT, sigterm_handler);
+    signal_install_handler(SIGTERM, sigterm_handler);
 
     /* in particular environment (maybe with glibc 2.5), core file
        through signal handler doesn't contain useful back trace. --yaz */
     if (magic == NULL)
         signal_install_handler(SIGSEGV, sigsegv_handler);
+
+    g_timeout_add(100, signal_process_events, NULL);
 }