gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r30932 - in gnunet/src: include util


From: gnunet
Subject: [GNUnet-SVN] r30932 - in gnunet/src: include util
Date: Thu, 28 Nov 2013 14:00:55 +0100

Author: harsha
Date: 2013-11-28 14:00:55 +0100 (Thu, 28 Nov 2013)
New Revision: 30932

Modified:
   gnunet/src/include/gnunet_signal_lib.h
   gnunet/src/util/os_priority.c
   gnunet/src/util/signal.c
Log:
- raise a signal after receiving it from the control pipe by calling the 
respective callback registered with GNUNET_SIGNAL_handler_install().


Modified: gnunet/src/include/gnunet_signal_lib.h
===================================================================
--- gnunet/src/include/gnunet_signal_lib.h      2013-11-28 11:35:48 UTC (rev 
30931)
+++ gnunet/src/include/gnunet_signal_lib.h      2013-11-28 13:00:55 UTC (rev 
30932)
@@ -72,6 +72,17 @@
 GNUNET_SIGNAL_handler_uninstall (struct GNUNET_SIGNAL_Context *ctx);
 
 
+/**
+ * Raise the given signal by calling the installed signal handlers.  This will
+ * not use the @em raise() system call but only calls the handlers registered
+ * through GNUNET_SIGNAL_handler_install().
+ *
+ * @param sig the signal to raise
+ */
+void
+GNUNET_SIGNAL_raise (const int sig);
+
+
 #if 0                           /* keep Emacsens' auto-indent happy */
 {
 #endif

Modified: gnunet/src/util/os_priority.c
===================================================================
--- gnunet/src/util/os_priority.c       2013-11-28 11:35:48 UTC (rev 30931)
+++ gnunet/src/util/os_priority.c       2013-11-28 13:00:55 UTC (rev 30932)
@@ -107,7 +107,7 @@
   GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
                                  control_pipe, &parent_control_handler,
                                  control_pipe);
-  raise ((int) sig);
+  GNUNET_SIGNAL_raise ((int) sig);
 }
 
 

Modified: gnunet/src/util/signal.c
===================================================================
--- gnunet/src/util/signal.c    2013-11-28 11:35:48 UTC (rev 30931)
+++ gnunet/src/util/signal.c    2013-11-28 13:00:55 UTC (rev 30932)
@@ -32,6 +32,11 @@
 
 struct GNUNET_SIGNAL_Context
 {
+
+  struct GNUNET_SIGNAL_Context *next;
+
+  struct GNUNET_SIGNAL_Context *prev;
+
   int sig;
 
   GNUNET_SIGNAL_Handler method;
@@ -41,6 +46,11 @@
 #endif
 };
 
+static struct GNUNET_SIGNAL_Context *sc_head;
+
+static struct GNUNET_SIGNAL_Context *sc_tail;
+
+
 #ifdef WINDOWS
 GNUNET_SIGNAL_Handler w32_sigchld_handler = NULL;
 #endif
@@ -81,6 +91,7 @@
     }
   }
 #endif
+  GNUNET_CONTAINER_DLL_insert_tail (sc_head, sc_tail, ret);
   return ret;
 }
 
@@ -93,5 +104,29 @@
   sigemptyset (&sig.sa_mask);
   sigaction (ctx->sig, &ctx->oldsig, &sig);
 #endif
+  GNUNET_CONTAINER_DLL_remove (sc_head, sc_tail, ctx);
   GNUNET_free (ctx);
 }
+
+
+/**
+ * Raise the given signal by calling the installed signal handlers.  This will
+ * not use the @em raise() system call but only calls the handlers registered
+ * through GNUNET_SIGNAL_handler_install().
+ *
+ * @param sig the signal to raise
+ */
+void
+GNUNET_SIGNAL_raise (const int sig)
+{
+  struct GNUNET_SIGNAL_Context *ctx;
+  
+  for (ctx = sc_head; NULL != sc_head; ctx = ctx->next)
+  {
+    if (sig != ctx->sig)
+      continue;
+    if (NULL == ctx->method)
+      continue;
+    ctx->method ();
+  }
+}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]