gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r23092 - Extractor/src/main
Date: Sat, 4 Aug 2012 03:21:15 +0200

Author: grothoff
Date: 2012-08-04 03:21:15 +0200 (Sat, 04 Aug 2012)
New Revision: 23092

Modified:
   Extractor/src/main/TODO
   Extractor/src/main/extractor_datasource.c
   Extractor/src/main/test_extractor.c
   Extractor/src/main/test_gzip.c
Log:
fixes

Modified: Extractor/src/main/TODO
===================================================================
--- Extractor/src/main/TODO     2012-08-04 01:08:35 UTC (rev 23091)
+++ Extractor/src/main/TODO     2012-08-04 01:21:15 UTC (rev 23092)
@@ -4,3 +4,6 @@
 
 * MAX_META_DATA buffer of 32 MB is a bit big as a non-growing default size;
   also, valgrind reports it is leaked even though printf-debugging shows it is 
not (!?)
+
+* for some reason, if a plugin crashes or something goes wrong (i.e. with a 
seek),
+  the whole system hangs (not good...)

Modified: Extractor/src/main/extractor_datasource.c
===================================================================
--- Extractor/src/main/extractor_datasource.c   2012-08-04 01:08:35 UTC (rev 
23091)
+++ Extractor/src/main/extractor_datasource.c   2012-08-04 01:21:15 UTC (rev 
23092)
@@ -326,7 +326,10 @@
        }
       if (bfds->fpos + bfds->buffer_pos + pos > bfds->fsize)
        {
-         LOG ("Invalid seek operation\n");
+         LOG ("Invalid seek operation to %lld from %llu (max is %llu)\n",
+              (long long) pos,
+              bfds->fpos + bfds->buffer_pos,
+              (unsigned long long) bfds->fsize);
          return -1;
        }
       if ( (NULL == bfds->buffer) ||
@@ -537,11 +540,16 @@
   unsigned int gzip_header_length = 10;
   unsigned char hdata[12];
 
+  if (0 != bfds_seek (cfs->bfds, 0, SEEK_SET))
+    {
+      LOG ("Failed to seek to offset 0!\n");
+      return -1;
+    }
   /* Process gzip header */  
   if (sizeof (hdata) > bfds_read (cfs->bfds, hdata, sizeof (hdata)))
     return -1;
   if (0 != (hdata[3] & 0x4)) /* FEXTRA  set */
-    gzip_header_length += 2 + (hdata[10] & 0xff) + ((hdata[11] & 0xff) * 256);
+    gzip_header_length += 2 + (hdata[10] & 0xff) + ((hdata[11] & 0xff) * 256); 
   
 
   if (0 != (hdata[3] & 0x8)) 
     {
@@ -819,7 +827,7 @@
       if ( (Z_OK != ret) && (Z_STREAM_END != ret) )
        return -1; /* unexpected error */
       /* go backwards by the number of bytes left in the buffer */
-      if (-1 == bfds_seek (cfs->bfds, - cfs->strm.avail_in, SEEK_CUR))
+      if (-1 == bfds_seek (cfs->bfds, - (int64_t) cfs->strm.avail_in, 
SEEK_CUR))
        return -1;
       /* copy decompressed bytes to target buffer */
       in = cfs->strm.total_out;

Modified: Extractor/src/main/test_extractor.c
===================================================================
--- Extractor/src/main/test_extractor.c 2012-08-04 01:08:35 UTC (rev 23091)
+++ Extractor/src/main/test_extractor.c 2012-08-04 01:21:15 UTC (rev 23092)
@@ -61,7 +61,8 @@
       fprintf (stderr, "Unexpected data at offset 0\n");
       abort (); 
     }
-  if (1024 * 150 != ec->get_size (ec->cls))
+  if ( (1024 * 150 != ec->get_size (ec->cls)) &&
+       (UINT64_MAX != ec->get_size (ec->cls)) )
     {
       fprintf (stderr, "Unexpected file size returned (expected 150k)\n");
       abort (); 

Modified: Extractor/src/main/test_gzip.c
===================================================================
--- Extractor/src/main/test_gzip.c      2012-08-04 01:08:35 UTC (rev 23091)
+++ Extractor/src/main/test_gzip.c      2012-08-04 01:21:15 UTC (rev 23092)
@@ -63,10 +63,14 @@
       ret = 3;
       return 1;
     }
+  if (0 == strcmp (plugin_name,
+                  "<zlib>"))
+    return 0; /* skip this one */
   if (0 != strcmp (plugin_name,
                   "test"))
     {
-      fprintf (stderr, "plugin name invalid\n");
+      fprintf (stderr, "plugin name invalid: `%s'\n",
+              plugin_name);
       ret = 4;
       return 1;
     }




reply via email to

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