projects
/
oweals
/
gnunet.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
f81f229
)
- cancel all DHT GET request while shutting down
author
Bart Polot
<bart@net.in.tum.de>
Fri, 18 Oct 2013 12:20:09 +0000
(12:20 +0000)
committer
Bart Polot
<bart@net.in.tum.de>
Fri, 18 Oct 2013 12:20:09 +0000
(12:20 +0000)
src/mesh/gnunet-service-mesh_dht.c
patch
|
blob
|
history
diff --git
a/src/mesh/gnunet-service-mesh_dht.c
b/src/mesh/gnunet-service-mesh_dht.c
index 68a99cf89f7123b21f19d8aab8d6394d50495f73..bb342d619f63731c28fb3a060b8d5e40e4d624b9 100644
(file)
--- a/
src/mesh/gnunet-service-mesh_dht.c
+++ b/
src/mesh/gnunet-service-mesh_dht.c
@@
-50,6
+50,9
@@
struct GMD_search_handle
/** Provided closure. */
void *cls;
/** Provided closure. */
void *cls;
+
+ /** Peer ID searched for */
+ GNUNET_PEER_Id peer_id;
};
};
@@
-92,6
+95,10
@@
static unsigned long long dht_replication_level;
*/
static GNUNET_SCHEDULER_TaskIdentifier announce_id_task;
*/
static GNUNET_SCHEDULER_TaskIdentifier announce_id_task;
+/**
+ * GET requests to stop on shutdown.
+ */
+static struct GNUNET_CONTAINER_MultiHashMap32 *get_requests;
/******************************************************************************/
/******************************** STATIC ***********************************/
/******************************************************************************/
/******************************** STATIC ***********************************/
@@
-261,6
+268,27
@@
announce_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
GNUNET_SCHEDULER_add_delayed (id_announce_time, &announce_id, cls);
}
GNUNET_SCHEDULER_add_delayed (id_announce_time, &announce_id, cls);
}
+/**
+ * Iterator over hash map entries and stop GET requests before disconnecting
+ * from the DHT.
+ *
+ * @param cls Closure (unused)
+ * @param key Current peer ID.
+ * @param value Value in the hash map (GMD_search_handle).
+ *
+ * @return #GNUNET_YES, we should continue to iterate,
+ */
+int
+stop_get (void *cls,
+ uint32_t key,
+ void *value)
+{
+ struct GMD_search_handle *h = value;
+
+ GMD_search_stop (h);
+ return GNUNET_YES;
+}
+
/******************************************************************************/
/******************************** API ***********************************/
/******************************************************************************/
/******************************** API ***********************************/
@@
-301,6
+329,7
@@
GMD_init (const struct GNUNET_CONFIGURATION_Handle *c)
}
announce_id_task = GNUNET_SCHEDULER_add_now (&announce_id, NULL);
}
announce_id_task = GNUNET_SCHEDULER_add_now (&announce_id, NULL);
+ get_requests = GNUNET_CONTAINER_multihashmap32_create (32);
}
}
@@
-308,8
+337,10
@@
GMD_init (const struct GNUNET_CONFIGURATION_Handle *c)
* Shut down the DHT subsystem.
*/
void
* Shut down the DHT subsystem.
*/
void
-GMD_shutdown
(void
)
+GMD_shutdown
(void
)
{
{
+ GNUNET_CONTAINER_multihashmap32_iterate (get_requests, &stop_get, NULL);
+ GNUNET_CONTAINER_multihashmap32_destroy (get_requests);
if (dht_handle != NULL)
{
GNUNET_DHT_disconnect (dht_handle);
if (dht_handle != NULL)
{
GNUNET_DHT_disconnect (dht_handle);
@@
-333,6
+364,7
@@
GMD_search (const struct GNUNET_PeerIdentity *peer_id,
" Starting DHT GET for peer %s\n", GNUNET_i2s (peer_id));
GNUNET_CRYPTO_hash (peer_id, sizeof (struct GNUNET_PeerIdentity), &phash);
h = GNUNET_new (struct GMD_search_handle);
" Starting DHT GET for peer %s\n", GNUNET_i2s (peer_id));
GNUNET_CRYPTO_hash (peer_id, sizeof (struct GNUNET_PeerIdentity), &phash);
h = GNUNET_new (struct GMD_search_handle);
+ h->peer_id = GNUNET_PEER_intern (peer_id);
h->callback = callback;
h->cls = cls;
h->dhtget = GNUNET_DHT_get_start (dht_handle, /* handle */
h->callback = callback;
h->cls = cls;
h->dhtget = GNUNET_DHT_get_start (dht_handle, /* handle */
@@
-344,12
+376,15
@@
GMD_search (const struct GNUNET_PeerIdentity *peer_id,
NULL, /* xquery */
0, /* xquery bits */
&dht_get_id_handler, h);
NULL, /* xquery */
0, /* xquery bits */
&dht_get_id_handler, h);
+ GNUNET_CONTAINER_multihashmap32_put (get_requests, h->peer_id, h,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
return h;
}
void
GMD_search_stop (struct GMD_search_handle *h)
{
return h;
}
void
GMD_search_stop (struct GMD_search_handle *h)
{
+ GNUNET_CONTAINER_multihashmap32_remove (get_requests, h->peer_id, h);
GNUNET_DHT_get_stop (h->dhtget);
GNUNET_free (h);
}
\ No newline at end of file
GNUNET_DHT_get_stop (h->dhtget);
GNUNET_free (h);
}
\ No newline at end of file