pidgin: e4b22781: Tell gstreamer not to fork; remove the S...

resiak at soc.pidgin.im resiak at soc.pidgin.im
Thu Mar 6 06:35:56 EST 2008


-----------------------------------------------------------------
Revision: e4b22781fe6c2a7cd1133ee36a308ede967be25e
Ancestor: ff681557cdc4d70719004cd04f9f7a68f6f33b3f
Author: resiak at soc.pidgin.im
Date: 2008-03-06T11:34:11
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/e4b22781fe6c2a7cd1133ee36a308ede967be25e

Modified files:
        configure.ac pidgin/gtkmain.c pidgin/gtksound.c

ChangeLog: 

Tell gstreamer not to fork; remove the SIGCHLD -> SIGALRM hack, which made
Pidgin unrunnable on non-Linux platforms.  This involves depending on gstreamer
>= 0.10.10, which has been around since 2006-09-14.  This isn't a problem,
right?

Fixes #1496.

-------------- next part --------------
============================================================
--- configure.ac	ddd05208a75f0ac1fcf45102f3bd5312ac876c75
+++ configure.ac	eff4eb1ce4eea274ce57bf7c6e9ab87fe73aa55b
@@ -662,7 +662,7 @@ if test "x$enable_gst" != "xno"; then
 	[AC_HELP_STRING([--disable-gstreamer], [compile without GStreamer audio support])],
 	enable_gst="$enableval", enable_gst="yes")
 if test "x$enable_gst" != "xno"; then
-	PKG_CHECK_MODULES(GSTREAMER, [gstreamer-0.10], [
+	PKG_CHECK_MODULES(GSTREAMER, [gstreamer-0.10 >= 0.10.10], [
 		AC_DEFINE(USE_GSTREAMER, 1, [Use GStreamer for playing sounds])
 		AC_SUBST(GSTREAMER_CFLAGS)
 		AC_SUBST(GSTREAMER_LIBS)
============================================================
--- pidgin/gtkmain.c	b30a878c499894cc82f3a610608548fc6d83e342
+++ pidgin/gtkmain.c	84c6d474edfca274f1a6b7900674454bc93858bc
@@ -99,7 +99,6 @@ static const int catch_sig_list[] = {
 	SIGTERM,
 	SIGQUIT,
 	SIGCHLD,
-	SIGALRM,
 	-1
 };
 
@@ -140,38 +139,11 @@ static void sighandler(int sig);
 #ifdef HAVE_SIGNAL_H
 static void sighandler(int sig);
 
-/**
- * Reap all our dead children.  Sometimes libpurple forks off a separate
- * process to do some stuff.  When that process exits we are
- * informed about it so that we can call waitpid() and let it
- * stop being a zombie.
- *
- * We used to do this immediately when our signal handler was
- * called, but because of GStreamer we now wait one second before
- * reaping anything.  Why?  For some reason GStreamer fork()s
- * during their initialization process.  I don't understand why...
- * but they do it, and there's nothing we can do about it.
- *
- * Anyway, so then GStreamer waits for its child to die and then
- * it continues with the initialization process.  This means that
- * we have a race condition where GStreamer is waitpid()ing for its
- * child to die and we're catching the SIGCHLD signal.  If GStreamer
- * is awarded the zombied process then everything is ok.  But if libpurple
- * reaps the zombie process then the GStreamer initialization sequence
- * fails.
- *
- * So the ugly solution is to wait a second to give GStreamer time to
- * reap that bad boy.
- *
- * GStreamer 0.10.10 and newer have a gst_register_fork_set_enabled()
- * function that can be called by applications to disable forking
- * during initialization.  But it's not in 0.10.0, so we shouldn't
- * use it.
- *
- * All of this child process reaping stuff is currently only used for
- * processes that were forked to play sounds.  It's not needed for
- * forked DNS child, which have their own waitpid() call.  It might
- * be wise to move this code into gtksound.c.
+/*
+ * This child process reaping stuff is currently only used for processes that
+ * were forked to play sounds.  It's not needed for forked DNS child, which
+ * have their own waitpid() call.  It might be wise to move this code into
+ * gtksound.c.
  */
 static void
 clean_pid(void)
@@ -188,9 +160,6 @@ clean_pid(void)
 		snprintf(errmsg, BUFSIZ, "Warning: waitpid() returned %d", pid);
 		perror(errmsg);
 	}
-
-	/* Restore signal catching */
-	signal(SIGALRM, sighandler);
 }
 
 char *segfault_message;
@@ -220,12 +189,8 @@ sighandler(int sig)
 		abort();
 		break;
 	case SIGCHLD:
-		/* Restore signal catching */
-		signal(SIGCHLD, sighandler);
-		alarm(1);
-		break;
-	case SIGALRM:
 		clean_pid();
+		signal(SIGCHLD, sighandler);    /* restore signal catching on this one! */
 		break;
 	default:
 		purple_debug_warning("sighandler", "Caught signal %d\n", sig);
============================================================
--- pidgin/gtksound.c	8bfca8ea29f98a356366c4371a9d05074e0f13cd
+++ pidgin/gtksound.c	dfc2a2429ae9e08398e5b65bb84d049d5d7f5f8e
@@ -302,6 +302,7 @@ pidgin_sound_init(void)
 
 #ifdef USE_GSTREAMER
 	purple_debug_info("sound", "Initializing sound output drivers.\n");
+	gst_registry_fork_set_enabled (FALSE);
 	if ((gst_init_failed = !gst_init_check(NULL, NULL, &error))) {
 		purple_notify_error(NULL, _("GStreamer Failure"),
 					_("GStreamer failed to initialize."),


More information about the Commits mailing list