gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r3446 - in GNUnet/src: applications/dht/module applications


From: grothoff
Subject: [GNUnet-SVN] r3446 - in GNUnet/src: applications/dht/module applications/dht/tools applications/stats util/error
Date: Sun, 8 Oct 2006 00:38:08 -0700 (PDT)

Author: grothoff
Date: 2006-10-08 00:38:04 -0700 (Sun, 08 Oct 2006)
New Revision: 3446

Modified:
   GNUnet/src/applications/dht/module/dht.c
   GNUnet/src/applications/dht/tools/dht_api.c
   GNUnet/src/applications/dht/tools/dhttest2.c
   GNUnet/src/applications/stats/clientapi.c
   GNUnet/src/util/error/error.c
Log:
fixes

Modified: GNUnet/src/applications/dht/module/dht.c
===================================================================
--- GNUnet/src/applications/dht/module/dht.c    2006-10-08 06:18:48 UTC (rev 
3445)
+++ GNUnet/src/applications/dht/module/dht.c    2006-10-08 07:38:04 UTC (rev 
3446)
@@ -60,7 +60,7 @@
 #define DEBUG_DHT YES
 
 #if DEBUG_DHT
-#define ENTER() GE_LOG(ectx, GE_REQUEST | GE_DEVELOPER | GE_DEBUG, "Entering 
method %s at %s:%d.\n", __FUNCTION__, __FILE__, __LINE__)
+#define ENTER() GE_LOG(ectx, GE_REQUEST | GE_DEVELOPER | GE_USER | GE_DEBUG, 
"Entering method %s at %s:%d.\n", __FUNCTION__, __FILE__, __LINE__)
 #else
 #define ENTER() do {} while (0)
 #endif
@@ -1597,17 +1597,19 @@
   IF_GELOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
        hash2enc(table,
                 &enc2));
-  GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
-      "performing `%s' operation on key `%s' and table `%s'.\n",
-      "DHT_GET",
-      &enc,
-      &enc2);
+  GE_LOG(ectx, 
+        GE_DEBUG | GE_REQUEST | GE_USER,
+        "performing `%s' operation on key `%s' and table `%s'.\n",
+        "DHT_GET",
+        &enc,
+        &enc2);
 #endif
 
   if (timeout > 1 * cronHOURS) {
-    GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
-       _("`%s' called with timeout above 1 hour (bug?)\n"),
-       __FUNCTION__);
+    GE_LOG(ectx,
+          GE_WARNING | GE_BULK | GE_USER,
+          _("`%s' called with timeout above 1 hour (bug?)\n"),
+          __FUNCTION__);
     timeout = 1 * cronHOURS;
   }
 
@@ -1636,13 +1638,15 @@
   if (ltd != NULL) {
     PeerIdentity * hosts;
 #if DEBUG_DHT
-    IF_GELOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
-         hash2enc(table,
-                  &enc));
-    GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
-       "I participate in the table `%s' for the `%s' operation.\n",
-       &enc,
-       "DHT_GET");
+    IF_GELOG(ectx,
+            GE_DEBUG | GE_REQUEST | GE_USER,
+            hash2enc(table,
+                     &enc));
+    GE_LOG(ectx, 
+          GE_DEBUG | GE_REQUEST | GE_USER,
+          "I participate in the table `%s' for the `%s' operation.\n",
+          &enc,
+          "DHT_GET");
 #endif
     /* We do participate in the table, it is fair to assume
        that we know the relevant peers in my neighbour set */
@@ -2289,7 +2293,8 @@
 static void
 dht_put_async_timeout(void * cls) {
   struct DHT_PUT_RECORD * dpr = cls;
-  dpr->callback(dpr->closure);
+  if (dpr->callback != NULL)
+    dpr->callback(dpr->closure);
   delAbortJob(&dht_put_async_timeout, cls);
 }
 
@@ -2793,7 +2798,8 @@
     return SYSERR;
   }
   old = tables[i];
-  tables[i] = tables[tablesCount-1];
+  if (tablesCount > 1)
+    tables[i] = tables[tablesCount-1];
   GROW(tables,
        tablesCount,
        tablesCount-1);
@@ -3003,6 +3009,7 @@
   unsigned int keysLength;
   unsigned int dataLength;
   RPC_DHT_FindValue_Context * fw_context;
+  RPC_Param * results;
 
   ENTER();
   processOptionalFields(sender, arguments);
@@ -3027,15 +3034,23 @@
                                   &dataLength,
                                   (void**) &type)) ||
        (dataLength != sizeof(unsigned int)) ) {
-    GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
-       _("Received invalid RPC `%s'.\n"),
-       "DHT_findValue");
+    GE_LOG(ectx,
+          GE_WARNING | GE_BULK | GE_USER,
+          _("Received invalid RPC `%s'.\n"),
+          "DHT_findValue");
+    RPC_paramFree(arguments);
+    results = RPC_paramNew();
+    if (callback != NULL)
+      callback(results,
+              SYSERR,
+              rpc_context);
+    RPC_paramFree(results);
     return;
   }
-
   fw_context
     = MALLOC(sizeof(RPC_DHT_FindValue_Context));
-  fw_context->lock = MUTEX_CREATE(YES);
+  fw_context->lock 
+    = MUTEX_CREATE(YES);
   fw_context->count
     = 0;
   fw_context->done
@@ -3056,6 +3071,7 @@
                          fw_context,
                          (DHT_OP_Complete) &rpc_dht_findValue_complete,
                          fw_context);
+  RPC_paramFree(arguments);
   addAbortJob((CronJob)&rpc_DHT_findValue_abort,
              fw_context);
   cron_add_job(coreAPI->cron,
@@ -3137,6 +3153,7 @@
   unsigned long long * timeout;
   RPC_DHT_store_Context * fw_context;
   LocalTableData * ltd;
+  RPC_Param * results;
 
   ENTER();
   processOptionalFields(sender, arguments);
@@ -3158,9 +3175,17 @@
        (dataLength != sizeof(unsigned long long)) ||
        ((NULL == (value = RPC_paramDataContainerByName(arguments,
                                                       "value")))) ) {
-    GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
-       _("Received invalid RPC `%s'.\n"),
-       "DHT_store");
+    GE_LOG(ectx,
+          GE_WARNING | GE_BULK | GE_USER,
+          _("Received invalid RPC `%s'.\n"),
+          "DHT_store");
+    RPC_paramFree(arguments);
+    results = RPC_paramNew();
+    if (callback != NULL)
+      callback(results,
+              SYSERR,
+              rpc_context);
+    RPC_paramFree(results);
     return;
   }
 
@@ -3188,6 +3213,7 @@
                          value,
                          (DHT_OP_Complete) &rpc_dht_store_callback,
                          fw_context);
+  RPC_paramFree(arguments);
   addAbortJob(&rpc_DHT_store_abort,
              fw_context);
   cron_add_job(coreAPI->cron,
@@ -3277,6 +3303,7 @@
   unsigned long long * timeout;
   RPC_DHT_remove_Context * fw_context;
   LocalTableData * ltd;
+  RPC_Param * results;
 
   ENTER();
   processOptionalFields(sender, arguments);
@@ -3296,9 +3323,17 @@
                                   &dataLength,
                                   (void**) &timeout)) ||
        (dataLength != sizeof(unsigned long long)) ) {
-    GE_LOG(ectx, GE_WARNING | GE_BULK | GE_USER,
-       _("Received invalid RPC `%s'.\n"),
-       "DHT_remove");
+    GE_LOG(ectx,
+          GE_WARNING | GE_BULK | GE_USER,
+          _("Received invalid RPC `%s'.\n"),
+          "DHT_remove");
+    RPC_paramFree(arguments);
+    results = RPC_paramNew();
+    if (callback != NULL)
+      callback(results,
+              SYSERR,
+              rpc_context);
+    RPC_paramFree(results);
     return;
   }
 
@@ -3328,6 +3363,7 @@
                             value,
                             (DHT_OP_Complete) &rpc_dht_remove_callback,
                             fw_context);
+  RPC_paramFree(arguments);
   addAbortJob((CronJob)&rpc_DHT_remove_abort,
              fw_context);
   cron_add_job(coreAPI->cron,

Modified: GNUnet/src/applications/dht/tools/dht_api.c
===================================================================
--- GNUnet/src/applications/dht/tools/dht_api.c 2006-10-08 06:18:48 UTC (rev 
3445)
+++ GNUnet/src/applications/dht/tools/dht_api.c 2006-10-08 07:38:04 UTC (rev 
3446)
@@ -188,10 +188,10 @@
     ok = NO;
     /* send 'join' message via socket! */
     if (OK == connection_write(list->sock,
-                           &req.header)) {
+                              &req.header)) {
       reply = NULL;
       if (OK == connection_read(list->sock,
-                              &reply)) {
+                               &reply)) {
        if (OK == checkACK(reply))
          ok = YES;
        FREENONNULL(reply);
@@ -721,10 +721,11 @@
   MESSAGE_HEADER * reply;
   int ret;
 
-  GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
-      "DHT_LIB_put called with value '%.*s'\n",
-      ntohl(value->size),
-      &value[1]);
+  GE_LOG(ectx, 
+        GE_DEBUG | GE_REQUEST | GE_USER,
+        "DHT_LIB_put called with value '%.*s'\n",
+        ntohl(value->size),
+        &value[1]);
 
   sock = client_connection_create(ectx,
                                  cfg);

Modified: GNUnet/src/applications/dht/tools/dhttest2.c
===================================================================
--- GNUnet/src/applications/dht/tools/dhttest2.c        2006-10-08 06:18:48 UTC 
(rev 3445)
+++ GNUnet/src/applications/dht/tools/dhttest2.c        2006-10-08 07:38:04 UTC 
(rev 3446)
@@ -48,8 +48,10 @@
   return OK;
 }
 
-#define START_PEERS 1
+#define START_PEERS 0
 
+#define DO_FORK 0
+
 #define CHECK(a) do { if (!(a)) { ret = 1; GE_BREAK(ectx, 0); goto FAILURE; } 
} while(0)
 
 #define CHECK2(a) do { if (!(a)) { ret = 1; GE_BREAK(ectx, 0); goto FAILURE2; 
} } while(0)
@@ -60,11 +62,15 @@
  */
 int main(int argc,
         const char ** argv) {
+#if START_PEERS
   pid_t daemon1;
   pid_t daemon2;
+#endif
   pid_t sto2;
   int ret;
+#if DO_FORK
   int status;
+#endif
   struct ClientServerConnection * sock;
   int left;
   DHT_TableId table;
@@ -74,6 +80,7 @@
   struct GE_Context * ectx;
   struct GC_Configuration * cfg;
 
+  ectx = NULL;
   enc2hash("BV3AS3KMIIBVIFCGEG907N6NTDTH26B7T6FODUSLSGK"
           "5B2Q58IEU1VF5FTR838449CSHVBOAHLDVQAOA33O77F"
           "OPDA8F1VIKESLSNBO",
@@ -176,7 +183,11 @@
   store = create_blockstore_memory(65536);
 
   /* actual test code */
+#if DO_FORK
   sto2 = fork();
+#else
+  sto2 = argc == 1;
+#endif
   if (sto2 == 0) {
     /* switch to peer2 */
     GC_set_configuration_value_number(cfg,
@@ -273,11 +284,12 @@
   printf("Peer1 tests successful, shutting down.\n");
   DHT_LIB_leave(&table);
   destroy_blockstore_memory(store);
-
+#if DO_FORK
   if (sto2 != waitpid(sto2, &status, 0))
     GE_DIE_STRERROR(ectx,
                    GE_FATAL | GE_USER | GE_IMMEDIATE,
                    "waitpid");
+#endif
   /* end of actual test code */
 
  FAILURE:

Modified: GNUnet/src/applications/stats/clientapi.c
===================================================================
--- GNUnet/src/applications/stats/clientapi.c   2006-10-08 06:18:48 UTC (rev 
3445)
+++ GNUnet/src/applications/stats/clientapi.c   2006-10-08 07:38:04 UTC (rev 
3446)
@@ -158,18 +158,18 @@
                                 &csHdr))
     return SYSERR;
   statMsg
-    = MALLOC(MAX_BUFFER_SIZE);
+    = MALLOC(sizeof(CS_stats_reply_MESSAGE));
   statMsg->totalCounters
     = htonl(1); /* to ensure we enter the loop */
   count = 0;
   while ( count < ntohl(statMsg->totalCounters) ) {
+    FREE(statMsg);
+    statMsg = NULL;
     /* printf("reading from socket starting %u of %d\n",
        count, ntohl(statMsg->totalCounters) );*/
     if (SYSERR == connection_read(sock,
-                                 (MESSAGE_HEADER**)&statMsg)) {
-      FREE(statMsg);
-      return SYSERR;
-    }
+                                 (MESSAGE_HEADER**)&statMsg)) 
+      return SYSERR;    
     if (ntohs(statMsg->header.size) < sizeof(CS_stats_reply_MESSAGE)) {
       GE_BREAK(ectx, 0);
       ret = SYSERR;

Modified: GNUnet/src/util/error/error.c
===================================================================
--- GNUnet/src/util/error/error.c       2006-10-08 06:18:48 UTC (rev 3445)
+++ GNUnet/src/util/error/error.c       2006-10-08 07:38:04 UTC (rev 3446)
@@ -77,8 +77,8 @@
   vsnprintf(buf, size, message, va);
   va_end(va);
   time(&timetmp);
+  memset(date, 0, 64);
   tmptr = localtime(&timetmp);
-  memset(date, 0, 64);
   strftime(date,
           64,
           "%b %d %H:%M:%S",
@@ -88,11 +88,18 @@
                 kind,
                 date,
                 buf);
-  else
+  else {
+    printf("!\n");
+    printf(date);
+    printf("\n");
+    printf(buf);
     fprintf(stderr,
+           "X!\n");
+    fprintf(stderr,
            "%s %s", 
            date,
            buf);
+  }
   free(buf);
 }
 





reply via email to

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