gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r10182 - gnunet/src/fs


From: gnunet
Subject: [GNUnet-SVN] r10182 - gnunet/src/fs
Date: Mon, 1 Feb 2010 14:02:01 +0100

Author: grothoff
Date: 2010-02-01 14:02:01 +0100 (Mon, 01 Feb 2010)
New Revision: 10182

Modified:
   gnunet/src/fs/fs_download.c
   gnunet/src/fs/gnunet-service-fs.c
   gnunet/src/fs/test_fs_download.c
Log:
die nicely

Modified: gnunet/src/fs/fs_download.c
===================================================================
--- gnunet/src/fs/fs_download.c 2010-02-01 12:32:23 UTC (rev 10181)
+++ gnunet/src/fs/fs_download.c 2010-02-01 13:02:01 UTC (rev 10182)
@@ -627,8 +627,7 @@
 
 
 /**
- * Reconnect to the FS service and transmit
- * our queries NOW.
+ * Reconnect to the FS service and transmit our queries NOW.
  *
  * @param cls our download context
  * @param tc unused

Modified: gnunet/src/fs/gnunet-service-fs.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs.c   2010-02-01 12:32:23 UTC (rev 10181)
+++ gnunet/src/fs/gnunet-service-fs.c   2010-02-01 13:02:01 UTC (rev 10182)
@@ -46,6 +46,8 @@
 #include "gnunet-service-fs_indexing.h"
 #include "fs.h"
 
+#define DEBUG_FS GNUNET_YES
+
 /**
  * Maximum number of outgoing messages we queue per peer.
  * FIXME: set to a tiny value for testing; make configurable.
@@ -53,7 +55,6 @@
 #define MAX_QUEUE_PER_PEER 2
 
 
-
 /**
  * Maximum number of requests (from other peers) that we're
  * willing to have pending at any given point in time.
@@ -1661,7 +1662,11 @@
   size_t msize;
   uint32_t prio;
 
-  
+#if DEBUG_FS
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Matched result for query `%s' with pending request\n",
+             GNUNET_h2s (key));
+#endif  
   GNUNET_CRYPTO_hash (prq->data,
                      prq->size,
                      &chash);
@@ -1717,6 +1722,11 @@
   pr->remaining_priority = 0;
   if (pr->client_request_list != NULL)
     {
+#if DEBUG_FS
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "Transmitting result for query `%s' to local client\n",
+                 GNUNET_h2s (key));
+#endif  
       cl = pr->client_request_list->client_list;
       msize = sizeof (struct PutMessage) + prq->size;
       creply = GNUNET_malloc (msize + sizeof (struct ClientResponseMessage));
@@ -1743,6 +1753,12 @@
   else
     {
       cp = pr->pht_entry->cp;
+#if DEBUG_FS
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "Transmitting result for query `%s' to other peer (PID=%u)\n",
+                 GNUNET_h2s (key),
+                 (unsigned int) cp->pid);
+#endif  
       msize = sizeof (struct ContentMessage) + prq->size;
       reply = GNUNET_malloc (msize + sizeof (struct PendingMessage));
       reply->cont = &transmit_reply_continuation;
@@ -1834,6 +1850,12 @@
       return GNUNET_SYSERR;
     }
 
+#if DEBUG_FS
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Received result for query `%s' from peer `%4s'\n",
+             GNUNET_h2s (&query),
+             GNUNET_i2s (other));
+#endif
   /* now, lookup 'query' */
   prq.data = (const void*) &put[1];
   prq.size = dsize;
@@ -1921,11 +1943,16 @@
     {      
 #if DEBUG_FS
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-                 "Result from datastore filtered by bloomfilter.\n");
+                 "Result from datastore filtered by bloomfilter 
(duplicate).\n");
 #endif
       GNUNET_FS_drq_get_next (GNUNET_YES);
       return;
     }
+#if DEBUG_FS
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Found result for query `%s' in local datastore\n",
+             GNUNET_h2s (key));
+#endif
   pr->results_found++;
   if ( (pr->type == GNUNET_DATASTORE_BLOCKTYPE_KBLOCK) ||
        (pr->type == GNUNET_DATASTORE_BLOCKTYPE_SBLOCK) ||
@@ -2104,6 +2131,13 @@
       return GNUNET_OK;
     }
 
+#if DEBUG_FS
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Received request for `%s' of type %u from peer `%4s'\n",
+             GNUNET_h2s (&gm->query),
+             (unsigned int) ntohl (gm->type),
+             GNUNET_i2s (other));
+#endif
   pr = GNUNET_malloc (sizeof (struct PendingRequest) + 
                      (bm & 
GET_MESSAGE_BIT_SKS_NAMESPACE)?sizeof(GNUNET_HashCode):0);
   if ((bm & GET_MESSAGE_BIT_SKS_NAMESPACE))
@@ -2259,7 +2293,12 @@
       client_list = cl;
     }
   type = ntohl (sm->type);
-
+#if DEBUG_FS
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Received request for `%s' of type %u from local client\n",
+             GNUNET_h2s (&sm->query),
+             (unsigned int) type);
+#endif
   /* FIXME: detect duplicate request; if duplicate, simply update (merge)
      'pr->replies_seen'! */
   pr = GNUNET_malloc (sizeof (struct PendingRequest) + 

Modified: gnunet/src/fs/test_fs_download.c
===================================================================
--- gnunet/src/fs/test_fs_download.c    2010-02-01 12:32:23 UTC (rev 10181)
+++ gnunet/src/fs/test_fs_download.c    2010-02-01 13:02:01 UTC (rev 10182)
@@ -68,15 +68,39 @@
 
 static struct GNUNET_FS_PublishContext *publish;
 
+static GNUNET_SCHEDULER_TaskIdentifier timeout_kill;
+
 static char *fn;
 
+static int err;
 
 static void
+timeout_kill_task (void *cls,
+                  const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+  if (publish != NULL)
+    {
+      GNUNET_FS_publish_stop (publish);
+      publish = NULL;
+    }
+  if (download != NULL)
+    {
+      GNUNET_FS_download_stop (download, GNUNET_YES);
+      download = NULL;
+    }
+  timeout_kill = GNUNET_SCHEDULER_NO_TASK;
+  err = 1;
+}
+
+static void
 abort_publish_task (void *cls,
                     const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
-  GNUNET_FS_publish_stop (publish);
-  publish = NULL;
+  if (publish != NULL)
+    {
+      GNUNET_FS_publish_stop (publish);
+      publish = NULL;
+    }
 }
 
 
@@ -86,13 +110,18 @@
 {
   uint64_t size;
   
-  GNUNET_FS_download_stop (download, GNUNET_YES);
-  download = NULL;
+  if (download != NULL)
+    {
+      GNUNET_FS_download_stop (download, GNUNET_YES);
+      download = NULL;
+    }
   GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_size (fn, &size, GNUNET_YES));
   GNUNET_assert (size == FILESIZE); 
   GNUNET_DISK_directory_remove (fn);
   GNUNET_free (fn);
   fn = NULL;
+  GNUNET_SCHEDULER_cancel (sched, timeout_kill);
+  timeout_kill = GNUNET_SCHEDULER_NO_TASK;
 }
 
 
@@ -132,10 +161,9 @@
     case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED:
       printf ("Download complete,  %llu kbps.\n",
              (unsigned long long) (FILESIZE * 1000 / 
(1+GNUNET_TIME_absolute_get_duration (start).value) / 1024));
-      GNUNET_SCHEDULER_add_continuation (sched,
-                                        &abort_download_task,
-                                        NULL,
-                                        GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+      GNUNET_SCHEDULER_add_now (sched,
+                               &abort_download_task,
+                               NULL);
       break;
     case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS:
       GNUNET_assert (download == event->value.download.dc);
@@ -161,10 +189,9 @@
       fprintf (stderr,
               "Error downloading file: %s\n",
               event->value.download.specifics.error.message);
-      GNUNET_SCHEDULER_add_continuation (sched,
-                                        &abort_download_task,
-                                        NULL,
-                                        GNUNET_SCHEDULER_REASON_PREREQ_DONE);
+      GNUNET_SCHEDULER_add_now (sched,
+                               &abort_download_task,
+                               NULL);
       break;
     case GNUNET_FS_STATUS_PUBLISH_START:
       GNUNET_assert (0 == strcmp ("publish-context", 
event->value.publish.cctx));
@@ -282,6 +309,10 @@
   GNUNET_FS_uri_destroy (kuri);
   GNUNET_CONTAINER_meta_data_destroy (meta);
   GNUNET_assert (NULL != fi);
+  timeout_kill = GNUNET_SCHEDULER_add_delayed (sched,
+                                              TIMEOUT,
+                                              &timeout_kill_task,
+                                              NULL);
   start = GNUNET_TIME_absolute_get ();
   publish = GNUNET_FS_publish_start (fs,
                                    fi,
@@ -319,7 +350,7 @@
                      "nohelp", options, &run, NULL);
   stop_arm (&p1);
   GNUNET_DISK_directory_remove ("/tmp/gnunet-test-fs-download/");
-  return 0;
+  return err;
 }
 
 /* end of test_fs_download.c */





reply via email to

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