diff options
author | Bart Polot <bart@net.in.tum.de> | 2012-05-04 12:57:06 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2012-05-04 12:57:06 +0000 |
commit | c0953e20856f7c29e15ef1d8bfbb308c8fecc6d6 (patch) | |
tree | 51c3599f426f88fd117eea2826b0f16e8d8d4811 /src/dht/dht_api.c | |
parent | 5cb80076be6f79e7bd58cc9e765bceec372b6e8b (diff) | |
download | gnunet-c0953e20856f7c29e15ef1d8bfbb308c8fecc6d6.tar.gz gnunet-c0953e20856f7c29e15ef1d8bfbb308c8fecc6d6.zip |
Added stop operation for dht monitoring
Diffstat (limited to 'src/dht/dht_api.c')
-rw-r--r-- | src/dht/dht_api.c | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/src/dht/dht_api.c b/src/dht/dht_api.c index 37b65b022..131070302 100644 --- a/src/dht/dht_api.c +++ b/src/dht/dht_api.c | |||
@@ -1275,7 +1275,7 @@ GNUNET_DHT_monitor_start (struct GNUNET_DHT_Handle *handle, | |||
1275 | void *cb_cls) | 1275 | void *cb_cls) |
1276 | { | 1276 | { |
1277 | struct GNUNET_DHT_MonitorHandle *h; | 1277 | struct GNUNET_DHT_MonitorHandle *h; |
1278 | struct GNUNET_DHT_MonitorStartMessage *m; | 1278 | struct GNUNET_DHT_MonitorStartStopMessage *m; |
1279 | struct PendingMessage *pending; | 1279 | struct PendingMessage *pending; |
1280 | 1280 | ||
1281 | h = GNUNET_malloc (sizeof (struct GNUNET_DHT_MonitorHandle)); | 1281 | h = GNUNET_malloc (sizeof (struct GNUNET_DHT_MonitorHandle)); |
@@ -1293,20 +1293,20 @@ GNUNET_DHT_monitor_start (struct GNUNET_DHT_Handle *handle, | |||
1293 | memcpy (h->key, key, sizeof(GNUNET_HashCode)); | 1293 | memcpy (h->key, key, sizeof(GNUNET_HashCode)); |
1294 | } | 1294 | } |
1295 | 1295 | ||
1296 | pending = GNUNET_malloc (sizeof (struct GNUNET_DHT_MonitorStartMessage) + | 1296 | pending = GNUNET_malloc (sizeof (struct GNUNET_DHT_MonitorStartStopMessage) + |
1297 | sizeof (struct PendingMessage)); | 1297 | sizeof (struct PendingMessage)); |
1298 | m = (struct GNUNET_DHT_MonitorStartMessage *) &pending[1]; | 1298 | m = (struct GNUNET_DHT_MonitorStartStopMessage *) &pending[1]; |
1299 | pending->msg = &m->header; | 1299 | pending->msg = &m->header; |
1300 | pending->handle = handle; | 1300 | pending->handle = handle; |
1301 | pending->free_on_send = GNUNET_YES; | 1301 | pending->free_on_send = GNUNET_YES; |
1302 | m->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_MONITOR_START); | 1302 | m->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_MONITOR_START); |
1303 | m->header.size = htons (sizeof (struct GNUNET_DHT_MonitorStartMessage)); | 1303 | m->header.size = htons (sizeof (struct GNUNET_DHT_MonitorStartStopMessage)); |
1304 | m->type = htonl(type); | 1304 | m->type = htonl(type); |
1305 | m->get = (NULL != get_cb); | 1305 | m->get = htons(NULL != get_cb); |
1306 | m->get_resp = (NULL != get_resp_cb); | 1306 | m->get_resp = htons(NULL != get_resp_cb); |
1307 | m->put = (NULL != put_cb); | 1307 | m->put = htons(NULL != put_cb); |
1308 | if (NULL != key) { | 1308 | if (NULL != key) { |
1309 | m->filter_key = 1; | 1309 | m->filter_key = htons(1); |
1310 | memcpy (&m->key, key, sizeof(GNUNET_HashCode)); | 1310 | memcpy (&m->key, key, sizeof(GNUNET_HashCode)); |
1311 | } | 1311 | } |
1312 | GNUNET_CONTAINER_DLL_insert (handle->pending_head, handle->pending_tail, | 1312 | GNUNET_CONTAINER_DLL_insert (handle->pending_head, handle->pending_tail, |
@@ -1328,11 +1328,36 @@ GNUNET_DHT_monitor_start (struct GNUNET_DHT_Handle *handle, | |||
1328 | void | 1328 | void |
1329 | GNUNET_DHT_monitor_stop (struct GNUNET_DHT_MonitorHandle *handle) | 1329 | GNUNET_DHT_monitor_stop (struct GNUNET_DHT_MonitorHandle *handle) |
1330 | { | 1330 | { |
1331 | GNUNET_free_non_null (handle->key); | 1331 | struct GNUNET_DHT_MonitorStartStopMessage *m; |
1332 | struct PendingMessage *pending; | ||
1333 | |||
1332 | GNUNET_CONTAINER_DLL_remove (handle->dht_handle->monitor_head, | 1334 | GNUNET_CONTAINER_DLL_remove (handle->dht_handle->monitor_head, |
1333 | handle->dht_handle->monitor_tail, | 1335 | handle->dht_handle->monitor_tail, |
1334 | handle); | 1336 | handle); |
1335 | /* FIXME notify service of stop */ | 1337 | |
1338 | pending = GNUNET_malloc (sizeof (struct GNUNET_DHT_MonitorStartStopMessage) + | ||
1339 | sizeof (struct PendingMessage)); | ||
1340 | m = (struct GNUNET_DHT_MonitorStartStopMessage *) &pending[1]; | ||
1341 | pending->msg = &m->header; | ||
1342 | pending->handle = handle->dht_handle; | ||
1343 | pending->free_on_send = GNUNET_YES; | ||
1344 | m->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_MONITOR_STOP); | ||
1345 | m->header.size = htons (sizeof (struct GNUNET_DHT_MonitorStartStopMessage)); | ||
1346 | m->type = htonl(handle->type); | ||
1347 | m->get = htons(NULL != handle->get_cb); | ||
1348 | m->get_resp = htons(NULL != handle->get_resp_cb); | ||
1349 | m->put = htons(NULL != handle->put_cb); | ||
1350 | if (NULL != handle->key) { | ||
1351 | m->filter_key = htons(1); | ||
1352 | memcpy (&m->key, handle->key, sizeof(GNUNET_HashCode)); | ||
1353 | } | ||
1354 | GNUNET_CONTAINER_DLL_insert (handle->dht_handle->pending_head, | ||
1355 | handle->dht_handle->pending_tail, | ||
1356 | pending); | ||
1357 | pending->in_pending_queue = GNUNET_YES; | ||
1358 | process_pending_messages (handle->dht_handle); | ||
1359 | |||
1360 | GNUNET_free_non_null (handle->key); | ||
1336 | GNUNET_free (handle); | 1361 | GNUNET_free (handle); |
1337 | } | 1362 | } |
1338 | 1363 | ||