gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r9205 - gnunet/src/fs
Date: Mon, 19 Oct 2009 09:34:53 -0600

Author: grothoff
Date: 2009-10-19 09:34:53 -0600 (Mon, 19 Oct 2009)
New Revision: 9205

Modified:
   gnunet/src/fs/fs_download.c
   gnunet/src/fs/gnunet-service-fs.c
   gnunet/src/fs/test_fs_download_data.conf
Log:
debug code and fixes

Modified: gnunet/src/fs/fs_download.c
===================================================================
--- gnunet/src/fs/fs_download.c 2009-10-19 14:07:56 UTC (rev 9204)
+++ gnunet/src/fs/fs_download.c 2009-10-19 15:34:53 UTC (rev 9205)
@@ -302,8 +302,15 @@
   struct ContentHashKey *chk;
   char *emsg;
 
+
   GNUNET_CRYPTO_hash (data, size, &query);
-  sm = GNUNET_CONTAINER_multihashmap_get (dc->active,
+#if DEBUG_DOWNLOAD
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Received result for query `%s' from `%s'-service\n",
+             GNUNET_h2s (&query),
+             "FS");
+#endif
+ sm = GNUNET_CONTAINER_multihashmap_get (dc->active,
                                          &query);
   if (NULL == sm)
     {
@@ -315,6 +322,10 @@
                                    sm->offset,
                                    sm->depth))
     {
+#if DEBUG_DOWNLOAD
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Internal error or bogus download URI\n");
+#endif
       dc->emsg = GNUNET_strdup ("Internal error or bogus download URI");
       /* signal error */
       pi.status = GNUNET_FS_STATUS_DOWNLOAD_ERROR;
@@ -347,6 +358,11 @@
                                 sm->depth,
                                 dc->treedepth);
       emsg = NULL;
+#if DEBUG_DOWNLOAD
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "Saving decrypted block to disk at offset %llu\n",
+                 (unsigned long long) off);
+#endif
       if ( (off  != 
            GNUNET_DISK_file_seek (dc->handle,
                                   off,
@@ -415,6 +431,11 @@
   GNUNET_assert (dc->completed <= dc->length);
   if (dc->completed == dc->length)
     {
+#if DEBUG_DOWNLOAD
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "Download completed, truncating file to desired length 
%llu\n",
+                 (unsigned long long) GNUNET_ntohll 
(dc->uri->data.chk.file_length));
+#endif
       /* truncate file to size (since we store IBlocks at the end) */
       if (dc->handle != NULL)
        {
@@ -436,6 +457,11 @@
   // FIXME: make persistent
   if (sm->depth == dc->treedepth) 
     return;
+#if DEBUG_DOWNLOAD
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Triggering downloads of children (this block was at level %u)\n",
+             dc->treedepth);
+#endif
   GNUNET_assert (0 == (size % sizeof(struct ContentHashKey)));
   chk = (struct ContentHashKey*) pt;
   for (i=0;i<(size / sizeof(struct ContentHashKey));i++)
@@ -519,9 +545,15 @@
   GNUNET_assert (size >= sizeof (struct SearchMessage));
   msize = 0;
   sm = buf;
-  while ( (dc->pending == NULL) &&
+  while ( (dc->pending != NULL) &&
          (size > msize + sizeof (struct SearchMessage)) )
     {
+#if DEBUG_DOWNLOAD
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "Transmitting download request for `%s' to `%s'-service\n",
+                 GNUNET_h2s (&dc->pending->chk.query),
+                 "FS");
+#endif
       memset (sm, 0, sizeof (struct SearchMessage));
       sm->header.size = htons (sizeof (struct SearchMessage));
       sm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_START_SEARCH);
@@ -557,6 +589,9 @@
                                  dc->h->cfg);
   if (NULL == client)
     {
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                 "Connecting to `%s'-service failed, will try again.\n",
+                 "FS");
       try_reconnect (dc);
       return;
     }
@@ -574,8 +609,7 @@
 
 
 /**
- * Add entries that are not yet pending back to
- * the pending list.
+ * Add entries that are not yet pending back to the pending list.
  *
  * @param cls our download context
  * @param key unused

Modified: gnunet/src/fs/gnunet-service-fs.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs.c   2009-10-19 14:07:56 UTC (rev 9204)
+++ gnunet/src/fs/gnunet-service-fs.c   2009-10-19 15:34:53 UTC (rev 9205)
@@ -1312,6 +1312,10 @@
 
   if (NULL == buf)
     {
+#if DEBUG_FS
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "Failed to transmit result to local client, aborting 
datastore iteration.\n");
+#endif
       /* error, abort! */
       GNUNET_free (lgc->result);
       lgc->result = NULL;
@@ -1319,6 +1323,11 @@
       return 0;
     }
   msize = ntohs (lgc->result->header.size);
+#if DEBUG_FS
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Transmitting %u bytes of result to local client.\n",
+             msize);
+#endif
   GNUNET_assert (max >= msize);
   memcpy (buf, lgc->result, msize);
   GNUNET_free (lgc->result);
@@ -1895,6 +1904,11 @@
 
   if (key == NULL)
     {
+#if DEBUG_FS
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "Received last result for `%s' from local datastore, deciding 
what to do next.\n",
+                 GNUNET_h2s (&lgc->query));
+#endif
       /* no further results from datastore; continue
         processing further requests from the client and
         allow the next task to use the datastore; also,
@@ -1907,6 +1921,11 @@
           (lgc->type == GNUNET_DATASTORE_BLOCKTYPE_SBLOCK) ||
           (lgc->type == GNUNET_DATASTORE_BLOCKTYPE_SKBLOCK) )
        {
+#if DEBUG_FS
+         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                     "Forwarding query for `%s' to network.\n",
+                     GNUNET_h2s (&lgc->query));
+#endif
          cl = clients;
          while ( (NULL != cl) &&
                  (cl->client != lgc->client) )
@@ -1960,11 +1979,21 @@
          return;
        }
       /* got all possible results, clean up! */
+#if DEBUG_FS
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "Found all possible results for query for `%s', done!\n",
+                 GNUNET_h2s (&lgc->query));
+#endif
       local_get_context_free (lgc);
       return;
     }
   if (type == GNUNET_DATASTORE_BLOCKTYPE_ONDEMAND)
     {
+#if DEBUG_FS
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "Received on-demand block for `%s' from local datastore, 
fetching data.\n",
+                 GNUNET_h2s (&lgc->query));
+#endif
       handle_on_demand_block (key, size, data, type, priority, 
                              anonymity, expiration, uid,
                              &process_local_get_result,
@@ -1977,6 +2006,11 @@
         query hash being identical to KBLOCK/SBLOCK query hash);
         nevertheless, if it happens, the correct thing is to
         simply skip the result. */
+#if DEBUG_FS
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "Received block of unexpected type for `%s' from local 
datastore, ignoring.\n",
+                 GNUNET_h2s (&lgc->query));
+#endif
       GNUNET_DATASTORE_get_next (dsh, GNUNET_YES);       
       return;
     }
@@ -1987,6 +2021,11 @@
                     &lgc->results[i],
                     sizeof (GNUNET_HashCode)))
       {
+#if DEBUG_FS
+       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                   "Received duplicate result for `%s' from local datastore, 
ignoring.\n",
+                   GNUNET_h2s (&lgc->query));
+#endif
        GNUNET_DATASTORE_get_next (dsh, GNUNET_YES);
        return; 
       }
@@ -2007,6 +2046,11 @@
   memcpy (&lgc->result[1],
          data,
          size);
+#if DEBUG_FS
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+             "Received new result for `%s' from local datastore, passing to 
client.\n",
+             GNUNET_h2s (&lgc->query));
+#endif
   GNUNET_SERVER_notify_transmit_ready (lgc->client,
                                       msize,
                                       GNUNET_TIME_UNIT_FOREVER_REL,

Modified: gnunet/src/fs/test_fs_download_data.conf
===================================================================
--- gnunet/src/fs/test_fs_download_data.conf    2009-10-19 14:07:56 UTC (rev 
9204)
+++ gnunet/src/fs/test_fs_download_data.conf    2009-10-19 15:34:53 UTC (rev 
9205)
@@ -36,6 +36,7 @@
 [fs]
 PORT = 42471
 HOSTNAME = localhost
+DEBUG = YES
 
 [testing]
 WEAKRANDOM = YES





reply via email to

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