gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r9824 - Extractor/src/main


From: gnunet
Subject: [GNUnet-SVN] r9824 - Extractor/src/main
Date: Sun, 20 Dec 2009 03:01:48 +0100

Author: grothoff
Date: 2009-12-20 03:01:48 +0100 (Sun, 20 Dec 2009)
New Revision: 9824

Modified:
   Extractor/src/main/extract.c
   Extractor/src/main/extractor.c
Log:
fixes

Modified: Extractor/src/main/extract.c
===================================================================
--- Extractor/src/main/extract.c        2009-12-20 02:00:59 UTC (rev 9823)
+++ Extractor/src/main/extract.c        2009-12-20 02:01:48 UTC (rev 9824)
@@ -22,6 +22,8 @@
 #include "extractor.h"
 #include "getopt.h"
 
+#include <signal.h>
+
 #define YES 1
 #define NO 0
 
@@ -42,6 +44,34 @@
 static int in_process;
 
 
+static void
+catcher (int sig)
+{
+}
+
+/**
+ * Install a signal handler to ignore SIGPIPE.
+ */
+static void
+ignore_sigpipe ()
+{
+  struct sigaction oldsig;
+  struct sigaction sig;
+
+  sig.sa_handler = &catcher;
+  sigemptyset (&sig.sa_mask);
+#ifdef SA_INTERRUPT
+  sig.sa_flags = SA_INTERRUPT;  /* SunOS */
+#else
+  sig.sa_flags = SA_RESTART;
+#endif
+  if (0 != sigaction (SIGPIPE, &sig, &oldsig))
+    fprintf (stderr,
+             "Failed to install SIGPIPE handler: %s\n", strerror (errno));
+}
+
+
+
 typedef struct {
   char shortArg;
   char * longArg;
@@ -536,6 +566,7 @@
   setlocale(LC_ALL, "");
   textdomain(PACKAGE);
 #endif
+  ignore_sigpipe ();
   print = malloc (sizeof (int) * EXTRACTOR_metatype_get_max ());
   for (i = 0; i < EXTRACTOR_metatype_get_max (); i++)
     print[i] = YES;            /* default: print everything */

Modified: Extractor/src/main/extractor.c
===================================================================
--- Extractor/src/main/extractor.c      2009-12-20 02:00:59 UTC (rev 9823)
+++ Extractor/src/main/extractor.c      2009-12-20 02:01:48 UTC (rev 9824)
@@ -44,7 +44,11 @@
  */
 #define MAX_MIME_LEN 256
 
-#define DEBUG 0
+/**
+ * Set to 1 to get failure info,
+ * 2 for actual debug info.
+ */ 
+#define DEBUG 1
 
 
 #if HAVE_LTDL_H
@@ -535,7 +539,7 @@
       dot = strstr (sym, ".");
       if (dot != NULL)
        *dot = '\0';
-#if DEBUG
+#if DEBUG > 1
       fprintf (stderr,
               "Adding default plugin `%s'\n",
               sym);
@@ -859,6 +863,12 @@
 {
   int status;
 
+#if DEBUG
+  if (plugin->cpid == -1)
+    fprintf (stderr,
+            "Plugin `%s' choked on this input\n",
+            plugin->short_libname);
+#endif
   if ( (plugin->cpid == -1) ||
        (plugin->cpid == 0) )
     return;
@@ -1067,6 +1077,11 @@
     {
       close (in);
       close (out);
+#if DEBUG
+      fprintf (stderr,
+              "Plugin `%s' failed to load!\n",
+              plugin->short_libname);
+#endif
       return;
     }  
   memset (&hdr, 0, sizeof (hdr));
@@ -1140,6 +1155,8 @@
       close (p1[1]);
       close (p2[0]);
       process_requests (plugin, p1[0], p2[1]);
+      fprintf (stderr,
+              "Plugin done with requests!\n");
       _exit (0);
     }
   plugin->cpid = pid;
@@ -1189,6 +1206,8 @@
                         &hdr,
                         sizeof(hdr)))
        {
+         stop_process (plugin);
+         plugin->cpid = -1;
          if (plugin->flags != EXTRACTOR_OPTION_AUTO_RESTART)
            plugin->flags = EXTRACTOR_OPTION_DISABLED;
          return 0;
@@ -1200,7 +1219,8 @@
        break;
       if (hdr.mime_len > MAX_MIME_LEN)
        {
-         stop_process (plugin);
+         stop_process (plugin);          
+         plugin->cpid = -1;
          if (plugin->flags != EXTRACTOR_OPTION_AUTO_RESTART)
            plugin->flags = EXTRACTOR_OPTION_DISABLED;
          return 0;
@@ -1219,6 +1239,7 @@
                            hdr.data_len))) )
        {
          stop_process (plugin);
+         plugin->cpid = -1;
          free (data);
          if (plugin->flags != EXTRACTOR_OPTION_AUTO_RESTART)
            plugin->flags = EXTRACTOR_OPTION_DISABLED;
@@ -1312,6 +1333,8 @@
          memcpy (ptr, data, size);
        }
     }
+  else
+    shmid = -1;
   if (want_shm && (shmid == -1))
     _exit(1);
   ppos = plugins;





reply via email to

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