gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r215 - in GNUnet: . src/applications/datastore src/applicat


From: grothoff
Subject: [GNUnet-SVN] r215 - in GNUnet: . src/applications/datastore src/applications/fs src/applications/fs/ecrs src/applications/fs/lib src/applications/fs/module src/applications/fs/tools src/applications/gap src/applications/sqstore_mysql src/util
Date: Tue, 8 Feb 2005 18:32:57 -0800 (PST)

Author: grothoff
Date: 2005-02-08 18:32:56 -0800 (Tue, 08 Feb 2005)
New Revision: 215

Modified:
   GNUnet/src/applications/datastore/datastore.c
   GNUnet/src/applications/fs/ecrs/keyspace.c
   GNUnet/src/applications/fs/ecrs/search.c
   GNUnet/src/applications/fs/ecrs_core.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/fs/tools/gnunet-insert.c
   GNUnet/src/applications/gap/gap.c
   GNUnet/src/applications/sqstore_mysql/mysql.c
   GNUnet/src/util/tcpio.c
   GNUnet/todo
Log:
various bugfixes

Modified: GNUnet/src/applications/datastore/datastore.c
===================================================================
--- GNUnet/src/applications/datastore/datastore.c       2005-02-08 19:39:58 UTC 
(rev 214)
+++ GNUnet/src/applications/datastore/datastore.c       2005-02-09 02:32:56 UTC 
(rev 215)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2001, 2002, 2003, 2004 Christian Grothoff (and other contributing 
authors)
+     (C) 2001, 2002, 2003, 2004, 2005 Christian Grothoff (and other 
contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -72,8 +72,11 @@
               void * closure) {
   int ret;
 
-  if (! testAvailable(query))
-    return SYSERR;
+  if (! testAvailable(query)) {
+    LOG(LOG_DEBUG,
+       "Datastore availability pre-test failed for request.\n");
+    return 0;
+  }
 
   ret = sq->get(query,
                type,
@@ -89,6 +92,8 @@
               const Datastore_Value * value) {
   int ok;
 
+  if (! testAvailable(query)) 
+    return 0;
   ok = sq->del(query, value);
   if (OK == ok) {
     makeUnavailable(query); /* update filter! */

Modified: GNUnet/src/applications/fs/ecrs/keyspace.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/keyspace.c  2005-02-08 19:39:58 UTC (rev 
214)
+++ GNUnet/src/applications/fs/ecrs/keyspace.c  2005-02-09 02:32:56 UTC (rev 
215)
@@ -133,6 +133,10 @@
                             &kb[1],
                             &kb->signature));
     /* extra check: verify sig */
+    GNUNET_ASSERT(OK == getQueryFor(size,
+                                   (char*) kb,
+                                   &hc));
+
     freePrivateKey(pk);
     if (OK != FS_insert(sock, value))
       ret = SYSERR;

Modified: GNUnet/src/applications/fs/ecrs/search.c
===================================================================
--- GNUnet/src/applications/fs/ecrs/search.c    2005-02-08 19:39:58 UTC (rev 
214)
+++ GNUnet/src/applications/fs/ecrs/search.c    2005-02-09 02:32:56 UTC (rev 
215)
@@ -308,11 +308,14 @@
 
   type = ntohl(value->type);
   size = ntohl(value->size) - sizeof(Datastore_Value);
+  LOG(LOG_DEBUG,
+      "Search received reply of type %u and size %u.\n",
+      type, size);
   for (i=0;i<sqc->queryCount;i++) {
     ps = sqc->queries[i];
     if ( ( (ps->type == type) ||
           (ps->type == ANY_BLOCK) ) &&
-        (YES != isDatumApplicable(type,
+        (YES == isDatumApplicable(type,
                                   size,
                                   (char*) &value[1],
                                   ps->keyCount,
@@ -518,6 +521,11 @@
       /* FIXME: checkAnonymityPolicy here */
 
       ps->lastTransmission = now;
+      LOG(LOG_DEBUG,
+         "ECRS initiating FS search with timeout %llus and priority %u.\n",
+         (ps->timeout - now) / cronSECONDS, 
+         ps->priority);
+
       ps->handle 
        = FS_start_search(ctx.sctx,
                          ps->type,

Modified: GNUnet/src/applications/fs/ecrs_core.c
===================================================================
--- GNUnet/src/applications/fs/ecrs_core.c      2005-02-08 19:39:58 UTC (rev 
214)
+++ GNUnet/src/applications/fs/ecrs_core.c      2005-02-09 02:32:56 UTC (rev 
215)
@@ -251,7 +251,8 @@
  * @param type the type of the query
  * @param size the size of the data
  * @param data the encoded data
- * @param keyCount the number of keys in the query
+ * @param keyCount the number of keys in the query,
+ *        use 0 to match only primary key
  * @param keys the keys of the query
  * @return YES if this data matches the query, otherwise
  *         NO; SYSERR if the keyCount does not match the
@@ -277,6 +278,8 @@
                we should not even see those here. */
     return SYSERR;    
   }
+  if (keyCount == 0)
+    return YES; /* request was to match only primary key */
   switch (type) {
   case S_BLOCK: 
     if (keyCount != 2) 

Modified: GNUnet/src/applications/fs/lib/fslib.c
===================================================================
--- GNUnet/src/applications/fs/lib/fslib.c      2005-02-08 19:39:58 UTC (rev 
214)
+++ GNUnet/src/applications/fs/lib/fslib.c      2005-02-09 02:32:56 UTC (rev 
215)
@@ -55,11 +55,14 @@
   ReplyContent * rep;
   HashCode160 query;
   unsigned int size;
+  cron_t delay;
 
+  delay = 100 * cronMILLIS;
   while (ctx->abort == NO) {
     hdr = NULL;
     if (OK == readFromSocket(ctx->sock,
                             &hdr)) {
+      delay = 100 * cronMILLIS;
       /* verify hdr, if reply, process, otherwise
         signal protocol problem; if ok, find
         matching callback, call on value */
@@ -69,7 +72,7 @@
        FREE(hdr);
        continue;
       }
-      rep = (ReplyContent*) ctx;
+      rep = (ReplyContent*) hdr;
       size = ntohs(hdr->size) - sizeof(ReplyContent);
       if (OK != getQueryFor(size,
                            (char*)&rep[1],
@@ -85,7 +88,7 @@
          Datastore_Value * value;
 
          value = MALLOC(sizeof(Datastore_Value) + size);
-         value->size = htons(size + sizeof(Datastore_Value));
+         value->size = htonl(size + sizeof(Datastore_Value));
          value->type = htonl(getTypeOfBlock(size,
                                             &rep[1]));
          value->prio = htonl(0);
@@ -101,6 +104,11 @@
        }
       }
       MUTEX_UNLOCK(&ctx->lock);      
+    } else {
+      gnunet_util_sleep(delay);
+      delay *= 2;
+      if (delay > 5 * cronSECONDS)
+       delay = 5 * cronSECONDS;
     }
     FREENONNULL(hdr);
   }

Modified: GNUnet/src/applications/fs/module/fs.c
===================================================================
--- GNUnet/src/applications/fs/module/fs.c      2005-02-08 19:39:58 UTC (rev 
214)
+++ GNUnet/src/applications/fs/module/fs.c      2005-02-09 02:32:56 UTC (rev 
215)
@@ -139,7 +139,19 @@
   memcpy(&dv[1],
         &gw[1],
         size - sizeof(Datastore_Value));
+  if (YES != isDatumApplicable(ntohl(dv->type),
+                              ntohl(dv->size) - sizeof(Datastore_Value),
+                              (char*) &dv[1],
+                              0,
+                              key)) {
+    BREAK();
+    FREE(dv);
+    return SYSERR;
+  }
   processResponse(key, dv); 
+  LOG(LOG_DEBUG,
+      "FS received GAP-PUT request (key: %u)\n",
+      key->a);
   ret = datastore->putUpdate(key,
                             dv);
   FREE(dv);
@@ -149,6 +161,9 @@
 static int get_result_callback(const HashCode160 * key,
                               const DataContainer * value,
                               DHT_GET_CLS * cls) {
+  LOG(LOG_DEBUG,
+      "Found reply to query %u.\n",
+      key->a);
   gapPut(NULL,
         key,
         value,
@@ -181,6 +196,9 @@
     return SYSERR;
   }
   rs = (RequestSearch*) req;
+  LOG(LOG_DEBUG,
+      "FS received QUERY START (key: %u)\n",
+      rs->query[0].a);
   trackQuery(&rs->query[0], 
             ntohl(rs->type),
             sock);
@@ -225,6 +243,9 @@
     return SYSERR;
   }
   rs = (RequestSearch*) req;
+  LOG(LOG_DEBUG,
+      "FS received QUERY STOP (key: %u)\n",
+      rs->query[0].a);
   if (ntohl(rs->anonymityLevel) == 0) {
     /* FIXME 0.7.1: cancel with dht? */
   }
@@ -269,7 +290,14 @@
   }
   type = getTypeOfBlock(ntohs(ri->header.size) - sizeof(RequestInsert),
                        &ri[1]);
+  LOG(LOG_DEBUG,
+      "FS received REQUEST INSERT (key: %u, type: %u)\n",
+      query.a,
+      type);
   datum->type = htonl(type);
+  memcpy(&datum[1],
+        &ri[1],
+        ntohs(req->size) - sizeof(RequestInsert));
   MUTEX_LOCK(&lock);
   ret = datastore->put(&query,
                       datum);
@@ -397,6 +425,11 @@
     BREAK();
     return SYSERR;
   }
+  LOG(LOG_DEBUG,
+      "FS received REQUEST DELETE (key: %u, type: %u)\n",
+      query.a,
+      type);
+
   MUTEX_LOCK(&lock);
   if (SYSERR == datastore->get(&query,
                               type,
@@ -425,6 +458,8 @@
     return SYSERR;
   }
   ru = (RequestUnindex*) req;  
+  LOG(LOG_DEBUG,
+      "FS received REQUEST UNINDEX\n");
   ret = ONDEMAND_unindex(datastore,
                         ntohl(ru->blocksize),
                         &ru->fileId);
@@ -447,6 +482,8 @@
     return SYSERR;
   }
   ru = (RequestTestindex*) req;  
+  LOG(LOG_DEBUG,
+      "FS received REQUEST TESTINDEXED\n");
   ret = ONDEMAND_testindexed(datastore,
                             &ru->fileId);
   return coreAPI->sendValueToClient(sock, 
@@ -459,6 +496,8 @@
  */
 static int csHandleRequestGetAvgPriority(ClientHandle sock,
                                         const CS_HEADER * req) {
+  LOG(LOG_DEBUG,
+      "FS received REQUEST GETAVGPRIORITY\n");
   return coreAPI->sendValueToClient(sock, 
                                    gap->getAvgPriority());
 }
@@ -491,7 +530,7 @@
 
   ret = isDatumApplicable(ntohl(value->type),
                          ntohl(value->size) - sizeof(Datastore_Value),
-                         (char*) &value[1],
+                         (const char*) &value[1],
                          ggc->keyCount,
                          ggc->keys);
   if (ret == SYSERR)
@@ -522,7 +561,7 @@
       unsigned int sizes;
       unsigned int timevect;
 
-      level = ntohl(value->anonymityLevel);
+      level = ntohl(value->anonymityLevel) - 1;
       if (OK != traffic->get(5 * cronSECONDS / TRAFFIC_TIME_UNIT, /* 
TTL_DECREMENT/TTU */
                             GAP_p2p_PROTO_RESULT,
                             TC_RECEIVED,
@@ -535,13 +574,22 @@
        return OK;
       }
       if (level > 1000) {
-       if (peers < level / 1000)
+       if (peers < level / 1000) {
+         LOG(LOG_DEBUG,
+             "Not enough cover traffic to satisfy anonymity requirements. 
Result dropped.\n");
          return OK;
-       if (count < level % 1000)
+       }
+       if (count < level % 1000) {
+         LOG(LOG_DEBUG,
+             "Not enough cover traffic to satisfy anonymity requirements. 
Result dropped.\n");
          return OK;
+       }
       } else {
-       if (count < level)
+       if (count < level) {
+         LOG(LOG_DEBUG,
+             "Not enough cover traffic to satisfy anonymity requirements. 
Result dropped.\n");
          return OK;
+       }
       }
     } else {
       /* traffic required by module not loaded;
@@ -671,7 +719,7 @@
     sizeof(Datastore_Value);
 
   if (ntohl(value->anonymityLevel) != 0) 
-    return OK;
+    return OK; /* do not allow anonymous content to leak through DHT */
   
   gw = MALLOC(size);
   gw->dc.size = htonl(size);
@@ -738,15 +786,22 @@
                                 unsigned int type,
                                 const HashCode160 * primaryKey) {
   HashCode160 q;
+  unsigned int t;
+  const GapWrapper * gw;
 
-  unsigned int t;
-  if ( (OK == getQueryFor(size,
-                         content,
+  if (size < sizeof(GapWrapper)) { 
+    BREAK();
+    return NO;
+  }
+  gw = (const GapWrapper*) content;
+  if ( (OK == getQueryFor(size - sizeof(GapWrapper),
+                         &gw[1],
                          &q)) &&
        (equalsHashCode160(&q,
                          primaryKey)) &&
        ( (type == ANY_BLOCK) ||
-        (type == (t = getTypeOfBlock(size, content) ) ) ) ) {
+        (type == (t = getTypeOfBlock(size - sizeof(GapWrapper), 
+                                     &gw[1]) ) ) ) ) {
     switch(type) {
     case D_BLOCK:
       return YES;

Modified: GNUnet/src/applications/fs/module/ondemand.c
===================================================================
--- GNUnet/src/applications/fs/module/ondemand.c        2005-02-08 19:39:58 UTC 
(rev 214)
+++ GNUnet/src/applications/fs/module/ondemand.c        2005-02-09 02:32:56 UTC 
(rev 215)
@@ -22,9 +22,6 @@
  * @file applications/afs/module/fileindex.c
  * @brief access to the list of indexed files
  * @author Christian Grothoff
- *
- * TODO:
- * - unindex
  */
 
 #include "platform.h"
@@ -41,6 +38,8 @@
 typedef struct {
   Datastore_Value header;
 
+  unsigned int type;
+
   /**
    * At what offset in the plaintext file is
    * this content stored?
@@ -159,6 +158,7 @@
   odb.header.prio = htonl(prio);
   odb.header.anonymityLevel = htonl(anonymityLevel);
   odb.header.expirationTime = htonll(expiration);
+  odb.type = htonl(ONDEMAND_BLOCK);
   odb.fileOffset = htonll(fileOffset);
   odb.blockSize = htonl(size - sizeof(DBlock));
   odb.fileId = *fileId;

Modified: GNUnet/src/applications/fs/module/querymanager.c
===================================================================
--- GNUnet/src/applications/fs/module/querymanager.c    2005-02-08 19:39:58 UTC 
(rev 214)
+++ GNUnet/src/applications/fs/module/querymanager.c    2005-02-09 02:32:56 UTC 
(rev 215)
@@ -136,6 +136,7 @@
   int i;
   ReplyContent * rc;
 
+  GNUNET_ASSERT(ntohl(value->size) > sizeof(Datastore_Value));
   MUTEX_LOCK(&queryManagerLock);
   for (i=trackerCount-1;i>=0;i--) {
     if ( (equalsHashCode160(&trackers[i]->query,
@@ -150,9 +151,16 @@
       memcpy(&rc[1],
             &value[1],
             ntohl(value->size) - sizeof(Datastore_Value));
+      LOG(LOG_DEBUG,
+         "Sending reply to client waiting in slot %u.\n",
+         i);
       coreAPI->sendToClient(trackers[i]->client,
                            &rc->header);
       FREE(rc);
+    } else {
+      LOG(LOG_DEBUG,
+         "Reply did not match request %u\n",
+         i);
     }
   }
   MUTEX_UNLOCK(&queryManagerLock);

Modified: GNUnet/src/applications/fs/tools/gnunet-insert.c
===================================================================
--- GNUnet/src/applications/fs/tools/gnunet-insert.c    2005-02-08 19:39:58 UTC 
(rev 214)
+++ GNUnet/src/applications/fs/tools/gnunet-insert.c    2005-02-09 02:32:56 UTC 
(rev 215)
@@ -628,8 +628,7 @@
                      topKeywordCnt,
                      (const char**) topKeywords);
   }
-  FREE(filename);
-
+  FREE(extractors);
   /* wait for completion */
   SEMAPHORE_DOWN(exitSignal);
   SEMAPHORE_FREE(exitSignal);

Modified: GNUnet/src/applications/gap/gap.c
===================================================================
--- GNUnet/src/applications/gap/gap.c   2005-02-08 19:39:58 UTC (rev 214)
+++ GNUnet/src/applications/gap/gap.c   2005-02-09 02:32:56 UTC (rev 215)
@@ -1356,7 +1356,8 @@
 
 struct qLRC {
   const PeerIdentity * sender;
-  int doForward;
+  DataContainer ** values;
+  unsigned int valueCount;
 };
 
 static int 
@@ -1377,23 +1378,15 @@
     if (equalsHashCode160(&hc,
                          &ite->seen[i]))
       return OK; /* drop, duplicate result! */
-  if (cls->sender != NULL)
-    queueReply(cls->sender,
-              primaryKey,
-              value);
-  /* even for local results, always do 'put' 
-     (at least to give back results to local client &
-      to update priority!) */
-  bs->put(bs->closure,
-         primaryKey,
-         value,
-         ite->priority);
-  if (uri(&value[1],
-         ntohl(value->size) - sizeof(DataContainer),
-         ite->type,
-         &ite->primaryKey))
-    cls->doForward = NO; /* we have the one and only answer,
-                           do not bother to forward... */
+
+  GROW(cls->values,
+       cls->valueCount,
+       cls->valueCount+1);
+  cls->values[cls->valueCount-1]
+    = MALLOC(ntohl(value->size));
+  memcpy(cls->values[cls->valueCount-1],
+        value,
+        ntohl(value->size));
   return OK;
 }
  
@@ -1421,6 +1414,14 @@
   IndirectionTableEntry * ite;
   int isRouted;
   struct qLRC cls;
+  int i;
+  int max;
+  int * perm;
+  int doForward;
+  
+  LOG(LOG_DEBUG,
+      "Executing request %u.\n",
+      query->queries[0].a);
 
   ite = &ROUTING_indTable_[computeRoutingIndex(&query->queries[0])];
   MUTEX_LOCK(&ite->lookup_exclusion); 
@@ -1431,18 +1432,20 @@
                      prio,
                      sender,
                      &isRouted,
-                     &cls.doForward); 
+                     &doForward); 
     } else {
       isRouted = NO;
-      cls.doForward = YES;
+      doForward = YES;
     }
   } else {
     isRouted = YES;
-    cls.doForward = YES;
+    doForward = YES;
   }
   if ( (policy & QUERY_FORWARD) == 0)
-    cls.doForward = NO;
+    doForward = NO;
 
+  cls.values = NULL;
+  cls.valueCount = 0;
   cls.sender = sender;
   if ( (isRouted == YES) && /* if we can't route, lookup useless! */
        ( (policy & QUERY_ANSWER) > 0) ) {
@@ -1455,11 +1458,54 @@
            (DataProcessor) &queryLocalResultCallback,
            &cls);
   }
+
+  if (cls.valueCount > 0) {
+    perm = permute(cls.valueCount);
+    max = getNetworkLoadDown();
+    if (max > 100)
+      max = 100;
+    if (max == -1)
+      max = 50; /* we don't know the load, assume middle-of-the-road */
+    max = max / 10; /* 1 reply per 10% free capacity */
+    max = 1 + (10 - max);
+    if (max > cls.valueCount)
+      max = cls.valueCount; /* can't send more back then
+                               what we have */
+    
+    for (i=0;i<cls.valueCount;i++) {
+      if (i < max) {
+       if (cls.sender != NULL)
+         queueReply(cls.sender,
+                    &query->queries[0],
+                    cls.values[perm[i]]);
+      }
+      /* even for local results, always do 'put' 
+        (at least to give back results to local client &
+        to update priority; but only do this for
+        the first result */
+      bs->put(bs->closure,
+             &query->queries[0],
+             cls.values[perm[i]],
+             ite->priority);
+      
+      if (uri(cls.values[perm[i]],
+             ntohl(cls.values[perm[i]]->size),
+             ite->type,
+             &query->queries[0]))
+       doForward = NO; /* we have the one and only answer,
+                               do not bother to forward... */
+      
+      FREE(cls.values[perm[i]]);
+    }
+  }
+
+
+
   MUTEX_UNLOCK(&ite->lookup_exclusion);
-  if (cls.doForward)
+  if (doForward)
     forwardQuery(query,
                 sender);
-  return cls.doForward; 
+  return doForward; 
 }
 
 /**
@@ -1615,7 +1661,8 @@
  * listening for these puts.
  *
  * @param type the type of the block that we're looking for
- * @param anonymityLevel how much cover traffic is required? 0 for none.
+ * @param anonymityLevel how much cover traffic is required? 1 for none
+ *        (0 does not require GAP, 1 requires GAP but no cover traffic)
  * @param keys the keys to query for
  * @param timeout how long to wait until this operation should
  *        automatically time-out
@@ -1647,6 +1694,7 @@
     unsigned int sizes;
     unsigned int timevect;
 
+    anonymityLevel--;
     if (traffic == NULL) {
       LOG(LOG_ERROR,
          _("Cover traffic requested but traffic service not loaded.  Rejecting 
request.\n"));
@@ -1664,13 +1712,22 @@
       return SYSERR;
     }
     if (anonymityLevel > 1000) {
-      if (peers < anonymityLevel / 1000)
+      if (peers < anonymityLevel / 1000) {
+       LOG(LOG_WARNING,
+           _("Cannot satisfy desired level of anonymity, ignoring 
request.\n"));
        return SYSERR;
-      if (count < anonymityLevel % 1000)
+      }
+      if (count < anonymityLevel % 1000) {
+       LOG(LOG_WARNING,
+           _("Cannot satisfy desired level of anonymity, ignoring 
request.\n"));
        return SYSERR;
+      }
     } else {
-      if (count < anonymityLevel)
+      if (count < anonymityLevel) {
+       LOG(LOG_WARNING,
+           _("Cannot satisfy desired level of anonymity, ignoring 
request.\n"));
        return SYSERR;
+      }
     }
   }
   

Modified: GNUnet/src/applications/sqstore_mysql/mysql.c
===================================================================
--- GNUnet/src/applications/sqstore_mysql/mysql.c       2005-02-08 19:39:58 UTC 
(rev 214)
+++ GNUnet/src/applications/sqstore_mysql/mysql.c       2005-02-09 02:32:56 UTC 
(rev 215)
@@ -181,30 +181,38 @@
  * order, assemble it into a Datastore_Datum representation.
  *
  */
-static Datastore_Datum * assembleDatum(MYSQL_ROW sql_row) {
+static Datastore_Datum * assembleDatum(MYSQL_RES * res,
+                                      MYSQL_ROW sql_row) {
   Datastore_Datum * datum;
   int contentSize;
+  unsigned long * lens;
   
   contentSize = atol(sql_row[0]) - sizeof(Datastore_Value);
   if (contentSize < 0)
     return NULL; /* error */
 
+  lens = mysql_fetch_lengths(res); 
+  if ( (lens[5] != sizeof(HashCode160)) ||
+       (lens[6] != contentSize) ) {
+    LOG(LOG_WARNING,
+       "SQL Database corrupt, ignoring result.\n");
+    return NULL;
+  }
+
   datum = MALLOC(sizeof(Datastore_Datum) + contentSize);
   datum->value.size = htonl(contentSize + sizeof(Datastore_Value));
   datum->value.type = htonl(atol(sql_row[1]));
   datum->value.prio = htonl(atol(sql_row[2]));
-  datum->value.anonymityLevel = atol(sql_row[3]);
+  datum->value.anonymityLevel = htonl(atol(sql_row[3]));
   datum->value.expirationTime = htonll(atoll(sql_row[4]));
 
   memcpy(&datum->key,
         sql_row[5],
         sizeof(HashCode160)); 
-
-  /* NOTE: assumes the db is not corrupt ... */
   memcpy(&datum[1], 
          sql_row[6],
         contentSize);
-  return(datum);
+  return datum;
 }
 
 /**
@@ -240,7 +248,7 @@
     dbhI->dbf = NULL;
     return SYSERR;
   }    
-  MUTEX_CREATE_RECURSIVE(&dbhI->DATABASE_Lock_);
+  MUTEX_CREATE(&dbhI->DATABASE_Lock_);
   return OK;
 }
 
@@ -315,7 +323,8 @@
   }
 
   while ((sql_row=mysql_fetch_row(sql_res))) {   
-    datum = assembleDatum(sql_row);
+    datum = assembleDatum(sql_res,
+                         sql_row);
     if (datum == NULL) {
       LOG(LOG_WARNING,
          _("Invalid data in MySQL database.  Please verify integrity!\n"));
@@ -398,7 +407,8 @@
   }
 
   while ((sql_row=mysql_fetch_row(sql_res))) {   
-    datum = assembleDatum(sql_row);
+    datum = assembleDatum(sql_res,
+                         sql_row);
     if (datum == NULL) {
       LOG(LOG_WARNING,
          _("Invalid data in MySQL database.  Please verify integrity!\n"));
@@ -502,16 +512,23 @@
     if(count == SYSERR) /* we are not allowed to break under mysql_use_result 
*/
       continue;
 
-    if(iter!=NULL) {
+    if (iter!=NULL) {
       Datastore_Datum * datum;
 
-      datum = assembleDatum(sql_row);
+      datum = assembleDatum(sql_res,
+                           sql_row);
       if (datum == NULL) {
        LOG(LOG_WARNING,
            _("Invalid data in MySQL database.  Please verify integrity!\n"));
        continue; 
       }
-      if( SYSERR == iter(&datum->key,&datum->value, closure) ) {
+      LOG(LOG_DEBUG,
+         "Found in database block with type %u.\n",
+         ntohl(*(int*)&((&datum->value)[1])));
+      
+      if( SYSERR == iter(&datum->key,
+                        &datum->value, 
+                        closure) ) {
         count = SYSERR;
        FREE(datum);
        break;
@@ -556,6 +573,9 @@
   mysql_escape_string(escapedHash, 
                      (char *)key, 
                      sizeof(HashCode160));
+  LOG(LOG_DEBUG,
+      "Storing in database block with type %u.\n",
+      ntohl(*(int*)&value[1]));
   escapedBlock = MALLOC(2*contentSize+1);
   mysql_escape_string(escapedBlock, 
                      (char *)&value[1],
@@ -572,7 +592,7 @@
           ntohl(value->size),
           ntohl(value->type),
           ntohl(value->prio),
-          value->anonymityLevel,
+          ntohl(value->anonymityLevel),
           ntohll(value->expirationTime),
           escapedHash,
           escapedBlock);
@@ -633,17 +653,21 @@
             " AND anonLevel=%u AND expire=%lld"
             " AND value='%s'",
             escapedHash,
-            ntohl(value->size), ntohl(value->type), ntohl(value->prio),
-            value->anonymityLevel, ntohll(value->expirationTime),
-            escapedBlock
-            );
+            ntohl(value->size),
+            ntohl(value->type),
+            ntohl(value->prio),
+            ntohl(value->anonymityLevel), 
+            ntohll(value->expirationTime),
+            escapedBlock);
   }
   mysql_query(dbh->dbf, scratch);
   FREE(escapedHash);
   FREE(escapedBlock);
   FREE(scratch);
   if(mysql_error(dbh->dbf)[0]) {
-    LOG_MYSQL(LOG_ERROR, "mysql_query", dbh);
+    LOG_MYSQL(LOG_ERROR, 
+             "mysql_query", 
+             dbh);
     MUTEX_UNLOCK(&dbh->DATABASE_Lock_);
     return SYSERR;
   }

Modified: GNUnet/src/util/tcpio.c
===================================================================
--- GNUnet/src/util/tcpio.c     2005-02-08 19:39:58 UTC (rev 214)
+++ GNUnet/src/util/tcpio.c     2005-02-09 02:32:56 UTC (rev 215)
@@ -188,6 +188,7 @@
   timeout.tv_usec = 0;
   ret = SELECT(sock->socket+1, &rset, &wset, &eset, &timeout);
   if ( (ret == -1) ||
+       (sock->socket == -1) ||
        (! FD_ISSET(sock->socket,
                   &wset)) ) {
     LOG(LOG_INFO,

Modified: GNUnet/todo
===================================================================
--- GNUnet/todo 2005-02-08 19:39:58 UTC (rev 214)
+++ GNUnet/todo 2005-02-09 02:32:56 UTC (rev 215)
@@ -8,12 +8,17 @@
 - 593???
 
 0.7.0pre0 [3'05] (aka "pre-preview"):
+- Investigate KBlocks:
+  generated public keys are fishy 
+  (far to many 0-values in N!)
 - Need testing:
+  * gnunet-insert
+  * gnunet-search
+  * gnunet-download
+  * FS/ECRS upload/download
   * ECRS-directories (build, iterate)
-  * FS/ECRS upload/download
   * gnunet-directory
   * gnunet-pseudonym
-  * gnunet-search
 
 0.7.0pre1 [4'05] (aka "preview"):
 - topology: do aggressive bootstrap on first start (Christian) [ easy ]





reply via email to

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