- Fixed some bugs in monitor code
authorBart Polot <bart@net.in.tum.de>
Thu, 5 Jan 2012 20:00:45 +0000 (20:00 +0000)
committerBart Polot <bart@net.in.tum.de>
Thu, 5 Jan 2012 20:00:45 +0000 (20:00 +0000)
src/dht/dht_api.c
src/dht/gnunet-service-dht_clients.c

index a49af335bd6b97889e9b288758479dcadca91df6..353620960ccdb3c7850314adec9e36de911644cd 100644 (file)
@@ -634,7 +634,11 @@ service_message_handler (void *cls, const struct GNUNET_MessageHeader *msg)
   if (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_DHT_CLIENT_RESULT)
   {
     if (process_monitor_message (handle, msg) == GNUNET_OK)
+    {
+      GNUNET_CLIENT_receive (handle->client, &service_message_handler, handle,
+                             GNUNET_TIME_UNIT_FOREVER_REL);
       return;
+    }
     GNUNET_break (0);
     do_disconnect (handle);
     return;
@@ -965,6 +969,7 @@ GNUNET_DHT_monitor_start (struct GNUNET_DHT_Handle *handle,
   struct GNUNET_DHT_MonitorMessage *m;
   struct PendingMessage *pending;
 
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "monitor start\n");
   h = GNUNET_malloc (sizeof (struct GNUNET_DHT_MonitorHandle));
   GNUNET_CONTAINER_DLL_insert(handle->monitor_head, handle->monitor_tail, h);
 
@@ -985,6 +990,11 @@ GNUNET_DHT_monitor_start (struct GNUNET_DHT_Handle *handle,
   pending->msg = &m->header;
   pending->handle = handle;
   pending->free_on_send = GNUNET_YES;
+  m->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET);
+  m->header.size = htons (sizeof (struct GNUNET_DHT_MonitorMessage));
+  m->type = htonl(type);
+  if (NULL != key)
+    memcpy (&m->key, key, sizeof(GNUNET_HashCode));
   GNUNET_CONTAINER_DLL_insert (handle->pending_head, handle->pending_tail,
                                pending);
   pending->in_pending_queue = GNUNET_YES;
index 7642dc6c3d43004262d47628413e8f01b6946164..2c013b38f1a8be981052a2f36a3a53ee71f372e1 100644 (file)
@@ -666,7 +666,9 @@ handle_dht_local_monitor (void *cls, struct GNUNET_SERVER_Client *client,
     r->key = GNUNET_malloc (sizeof (GNUNET_HashCode));
     memcpy (r->key, &msg->key, sizeof (GNUNET_HashCode));
   }
-
+  GNUNET_CONTAINER_DLL_insert (monitor_head, monitor_tail, r);
+  // FIXME add remove somewhere
+  GNUNET_SERVER_receive_done (client, GNUNET_OK);
 }
 
 
@@ -1061,7 +1063,7 @@ GDS_CLIENTS_process_monitor (uint16_t mtype,
   cl_size = 0;
   for (m = monitor_head; NULL != m; m = m->next)
   {
-    if (m->type == type &&
+    if ((GNUNET_BLOCK_TYPE_ANY == m->type || m->type == type) &&
         (NULL == m->key ||
          memcmp (key, m->key, sizeof(GNUNET_HashCode)) == 0))
     {