gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r8156 - in GNUnet/src/applications/dht: module tools
Date: Sun, 1 Feb 2009 00:29:53 -0700 (MST)

Author: grothoff
Date: 2009-02-01 00:29:53 -0700 (Sun, 01 Feb 2009)
New Revision: 8156

Modified:
   GNUnet/src/applications/dht/module/cs.c
   GNUnet/src/applications/dht/tools/Makefile.am
   GNUnet/src/applications/dht/tools/dht_api.c
Log:
wait for PUT to be handled by core

Modified: GNUnet/src/applications/dht/module/cs.c
===================================================================
--- GNUnet/src/applications/dht/module/cs.c     2009-02-01 07:29:34 UTC (rev 
8155)
+++ GNUnet/src/applications/dht/module/cs.c     2009-02-01 07:29:53 UTC (rev 
8156)
@@ -90,7 +90,7 @@
   size = ntohs (req->header.size) - sizeof (CS_dht_request_put_MESSAGE);
   GNUNET_GE_ASSERT (NULL, size < GNUNET_MAX_BUFFER_SIZE);
   dhtAPI->put (&req->key, ntohl (req->type), size, (const char *) &req[1]);
-  return GNUNET_OK;
+  return  coreAPI->cs_send_value (client, GNUNET_OK);
 }
 
 static int

Modified: GNUnet/src/applications/dht/tools/Makefile.am
===================================================================
--- GNUnet/src/applications/dht/tools/Makefile.am       2009-02-01 07:29:34 UTC 
(rev 8155)
+++ GNUnet/src/applications/dht/tools/Makefile.am       2009-02-01 07:29:53 UTC 
(rev 8156)
@@ -15,6 +15,7 @@
 libgnunetdht_api_la_LDFLAGS = \
   $(GN_LIB_LDFLAGS)
 libgnunetdht_api_la_LIBADD = \
+  $(top_builddir)/src/applications/stats/libgnunetstats_api.la \
   $(top_builddir)/src/util/libgnunetutil.la \
   $(GN_LIBINTL)
 

Modified: GNUnet/src/applications/dht/tools/dht_api.c
===================================================================
--- GNUnet/src/applications/dht/tools/dht_api.c 2009-02-01 07:29:34 UTC (rev 
8155)
+++ GNUnet/src/applications/dht/tools/dht_api.c 2009-02-01 07:29:53 UTC (rev 
8156)
@@ -27,6 +27,7 @@
 #include "gnunet_protocols.h"
 #include "dht.h"
 #include "gnunet_dht_lib.h"
+#include "gnunet_stats_lib.h"
 #include "gnunet_util.h"
 
 #define DEBUG_DHT_API GNUNET_NO
@@ -299,6 +300,7 @@
   struct GNUNET_ClientServerConnection *sock;
   CS_dht_request_put_MESSAGE *req;
   int ret;
+  int ret2;
 
 #if DEBUG_DHT_API
   GNUNET_GE_LOG (ectx,
@@ -315,9 +317,41 @@
   req->type = htonl (type);
   memcpy (&req[1], value, size);
   ret = GNUNET_client_connection_write (sock, &req->header);
+  if ( (GNUNET_OK != GNUNET_client_connection_read_result (sock, &ret2)) ||
+       (ret2 != GNUNET_OK) )    
+    ret = GNUNET_SYSERR;
   GNUNET_client_connection_destroy (sock);
   GNUNET_free (req);
   return ret;
 }
 
+static int
+waitForConnect (const char *name, unsigned long long value, void *cls)
+{
+  unsigned long long * ok = cls;
+  if ((value > 0) && (0 == strcmp (_("# dht connections"), name)))
+    {
+      *ok = value;
+      return GNUNET_SYSERR;
+    }
+  return GNUNET_OK;
+}
+
+/**
+ * Check if this peer has DHT connections to 
+ * any other peer.
+ *
+ * @param sock connection to gnunetd
+ * @return number of connections
+ */
+unsigned long long
+GNUNET_DHT_test_connected(struct GNUNET_ClientServerConnection *sock)
+{
+  unsigned long long ret;
+
+  GNUNET_STATS_get_statistics (NULL, sock, &waitForConnect, &ret);
+  return ret; 
+}
+
+
 /* end of dht_api.c */





reply via email to

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