gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r1670 - in GNUnet/src/applications: fs/ecrs fs/fsui fs/lib


From: grothoff
Subject: [GNUnet-SVN] r1670 - in GNUnet/src/applications: fs/ecrs fs/fsui fs/lib fs/module gap sqstore_sqlite
Date: Sun, 14 Aug 2005 18:30:36 -0700 (PDT)

Author: grothoff
Date: 2005-08-14 18:30:32 -0700 (Sun, 14 Aug 2005)
New Revision: 1670

Modified:
   GNUnet/src/applications/fs/ecrs/download.c
   GNUnet/src/applications/fs/ecrs/keyspace.c
   GNUnet/src/applications/fs/ecrs/search.c
   GNUnet/src/applications/fs/ecrs/upload.c
   GNUnet/src/applications/fs/fsui/check.conf
   GNUnet/src/applications/fs/fsui/download.c
   GNUnet/src/applications/fs/fsui/downloadtest.c
   GNUnet/src/applications/fs/fsui/file_info.c
   GNUnet/src/applications/fs/fsui/fsui.c
   GNUnet/src/applications/fs/fsui/search.c
   GNUnet/src/applications/fs/lib/fslib.c
   GNUnet/src/applications/fs/module/fs.c
   GNUnet/src/applications/fs/module/ondemand.c
   GNUnet/src/applications/fs/module/querymanager.c
   GNUnet/src/applications/gap/gap.c
   GNUnet/src/applications/sqstore_sqlite/sqlite.c
Log:
bugfix

Modified: GNUnet/src/applications/fs/ecrs/download.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/download.c  2005-08-14 23:40:07 UTC (rev 
1669)
+++ GNUnet/src/applications/fs/ecrs/download.c  2005-08-15 01:30:32 UTC (rev 
1670)
@@ -31,6 +31,8 @@
 #include "ecrs.h"
 #include "tree.h"
 
+#define DEBUG_DOWNLOAD NO
+
 /**
  * Highest TTL allowed? (equivalent of 25-50 HOPS distance!)
  */
@@ -116,7 +118,7 @@
       fn[strlen(fn)-1]+=i;
       if (0 != UNLINK(fn))
        LOG(LOG_WARNING,
-           "Could not unlink temporary file %s: %s\n",
+           _("Could not unlink temporary file '%s': %s\n"),
            fn, STRERROR(errno));
       FREE(fn);
     }
@@ -244,10 +246,11 @@
              len);
   if (ret != len) {
     LOG(LOG_WARNING,
-       "write(%d, %p, %d failed)!\n",
+       _("Write(%d, %p, %d) failed: %s\n"),
        this->handles[level],
        buf,
-       len);
+       len,
+       STRERROR(errno));
   }
   MUTEX_UNLOCK(&this->lock);
   return ret;
@@ -487,6 +490,7 @@
 static void addRequest(RequestManager * rm,
                       NodeClosure * node) {
   RequestEntry * entry;
+#if DEBUG_DOWNLOAD
   EncName enc;
 
   IFLOG(LOG_DEBUG,
@@ -495,6 +499,7 @@
   LOG(LOG_DEBUG,
       "Queuing request (query: %s)\n",
       &enc);
+#endif
 
   GNUNET_ASSERT(node != NULL);
   entry
@@ -848,6 +853,7 @@
   unsigned int size;
   int i;
   char * data;
+#if DEBUG_DOWNLOAD
   EncName enc;
 
   IFLOG(LOG_DEBUG,
@@ -856,15 +862,13 @@
   LOG(LOG_DEBUG,
       "Receiving reply to query %s\n",
       &enc);
+#endif
 
   GNUNET_ASSERT(equalsHashCode512(query,
                                  &node->chk.query));
   size = ntohl(reply->size) - sizeof(Datastore_Value);
   if ( (size <= sizeof(DBlock)) ||
        (size - sizeof(DBlock) != getNodeSize(node)) ) {
-    printf("Received %llu bytes, expected %u\n",
-          (unsigned long long) (size - sizeof(DBlock)),
-          getNodeSize(node));
     BREAK();
     return SYSERR; /* invalid size! */
   }
@@ -943,7 +947,9 @@
   cron_t timeout;
   unsigned int ttl;
   int TTL_DECREMENT;
+#if DEBUG_DOWNLOAD 
   EncName enc;
+#endif
 
   cronTime(&now);
   entry = rm->requestList[requestIndex];
@@ -968,7 +974,7 @@
        calculated tpriority is above it, we reduce tpriority
        to random value between the average (mpriority/2) but
        bounded by mpriority */
-    priority = mpriority / 2 + (randomi(1+mpriority/2));
+    priority = 1 + mpriority / 2 + (randomi(2+mpriority/2));
   }
   if (priority > 0x0FFFFFF)
     priority = randomi(0xFFFFFF); /* bound! */
@@ -1009,12 +1015,14 @@
     timeout = now + ttl;
   }
 
+#if DEBUG_DOWNLOAD
   IFLOG(LOG_DEBUG,
        hash2enc(&entry->node->chk.query,
                 &enc));
   LOG(LOG_DEBUG,
       "Starting FS search for %s\n",
       &enc);
+#endif
 
   if (entry->searchHandle != NULL)
     FS_stop_search(rm->sctx,
@@ -1151,6 +1159,10 @@
   NodeClosure * top;
   FileIdentifier fid;
 
+  LOG(LOG_DEBUG,
+      "'%s' running for file '%s'\n",
+      __FUNCTION__,
+      filename);
   GNUNET_ASSERT(filename != NULL);
   fid = uri->data.chk;
   if (! ECRS_isFileUri(uri)) {
@@ -1161,6 +1173,10 @@
   if (OK != createIOContext(&ioc,
                            ntohll(fid.file_length),
                            filename)) {
+    LOG(LOG_DEBUG,
+       "'%s' aborted for file '%s'\n",
+       __FUNCTION__,
+       filename);
     return SYSERR;
   }
   rm = createRequestManager();
@@ -1196,6 +1212,11 @@
     freeIOC(&ioc, YES);
   else
     freeIOC(&ioc, NO); /* aborted */
+  LOG(LOG_DEBUG,
+      "'%s' terminating for file '%s' with result %s\n",
+      __FUNCTION__,
+      filename,
+      ret == OK ? "SUCCESS" : "INCOMPLETE");
   return ret;
 }
 

Modified: GNUnet/src/applications/fs/ecrs/keyspace.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/keyspace.c  2005-08-14 23:40:07 UTC (rev 
1669)
+++ GNUnet/src/applications/fs/ecrs/keyspace.c  2005-08-15 01:30:32 UTC (rev 
1670)
@@ -32,6 +32,8 @@
 #include "gnunet_protocols.h"
 #include "ecrs.h"
 
+#define DEBUG_KEYSPACE NO
+
 /**
  * What is the maximum size that we allow for a kblock
  * before we start dropping meta-data?
@@ -132,7 +134,9 @@
   char ** keywords;
   unsigned int keywordCount;
   int i;
+#if DEBUG_KEYSPACE
   EncName enc;
+#endif
   HashCode512 key;
   char * cpy; /* copy of the encrypted portion */
   struct ECRS_URI * xuri;
@@ -204,12 +208,14 @@
     hash(keywords[i],
         strlen(keywords[i]),
         &key);
+#if DEBUG_KEYSPACE
     IFLOG(LOG_DEBUG,
          hash2enc(&key,
                   &enc));
     LOG(LOG_DEBUG,
        "Encrypting KBlock with key %s.\n",
        &enc);
+#endif
     ECRS_encryptInPlace(&key,
                        &kb[1],
                        mdsize + strlen(dstURI) + 1);

Modified: GNUnet/src/applications/fs/ecrs/search.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/search.c    2005-08-14 23:40:07 UTC (rev 
1669)
+++ GNUnet/src/applications/fs/ecrs/search.c    2005-08-15 01:30:32 UTC (rev 
1670)
@@ -31,6 +31,8 @@
 #include "ecrs_core.h"
 #include "ecrs.h"
 
+#define DEBUG_SEARCH NO
+
 typedef struct {
 
   /**
@@ -182,8 +184,10 @@
     PublicKey pub;
     int i;
     
+#if DEBUG_SEARCH
     LOG(LOG_DEBUG,
        "Computing queries (this may take a while).\n");
+#endif
     for (i=0;i<uri->data.ksk.keywordCount;i++) {
       hash(uri->data.ksk.keywords[i],
           strlen(uri->data.ksk.keywords[i]),
@@ -201,8 +205,10 @@
            sqc);
       freePrivateKey(pk);
     }  
+#if DEBUG_SEARCH
     LOG(LOG_DEBUG,
        "Queries ready.\n");
+#endif
     break;
   }
   case loc:
@@ -319,9 +325,11 @@
 
   type = ntohl(value->type);
   size = ntohl(value->size) - sizeof(Datastore_Value);
+#if DEBUG_SEARCH
   LOG(LOG_DEBUG,
       "Search received reply of type %u and size %u.\n",
       type, size);
+#endif
   if (OK != getQueryFor(size,
                        (const DBlock*) &value[1],
                        &query))
@@ -348,12 +356,14 @@
          return SYSERR;
        kb = MALLOC(size);
        memcpy(kb, &value[1], size);
+#if DEBUG_SEARCH
        IFLOG(LOG_DEBUG,
              hash2enc(&ps->decryptKey,
                       &enc));
        LOG(LOG_DEBUG,
            "Decrypting KBlock with key %s.\n",
            &enc);
+#endif
        ECRS_decryptInPlace(&ps->decryptKey,
                            &kb[1],
                            size - sizeof(KBlock));
@@ -579,11 +589,12 @@
        new_priority = randomi(0xFFFFFF); /* if we get to large, reduce! */
       ps->priority = new_priority;
       ps->lastTransmission = now;
+#if DEBUG_SEARCH
       LOG(LOG_DEBUG,
          "ECRS initiating FS search with timeout %llus and priority %u.\n",
          (ps->timeout - now) / cronSECONDS,
          ps->priority);
-
+#endif
       ps->handle
        = FS_start_search(ctx.sctx,
                          ps->type,

Modified: GNUnet/src/applications/fs/ecrs/upload.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/upload.c    2005-08-14 23:40:07 UTC (rev 
1669)
+++ GNUnet/src/applications/fs/ecrs/upload.c    2005-08-15 01:30:32 UTC (rev 
1670)
@@ -38,6 +38,8 @@
 #include "uri.h"
 #include "tree.h"
 
+#define DEBUG_UPLOAD NO
+
 /**
  * Append the given key and query to the iblock[level].
  * If iblock[level] is already full, compute its chk
@@ -53,7 +55,9 @@
   Datastore_Value * value;
   DBlock * db;
   CHK ichk;
+#if DEBUG_UPLOAD
   EncName enc;
+#endif
 
   size = ntohl(iblocks[level]->size);
   GNUNET_ASSERT(size > sizeof(Datastore_Value));
@@ -68,6 +72,7 @@
     fileBlockGetQuery(db,
                      size,
                      &ichk.query);
+#if DEBUG_UPLOAD
     IFLOG(LOG_DEBUG,
          hash2enc(&ichk.query,
                   &enc));
@@ -75,6 +80,7 @@
        "Query for current iblock at level %u is %s\n",
        level,
        &enc);
+#endif
     if (OK != pushBlock(sock,
                        &ichk,
                        level+1,
@@ -88,12 +94,14 @@
       BREAK();
       return SYSERR;
     }
+#if DEBUG_UPLOAD
     IFLOG(LOG_DEBUG,
          hash2enc(&ichk.query,
                   &enc));
     LOG(LOG_DEBUG,
        "Publishing block (query: %s)\n",
        &enc);
+#endif
     if (OK != FS_insert(sock,
                        value)) {
       FREE(value);
@@ -152,7 +160,9 @@
   cron_t now;
   char * uris;
   FileIdentifier fid;
+#if DEBUG_UPLOAD
   EncName enc;
+#endif
 
   cronTime(&start);
   memset(&chk, 0, sizeof(CHK));
@@ -162,7 +172,7 @@
   }
   if (0 == assertIsFile(filename)) {
     LOG(LOG_ERROR,
-       "'%s' is not a file.\n",
+       _("'%s' is not a file.\n"),
        filename);
     return SYSERR;
   }
@@ -274,6 +284,7 @@
     fileBlockGetQuery(db,
                      size + sizeof(DBlock),
                      &chk.query);
+#if DEBUG_UPLOAD
     IFLOG(LOG_DEBUG,
          hash2enc(&chk.query,
                   &enc));
@@ -281,6 +292,7 @@
        "Query for current block of size %u is %s\n",
        size,
        &enc);
+#endif
     if (doIndex) {
       if (SYSERR == FS_index(sock,
                             &fileId,
@@ -322,35 +334,43 @@
   if (tt != NULL)
     if (OK != tt(ttClosure))
       goto FAILURE;
+#if DEBUG_UPLOAD
   LOG(LOG_DEBUG,
       "Tree depth is %u, walking up tree.\n",
       treedepth);
+#endif
   for (i=0;i<treedepth;i++) {
     size = ntohl(iblocks[i]->size) - sizeof(Datastore_Value);
     GNUNET_ASSERT(size < MAX_BUFFER_SIZE);
     if (size == sizeof(DBlock)) {
+#if DEBUG_UPLOAD
       LOG(LOG_DEBUG,
          "Level %u is empty\n",
          i);
+#endif
       continue;
     }
     db = (DBlock*) &iblocks[i][1];
     fileBlockGetKey(db,
                    size,
                    &chk.key);
+#if DEBUG_UPLOAD
     LOG(LOG_DEBUG,
        "Computing query for %u bytes content.\n",
        size);
+#endif
     fileBlockGetQuery(db,
                      size,
                      &chk.query);
+#if DEBUG_UPLOAD
     IFLOG(LOG_DEBUG,
          hash2enc(&chk.query,
                   &enc));
     LOG(LOG_DEBUG,
-       "Query for current block at level %u is %s\n",
+       "Query for current block at level %u is '%s'.\n",
        i,
        &enc);
+#endif
     if (OK != pushBlock(sock,
                        &chk,
                        i+1,
@@ -373,12 +393,14 @@
     FREE(iblocks[i]);
     iblocks[i] = NULL;
   }
+#if DEBUG_UPLOAD
   IFLOG(LOG_DEBUG,
        hash2enc(&chk.query,
                 &enc));
   LOG(LOG_DEBUG,
       "Query for top block is %s\n",
       &enc);
+#endif
   /* build URI */
   fid.file_length = htonll(filesize);
   db = (DBlock*) &iblocks[treedepth][1];

Modified: GNUnet/src/applications/fs/fsui/check.conf
===================================================================
--- GNUnet/src/applications/fs/fsui/check.conf  2005-08-14 23:40:07 UTC (rev 
1669)
+++ GNUnet/src/applications/fs/fsui/check.conf  2005-08-15 01:30:32 UTC (rev 
1670)
@@ -5,7 +5,7 @@
 GNUNETD_HOME     = /tmp/gnunet-check-fsui
 # VALGRIND        = 300
 HELLOEXPIRES    = 60
-LOGLEVEL        = DEBUG
+LOGLEVEL        = ERROR
 LOGFILE         = $GNUNETD_HOME/logs
 KEEPLOG         = 0
 PIDFILE         = $GNUNETD_HOME/gnunetd.pid

Modified: GNUnet/src/applications/fs/fsui/download.c
===================================================================
--- GNUnet/src/applications/fs/fsui/download.c  2005-08-14 23:40:07 UTC (rev 
1669)
+++ GNUnet/src/applications/fs/fsui/download.c  2005-08-15 01:30:32 UTC (rev 
1670)
@@ -30,6 +30,7 @@
 #include "gnunet_fsui_lib.h"
 #include "fsui.h"
 
+#define DEBUG_DTM NO
 
 /**
  * Start to download a file.
@@ -366,6 +367,11 @@
   if (list == NULL)
     return NO;
 
+#if DEBUG_DTM
+  LOG(LOG_DEBUG,
+      "Download thread manager investigates pending downlod of file '%s'\n",
+      list->filename);
+#endif
   ret = NO;
   /* should this one be started? */
   if ( (list->ctx->threadPoolSize
@@ -373,6 +379,11 @@
        (list->signalTerminate == SYSERR) &&
        (list->total > list->completed) &&
        (list->finished == NO) ) {
+#if DEBUG_DTM
+    LOG(LOG_DEBUG,
+       "Download thread manager schedules active downlod of file '%s'\n",
+       list->filename);
+#endif
     list->signalTerminate = NO;
     if (0 == PTHREAD_CREATE(&list->handle,
                            (PThreadMain)&downloadThread,
@@ -388,6 +399,11 @@
   if ( (list->ctx->threadPoolSize
        < list->ctx->activeDownloadThreads) &&
        (list->signalTerminate == NO) ) {
+#if DEBUG_DTM
+    LOG(LOG_DEBUG,
+       "Download thread manager aborts active downlod of file '%s'\n",
+       list->filename);
+#endif
     list->signalTerminate = YES;
     PTHREAD_JOIN(&list->handle,
                 &unused);
@@ -398,6 +414,11 @@
 
   /* has this one "died naturally"? */
   if (list->signalTerminate == YES) {
+#if DEBUG_DTM
+    LOG(LOG_DEBUG,
+       "Download thread manager collects inactive downlod of file '%s'\n",
+       list->filename);
+#endif
     PTHREAD_JOIN(&list->handle,
                 &unused);
     list->ctx->activeDownloadThreads--;

Modified: GNUnet/src/applications/fs/fsui/downloadtest.c
===================================================================
--- GNUnet/src/applications/fs/fsui/downloadtest.c      2005-08-14 23:40:07 UTC 
(rev 1669)
+++ GNUnet/src/applications/fs/fsui/downloadtest.c      2005-08-15 01:30:32 UTC 
(rev 1670)
@@ -75,6 +75,7 @@
 static volatile enum FSUI_EventType lastEvent;
 static volatile enum FSUI_EventType waitForEvent;
 static struct FSUI_Context * ctx;
+static struct ECRS_URI * upURI;
 
 static void eventCallback(void * cls,
                          const FSUI_Event * event) {
@@ -85,19 +86,26 @@
     printf("Received search result\n");
     break;
   case FSUI_upload_progress:
-    printf("Upload is progressing...\n");
+    printf("Upload is progressing (%llu/%llu)...\n",
+          event->data.UploadProgress.completed,
+          event->data.UploadProgress.total);
     break;
   case FSUI_upload_complete:
+    upURI = ECRS_dupUri(event->data.UploadComplete.uri);
     printf("Upload complete.\n");
     break;
   case FSUI_download_complete:
     printf("Download complete.\n");
     break;
   case FSUI_download_progress:
-    printf("Download is progressing...\n");
+    printf("Download is progressing (%llu/%llu)...\n",
+          event->data.DownloadProgress.completed,
+          event->data.DownloadProgress.total);
     break;
   case FSUI_unindex_progress:
-    printf("Unindex is progressing...\n");
+    printf("Unindex is progressing (%llu/%llu)...\n",
+          event->data.UnindexProgress.completed,
+          event->data.UnindexProgress.total);
     break;
   case FSUI_unindex_complete:
     printf("Unindex complete.\n");
@@ -108,6 +116,12 @@
   case FSUI_search_error:
     errexit("Received ERROR: %d\n",
            event->type);
+  case FSUI_download_aborted:
+    printf("Received unexpected download aborted event.\n");
+    break;
+  case FSUI_gnunetd_connected:
+  case FSUI_gnunetd_disconnected:
+    break;
   default:
     printf("Unexpected event: %d\n",
           event->type);
@@ -119,6 +133,9 @@
   if (event->type == FSUI_search_result) {
     char * u;
 
+    if (! ECRS_equalsUri(upURI,
+                        event->data.SearchResult.fi.uri))
+      return; /* ignore */
     fn = makeName(43);
     u = ECRS_uriToString(event->data.SearchResult.fi.uri);
     printf("Download started: %s.\n", u);
@@ -130,14 +147,17 @@
                           fn))
       errexit("Failed to start download.\n");
     FREE(fn);
-    suspendRestart = 1;
+    suspendRestart = 4;
   }
 }
 
+#define FILESIZE (1024 * 1024 * 2)
 
+
 int main(int argc, char * argv[]){
   pid_t daemon;
   int ok;
+  int i;
   struct ECRS_URI * uri = NULL;
   char * fn = NULL;
   char * keywords[] = { 
@@ -147,6 +167,7 @@
   };
   char keyword[40];
   int prog;
+  char * buf;
   struct ECRS_MetaData * meta;
   struct ECRS_URI * kuri = NULL;
 
@@ -154,7 +175,7 @@
                     argv, 
                     &parseCommandLine))
     return -1;
-#if 0
+#if 1
   daemon = startGNUnetDaemon(NO);
   GNUNET_ASSERT(daemon > 0);
 #else
@@ -172,10 +193,14 @@
                   NULL);
   CHECK(ctx != NULL);
   fn = makeName(42);
+  buf = MALLOC(FILESIZE);
+  for (i=0;i<FILESIZE;i++)
+    buf[i] = weak_randomi(256);
   writeFile(fn,
-           "foo bar test!",
-           strlen("foo bar test!"),
+           buf,
+           FILESIZE,
            "600");
+  FREE(buf);
   meta = ECRS_createMetaData();
   kuri = FSUI_parseListKeywordURI(2,
                                  (const char**)keywords);
@@ -213,15 +238,18 @@
     prog++;
     CHECK(prog < 10000);
     gnunet_util_sleep(50 * cronMILLIS);
-    if (suspendRestart > 0) {
+    if ( (suspendRestart > 0) &&
+        (randomi(4) == 0) ) {
       suspendCron();
-#if 0
+#if 1
+      printf("Testing FSUI suspend-resume\n");
       FSUI_stop(ctx); /* download possibly incomplete
                         at this point, thus testing resume */
       ctx = FSUI_start("fsuidownloadtest",
                       YES,
                       &eventCallback,
                       NULL);
+      printf("Resumed...\n");
 #endif
       resumeCron();
       suspendRestart--;
@@ -253,6 +281,9 @@
                      uri,
                      fn);
     FREE(fn);
+    FSUI_clearCompletedDownloads(ctx,
+                                NULL,
+                                NULL);
     FSUI_stop(ctx);
   }  
   if (uri != NULL)
@@ -263,6 +294,8 @@
   /* TODO: verify file 'fn(42)' == file 'fn(43)' */
   UNLINK(fn);
   FREE(fn);
+  if (upURI != NULL)
+    ECRS_freeUri(upURI);
 
   stopCron();
   GNUNET_ASSERT(OK == stopGNUnetDaemon());

Modified: GNUnet/src/applications/fs/fsui/file_info.c
===================================================================
--- GNUnet/src/applications/fs/fsui/file_info.c 2005-08-14 23:40:07 UTC (rev 
1669)
+++ GNUnet/src/applications/fs/fsui/file_info.c 2005-08-15 01:30:32 UTC (rev 
1670)
@@ -32,6 +32,8 @@
 #include "gnunet_fsui_lib.h"
 #include "gnunet_ecrs_lib.h"
 
+#define DEBUG_FILE_INFO NO
+
 #define STATE_NAME "fs_uridb"
 #define TRACK_OPTION "fs_uridb_status"
 
@@ -69,8 +71,10 @@
                                        (void**)&status)) ||
        (ntohl(*status) != YES) ) {
     FREENONNULL(status);
+#if DEBUG_FILE_INFO
     LOG(LOG_DEBUG,
        _("Collecting file identifiers disabled.\n"));
+#endif
     return NO;
   } else {
     FREENONNULL(status);

Modified: GNUnet/src/applications/fs/fsui/fsui.c
===================================================================
--- GNUnet/src/applications/fs/fsui/fsui.c      2005-08-14 23:40:07 UTC (rev 
1669)
+++ GNUnet/src/applications/fs/fsui/fsui.c      2005-08-15 01:30:32 UTC (rev 
1670)
@@ -28,6 +28,8 @@
 #include "gnunet_fsui_lib.h"
 #include "fsui.h"
 
+#define DEBUG_PERSISTENCE NO
+
 #define FSUI_UDT_FREQUENCY (2 * cronSECONDS)
 
 #define READINT(a) \
@@ -76,7 +78,7 @@
                                            FSUI_Context * ctx,
                                            FSUI_DownloadList * parent) {
   char zaro;
-  static FSUI_DownloadList * ret;
+  FSUI_DownloadList * ret;
   unsigned int big;
   unsigned long long bigl;
   int i;
@@ -89,8 +91,6 @@
   }
   if (zaro == '\0')
     return NULL;
-  LOG(LOG_DEBUG,
-      "FSUI persistence: restoring download\n");
   ret = MALLOC(sizeof(FSUI_DownloadList));
   memset(ret, 
         0,
@@ -147,6 +147,12 @@
   ret->child = readDownloadList(fd,
                                ctx,
                                ret);
+#if DEBUG_PERSISTENCE
+  LOG(LOG_DEBUG,
+      "FSUI persistence: restoring download '%s': %s\n",
+      ret->filename,
+      ret->finished == YES ? "finished" : "pending");
+#endif
   return ret;
  ERR:
   FREENONNULL(ret->filename);
@@ -204,6 +210,12 @@
     WRITE(fd, &zero, sizeof(char));
     return;
   }
+#if DEBUG_PERSISTENCE
+  LOG(LOG_DEBUG,
+      "Serializing download state of download '%s': %s\n",
+      list->filename,
+      list->finished == YES ? "finished" : "pending");
+#endif
   WRITE(fd, &nonzero, sizeof(char));
 
   WRITEINT(fd, list->is_recursive);
@@ -306,6 +318,11 @@
 
   MUTEX_LOCK(&ctx->lock);
   dpos = ctx->activeDownloads.child;
+#if DEBUG_PERSISTENCE
+  if (dpos != NULL)
+    LOG(LOG_DEBUG,
+       "Download thread manager schedules pending downloads...\n");
+#endif
   while (dpos != NULL) {
     updateDownloadThread(dpos);
     dpos = dpos->next;
@@ -546,8 +563,10 @@
        list->ctx
          = ret;
        /* start search thread! */
+#if DEBUG_PERSISTENCE
        LOG(LOG_DEBUG,
            "FSUI persistence: restarting search\n");
+#endif
        if (0 != PTHREAD_CREATE(&list->handle,
                                (PThreadMain)&searchThread,
                                list,
@@ -679,7 +698,15 @@
            "FSUI00\n\0",
            8); /* magic */
     }
+#if DEBUG_PERSISTENCE
+    LOG(LOG_DEBUG,
+       "Serializing FSUI state...\n");
+#endif
   } else {
+#if DEBUG_PERSISTENCE
+    LOG(LOG_DEBUG,
+       "NOT serializing FSUI state...\n");
+#endif
     fd = -1;
   }
   if (fd != -1) {
@@ -780,8 +807,13 @@
     writeDownloadList(fd,
                      ctx->activeDownloads.child);
   }
-  if (fd != -1)
+  if (fd != -1) {
+#if DEBUG_PERSISTENCE
+    LOG(LOG_DEBUG,
+       "Serializing FSUI state done.\n");
+#endif
     CLOSE(fd);
+  }
 
   /* finally, free all (remaining) FSUI data */
   while (ctx->activeDownloads.child != NULL)

Modified: GNUnet/src/applications/fs/fsui/search.c
===================================================================
--- GNUnet/src/applications/fs/fsui/search.c    2005-08-14 23:40:07 UTC (rev 
1669)
+++ GNUnet/src/applications/fs/fsui/search.c    2005-08-15 01:30:32 UTC (rev 
1670)
@@ -31,6 +31,8 @@
 #include "gnunet_fsui_lib.h"
 #include "fsui.h"
 
+#define DEBUG_SEARCH NO
+
 /**
  * Pass the result to the client and note it as shown.
  */
@@ -67,15 +69,19 @@
   for (i=0;i<pos->sizeResultsReceived;i++)
     if (ECRS_equalsUri(fi->uri,
                       pos->resultsReceived[i].uri)) {
+#if DEBUG_SEARCH
       LOG(LOG_DEBUG,
          "Received search result that I have seen before.\n");
+#endif
       return OK; /* seen before */
     }
   if (pos->numberOfURIKeys > 1) {
     if (key == NULL) {
       BREAK();
+#if DEBUG_SEARCH
       LOG(LOG_DEBUG,
          "Received search result without key to decrypt.\n");
+#endif
       return SYSERR;
     }
     for (i=0;i<pos->sizeUnmatchedResultsReceived;i++) {
@@ -85,13 +91,17 @@
        for (j=0;j<rp->matchingKeyCount;j++)
          if (equalsHashCode512(key,
                                &rp->matchingKeys[j])) {
+#if DEBUG_SEARCH
            LOG(LOG_DEBUG,
                "Received search result that I have seen before (missing 
keyword to show client).\n");
+#endif
            return OK;
          }
        if (rp->matchingKeyCount + 1 == pos->numberOfURIKeys) {
+#if DEBUG_SEARCH
          LOG(LOG_DEBUG,
              "Received search result (showing client)!\n");
+#endif
          GROW(rp->matchingKeys,
               rp->matchingKeyCount,
               0);
@@ -110,9 +120,11 @@
               rp->matchingKeyCount,
               rp->matchingKeyCount+1);
          rp->matchingKeys[rp->matchingKeyCount-1] = *key;
+#if DEBUG_SEARCH
          LOG(LOG_DEBUG,
              "Received search result (waiting for more %u keys before showing 
client).\n",
              pos->numberOfURIKeys - rp->matchingKeyCount);
+#endif
          return OK;
        }       
       }
@@ -129,13 +141,17 @@
         rp->matchingKeyCount,
         1);
     rp->matchingKeys[0] = *key;
+#if DEBUG_SEARCH
     LOG(LOG_DEBUG,
        "Received search result (waiting for %u more keys before showing 
client).\n",
        pos->numberOfURIKeys  - rp->matchingKeyCount);
+#endif
     return OK;
   } else {
+#if DEBUG_SEARCH
     LOG(LOG_DEBUG,
        "Received search result (showing client)!\n");
+#endif
     processResult(fi,
                  pos);
   }

Modified: GNUnet/src/applications/fs/lib/fslib.c
===================================================================
--- GNUnet/src/applications/fs/lib/fslib.c      2005-08-14 23:40:07 UTC (rev 
1669)
+++ GNUnet/src/applications/fs/lib/fslib.c      2005-08-15 01:30:32 UTC (rev 
1670)
@@ -29,6 +29,8 @@
 #include "fs.h"
 #include "ecrs_core.h"
 
+#define DEBUG_FSLIB NO
+
 typedef struct FS_SEARCH_HANDLE {
   CS_fs_request_search_MESSAGE * req;
   Datum_Iterator callback;
@@ -197,6 +199,7 @@
   }
   ctx->handles[ctx->handleCount++] = ret;
   MUTEX_UNLOCK(ctx->lock);
+#if DEBUG_FSLIB
   IFLOG(LOG_DEBUG,
        hash2enc(&req->query[0],
                 &enc));
@@ -204,6 +207,7 @@
       "FS initiating search for %s of type %u\n",
       &enc,
       type);
+#endif
   if (OK != writeToSocket(ctx->sock,
                          &req->header)) {
     FS_stop_search(ctx,
@@ -311,16 +315,20 @@
   ri->fileId = *fileHc;
   memcpy(&ri[1], fn, fnSize);
 
+#if DEBUG_FSLIB
   LOG(LOG_DEBUG,
       "Sending index initialization request to gnunetd\n");
+#endif
   if (OK != writeToSocket(sock,
         &ri->header)) {
     FREE(ri);
     return SYSERR;
   }
   FREE(ri);
+#if DEBUG_FSLIB
   LOG(LOG_DEBUG,
       "Waiting for confirmation of index initialization request by gnunetd\n");
+#endif
   if (OK != readTCPResult(sock,
         &ret))
     return SYSERR;
@@ -355,16 +363,20 @@
   memcpy(&ri[1],
         &block[1],
         size);
+#if DEBUG_FSLIB
   LOG(LOG_DEBUG,
       "Sending index request to gnunetd\n");
+#endif
   if (OK != writeToSocket(sock,
                          &ri->header)) {
     FREE(ri);
     return SYSERR;
   }
   FREE(ri);
+#if DEBUG_FSLIB
   LOG(LOG_DEBUG,
       "Waiting for confirmation of index request by gnunetd\n");
+#endif
   if (OK != readTCPResult(sock,
                          &ret))
     return SYSERR;

Modified: GNUnet/src/applications/fs/module/fs.c
===================================================================
--- GNUnet/src/applications/fs/module/fs.c      2005-08-14 23:40:07 UTC (rev 
1669)
+++ GNUnet/src/applications/fs/module/fs.c      2005-08-15 01:30:32 UTC (rev 
1670)
@@ -283,7 +283,7 @@
  * @return SYSERR if the TCP connection should be closed, otherwise OK
  */
 static int csHandleCS_fs_request_insert_MESSAGE(ClientHandle sock,
-                                const CS_MESSAGE_HEADER * req) {
+                                               const CS_MESSAGE_HEADER * req) {
   const CS_fs_request_insert_MESSAGE * ri;
   Datastore_Value * datum;
   int ret;
@@ -316,7 +316,7 @@
   type = getTypeOfBlock(ntohs(ri->header.size) - 
sizeof(CS_fs_request_insert_MESSAGE),
                        (const DBlock*) &ri[1]);
   LOG(LOG_DEBUG,
-      "FS received REQUEST INSERT (query: %s, type: %u)\n",
+      "FS received REQUEST INSERT (query: '%s', type: %u)\n",
       &enc,
       type);
   datum->type = htonl(type);
@@ -373,7 +373,7 @@
  * Process a request to symlink a file
  */
 static int csHandleCS_fs_request_init_index_MESSAGE(ClientHandle sock,
-                                   const CS_MESSAGE_HEADER * req) {
+                                                   const CS_MESSAGE_HEADER * 
req) {
   int ret;
   char *fn;
   CS_fs_request_init_index_MESSAGE *ri;
@@ -413,7 +413,7 @@
  * @return SYSERR if the TCP connection should be closed, otherwise OK
  */
 static int csHandleCS_fs_request_index_MESSAGE(ClientHandle sock,
-                               const CS_MESSAGE_HEADER * req) {
+                                              const CS_MESSAGE_HEADER * req) {
   int ret;
   const CS_fs_request_index_MESSAGE * ri;
 
@@ -472,7 +472,7 @@
  * @return SYSERR if the TCP connection should be closed, otherwise OK
  */
 static int csHandleCS_fs_request_delete_MESSAGE(ClientHandle sock,
-                                const CS_MESSAGE_HEADER * req) {
+                                               const CS_MESSAGE_HEADER * req) {
   int ret;
   const CS_fs_request_delete_MESSAGE * rd;
   Datastore_Value * value;
@@ -612,7 +612,15 @@
   const Datastore_Value * value;
   Datastore_Value * xvalue;
   unsigned int level;
+  EncName enc;
 
+  IFLOG(LOG_DEBUG,
+       hash2enc(key,
+                &enc));
+  LOG(LOG_DEBUG,
+      "Converting reply for query '%s' for gap.\n",
+      &enc);
+
   if (ntohl(invalue->type) == ONDEMAND_BLOCK) {
     if (OK != ONDEMAND_getIndexed(datastore,
                                  invalue,
@@ -624,17 +632,28 @@
     xvalue = NULL;
     value = invalue;
   }
-               
   ret = isDatumApplicable(ntohl(value->type),
                          ntohl(value->size) - sizeof(Datastore_Value),
                          (const DBlock*) &value[1],
                          ggc->keyCount,
                          ggc->keys);
   if (ret == SYSERR) {
+    IFLOG(LOG_WARNING,
+         hash2enc(key,
+                  &enc));
+    LOG(LOG_WARNING,
+       "Converting reply for query '%s' for gap failed (datum not 
applicable).\n",
+       &enc);
     FREENONNULL(xvalue);
     return SYSERR; /* no query will ever match */
   }
   if (ret == NO) {
+    IFLOG(LOG_WARNING,
+         hash2enc(key,
+                  &enc));
+    LOG(LOG_WARNING,
+       "Converting reply for query '%s' for gap failed (type not 
applicable).\n",
+       &enc);
     FREENONNULL(xvalue);
     return OK; /* Additional filtering based on type;
                  i.e., namespace request and namespace
@@ -652,6 +671,12 @@
        refuse to hand out data that requires
        anonymity! */
     FREENONNULL(xvalue);
+    IFLOG(LOG_WARNING,
+         hash2enc(key,
+                  &enc));
+    LOG(LOG_WARNING,
+       "Converting reply for query '%s' for gap failed (insufficient cover 
traffic).\n",
+       &enc);
     return OK;    
   }
   gw = MALLOC(size);

Modified: GNUnet/src/applications/fs/module/ondemand.c
===================================================================
--- GNUnet/src/applications/fs/module/ondemand.c        2005-08-14 23:40:07 UTC 
(rev 1669)
+++ GNUnet/src/applications/fs/module/ondemand.c        2005-08-15 01:30:32 UTC 
(rev 1670)
@@ -645,11 +645,14 @@
   UNLINK(fn);
 
   /* Remove information about unavailability */
+  hash2enc(fileId,
+          &enc);
   SNPRINTF(unavail_key,
           256,
           "FIRST_UNAVAILABLE-%s",
           (char*)&enc);
   stateUnlinkFromDB(unavail_key);
+  
 
   FREE(fn);
   return OK;

Modified: GNUnet/src/applications/fs/module/querymanager.c
===================================================================
--- GNUnet/src/applications/fs/module/querymanager.c    2005-08-14 23:40:07 UTC 
(rev 1669)
+++ GNUnet/src/applications/fs/module/querymanager.c    2005-08-15 01:30:32 UTC 
(rev 1670)
@@ -30,6 +30,8 @@
 #include "fs.h"
 #include "querymanager.h"
 
+#define DEBUG_QUERYMANAGER NO
+
 typedef struct {
   HashCode512 query;
   unsigned int type;
@@ -162,6 +164,7 @@
       FREE(rc);
     }
   }
+#if DEBUG_QUERYMANAGER
   if (matchCount == 0) {      
     EncName enc;
 
@@ -172,6 +175,7 @@
        "Reply '%s' did not match any request.\n",
        &enc);
   }
+#endif
   MUTEX_UNLOCK(&queryManagerLock);
 }
 

Modified: GNUnet/src/applications/gap/gap.c
===================================================================
--- GNUnet/src/applications/gap/gap.c   2005-08-14 23:40:07 UTC (rev 1669)
+++ GNUnet/src/applications/gap/gap.c   2005-08-15 01:30:32 UTC (rev 1670)
@@ -1028,7 +1028,15 @@
   P2P_gap_reply_MESSAGE * pmsg;
   IndirectionTableEntry * ite;
   unsigned int size;
+  EncName enc;
 
+  IFLOG(LOG_DEBUG,
+       hash2enc(primaryKey,
+                &enc));
+  LOG(LOG_DEBUG,
+      "Gap queues reply to query '%s' for later use.\n",
+      &enc);
+
 #if EXTRA_CHECKS
   /* verify data is valid */
   uri(data,

Modified: GNUnet/src/applications/sqstore_sqlite/sqlite.c
===================================================================
--- GNUnet/src/applications/sqstore_sqlite/sqlite.c     2005-08-14 23:40:07 UTC 
(rev 1669)
+++ GNUnet/src/applications/sqstore_sqlite/sqlite.c     2005-08-15 01:30:32 UTC 
(rev 1670)
@@ -23,7 +23,6 @@
  * @brief SQLite based implementation of the sqstore service
  * @author Nils Durner
  * @todo Estimation of DB size
- * @todo Apply fixes from MySQL module
  *
  * Database: SQLite
  */
@@ -34,7 +33,7 @@
 #include "gnunet_protocols.h"
 #include <sqlite3.h>
 
-#define DEBUG_SQLITE NO
+#define DEBUG_SQLITE YES
 
 /**
  * Die with an error message that indicates
@@ -114,11 +113,6 @@
   MUTEX_LOCK(&dbh->DATABASE_Lock_);
   ret = dbh->payload;
   MUTEX_UNLOCK(&dbh->DATABASE_Lock_);
-#if DEBUG_SQLITE
-  LOG(LOG_DEBUG,
-      "SQLite: database size: %.0f\n",
-      ret);
-#endif
   return ret;
 }
 
@@ -347,10 +341,6 @@
   char * lastHash;
   HashCode512 key;
 
-#if DEBUG_SQLITE
-  LOG(LOG_DEBUG, "SQLite: iterating through the database\n");
-#endif
-
   MUTEX_LOCK(&dbh->DATABASE_Lock_);
 
   strcpy(scratch,
@@ -473,10 +463,6 @@
   sqlite3_finalize(stmt);
   MUTEX_UNLOCK(&dbh->DATABASE_Lock_);
 
-#if DEBUG_SQLITE
-  LOG(LOG_DEBUG,
-      "SQLite: reached end of database\n");
-#endif
   return count;
 }
 
@@ -570,11 +556,13 @@
   Datastore_Datum *datum;
 
 #if DEBUG_SQLITE
-  {
-    char block[33];
-    hash2enc(block, (EncName *) key);
-    LOG(LOG_DEBUG, "SQLite: read content %s\n", key);
-  }
+  EncName enc;
+  IFLOG(LOG_DEBUG,
+       hash2enc(key,
+                &enc));
+  LOG(LOG_DEBUG,
+      "SQLite: retrieving content '%s'\n", 
+      &enc);  
 #endif
 
   MUTEX_LOCK(&dbh->DATABASE_Lock_);
@@ -691,18 +679,23 @@
   unsigned int contentSize;
   unsigned int size, type, prio, anon;
   unsigned long long expir;
+#if DEBUG_SQLITE
+  EncName enc;
 
+  IFLOG(LOG_DEBUG,
+       hash2enc(key,
+                &enc));
+  LOG(LOG_DEBUG,
+      "Storing in database block with type %u and key '%s'.\n",
+      ntohl(*(int*)&value[1]),
+      &enc);
+#endif
+
   if ( (ntohl(value->size) < sizeof(Datastore_Value)) ) {
     BREAK();
     return SYSERR;
   }
 
-#if DEBUG_SQLITE
-  LOG(LOG_DEBUG,
-      "Storing in database block with type %u.\n",
-      ntohl(*(int*)&value[1]));
-#endif
-
   MUTEX_LOCK(&dbh->DATABASE_Lock_);
 
   if (dbh->lastSync > 1000)
@@ -779,9 +772,15 @@
   char * escapedBlock;
   int blockLen;
   unsigned long contentSize;
+#if DEBUG_SQLITE
+  EncName enc;
 
-#if DEBUG_SQLITE
-  LOG(LOG_DEBUG, "SQLite: delete block\n");
+  IFLOG(LOG_DEBUG,
+       hash2enc(key,
+                &enc));
+  LOG(LOG_DEBUG,
+      "SQLite: deleting block with key '%s'\n",
+      &enc);
 #endif
 
   MUTEX_LOCK(&dbh->DATABASE_Lock_);
@@ -896,10 +895,15 @@
   char *escapedHash, *escapedBlock;
   int hashLen, blockLen, n;
   unsigned long contentSize;
+#if DEBUG_SQLITE
+  EncName enc;
 
-#if DEBUG_SQLITE
+  IFLOG(LOG_DEBUG,
+       hash2enc(key,
+                &enc));
   LOG(LOG_DEBUG,
-      "SQLite: update block\n");
+      "SQLite: updating block with key '%s'\n",
+      &enc);
 #endif
 
   MUTEX_LOCK(&dbh->DATABASE_Lock_);
@@ -943,7 +947,8 @@
   MUTEX_UNLOCK(&dbh->DATABASE_Lock_);
 
 #if DEBUG_SQLITE
-  LOG(LOG_DEBUG, "SQLite: block updated\n");
+  LOG(LOG_DEBUG, 
+      "SQLite: block updated\n");
 #endif
 
   return n == SQLITE_OK ? OK : SYSERR;
@@ -959,7 +964,8 @@
   sqlite3_stmt *stmt;
 
 #if DEBUG_SQLITE
-  LOG(LOG_DEBUG, "SQLite: initializing database\n");
+  LOG(LOG_DEBUG, 
+      "SQLite: initializing database\n");
 #endif
 
   dbh = MALLOC(sizeof(sqliteHandle));
@@ -1076,6 +1082,10 @@
  */
 void release_module_sqstore_sqlite() {
   sqlite_shutdown();
+#if DEBUG_SQLITE
+  LOG(LOG_DEBUG, 
+      "SQLite: database shutdown\n");
+#endif
 }
 
 /* end of sqlite.c */





reply via email to

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