aboutsummaryrefslogtreecommitdiff
path: root/src/dht
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2012-01-05 20:00:45 +0000
committerBart Polot <bart@net.in.tum.de>2012-01-05 20:00:45 +0000
commitfca364b9a6259f8e802ca118d069eecacf625064 (patch)
treebe2aaa67805b79fa44e95d25ec34dae81aeb4675 /src/dht
parentc84257c7030b727a09ac92b295f404077969ad0c (diff)
downloadgnunet-fca364b9a6259f8e802ca118d069eecacf625064.tar.gz
gnunet-fca364b9a6259f8e802ca118d069eecacf625064.zip
- Fixed some bugs in monitor code
Diffstat (limited to 'src/dht')
-rw-r--r--src/dht/dht_api.c10
-rw-r--r--src/dht/gnunet-service-dht_clients.c6
2 files changed, 14 insertions, 2 deletions
diff --git a/src/dht/dht_api.c b/src/dht/dht_api.c
index a49af335b..353620960 100644
--- a/src/dht/dht_api.c
+++ b/src/dht/dht_api.c
@@ -634,7 +634,11 @@ service_message_handler (void *cls, const struct GNUNET_MessageHeader *msg)
634 if (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_DHT_CLIENT_RESULT) 634 if (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_DHT_CLIENT_RESULT)
635 { 635 {
636 if (process_monitor_message (handle, msg) == GNUNET_OK) 636 if (process_monitor_message (handle, msg) == GNUNET_OK)
637 {
638 GNUNET_CLIENT_receive (handle->client, &service_message_handler, handle,
639 GNUNET_TIME_UNIT_FOREVER_REL);
637 return; 640 return;
641 }
638 GNUNET_break (0); 642 GNUNET_break (0);
639 do_disconnect (handle); 643 do_disconnect (handle);
640 return; 644 return;
@@ -965,6 +969,7 @@ GNUNET_DHT_monitor_start (struct GNUNET_DHT_Handle *handle,
965 struct GNUNET_DHT_MonitorMessage *m; 969 struct GNUNET_DHT_MonitorMessage *m;
966 struct PendingMessage *pending; 970 struct PendingMessage *pending;
967 971
972 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "monitor start\n");
968 h = GNUNET_malloc (sizeof (struct GNUNET_DHT_MonitorHandle)); 973 h = GNUNET_malloc (sizeof (struct GNUNET_DHT_MonitorHandle));
969 GNUNET_CONTAINER_DLL_insert(handle->monitor_head, handle->monitor_tail, h); 974 GNUNET_CONTAINER_DLL_insert(handle->monitor_head, handle->monitor_tail, h);
970 975
@@ -985,6 +990,11 @@ GNUNET_DHT_monitor_start (struct GNUNET_DHT_Handle *handle,
985 pending->msg = &m->header; 990 pending->msg = &m->header;
986 pending->handle = handle; 991 pending->handle = handle;
987 pending->free_on_send = GNUNET_YES; 992 pending->free_on_send = GNUNET_YES;
993 m->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_MONITOR_GET);
994 m->header.size = htons (sizeof (struct GNUNET_DHT_MonitorMessage));
995 m->type = htonl(type);
996 if (NULL != key)
997 memcpy (&m->key, key, sizeof(GNUNET_HashCode));
988 GNUNET_CONTAINER_DLL_insert (handle->pending_head, handle->pending_tail, 998 GNUNET_CONTAINER_DLL_insert (handle->pending_head, handle->pending_tail,
989 pending); 999 pending);
990 pending->in_pending_queue = GNUNET_YES; 1000 pending->in_pending_queue = GNUNET_YES;
diff --git a/src/dht/gnunet-service-dht_clients.c b/src/dht/gnunet-service-dht_clients.c
index 7642dc6c3..2c013b38f 100644
--- a/src/dht/gnunet-service-dht_clients.c
+++ b/src/dht/gnunet-service-dht_clients.c
@@ -666,7 +666,9 @@ handle_dht_local_monitor (void *cls, struct GNUNET_SERVER_Client *client,
666 r->key = GNUNET_malloc (sizeof (GNUNET_HashCode)); 666 r->key = GNUNET_malloc (sizeof (GNUNET_HashCode));
667 memcpy (r->key, &msg->key, sizeof (GNUNET_HashCode)); 667 memcpy (r->key, &msg->key, sizeof (GNUNET_HashCode));
668 } 668 }
669 669 GNUNET_CONTAINER_DLL_insert (monitor_head, monitor_tail, r);
670 // FIXME add remove somewhere
671 GNUNET_SERVER_receive_done (client, GNUNET_OK);
670} 672}
671 673
672 674
@@ -1061,7 +1063,7 @@ GDS_CLIENTS_process_monitor (uint16_t mtype,
1061 cl_size = 0; 1063 cl_size = 0;
1062 for (m = monitor_head; NULL != m; m = m->next) 1064 for (m = monitor_head; NULL != m; m = m->next)
1063 { 1065 {
1064 if (m->type == type && 1066 if ((GNUNET_BLOCK_TYPE_ANY == m->type || m->type == type) &&
1065 (NULL == m->key || 1067 (NULL == m->key ||
1066 memcmp (key, m->key, sizeof(GNUNET_HashCode)) == 0)) 1068 memcmp (key, m->key, sizeof(GNUNET_HashCode)) == 0))
1067 { 1069 {