aboutsummaryrefslogtreecommitdiff
path: root/src/topology
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-01-18 10:21:20 +0000
committerChristian Grothoff <christian@grothoff.org>2010-01-18 10:21:20 +0000
commita4bf36da4f459a4bf6cfd700e3cbe62bca6bf935 (patch)
tree077a2b7b47fde07b5967b88870a4f214a236571e /src/topology
parent1e3e9dcf2de32963fc85e5c6be693e608761f701 (diff)
downloadgnunet-a4bf36da4f459a4bf6cfd700e3cbe62bca6bf935.tar.gz
gnunet-a4bf36da4f459a4bf6cfd700e3cbe62bca6bf935.zip
cleaner shutdown
Diffstat (limited to 'src/topology')
-rw-r--r--src/topology/gnunet-daemon-topology.c103
1 files changed, 94 insertions, 9 deletions
diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c
index 157e270ab..5dedeb42a 100644
--- a/src/topology/gnunet-daemon-topology.c
+++ b/src/topology/gnunet-daemon-topology.c
@@ -231,6 +231,76 @@ static struct GNUNET_PEERINFO_IteratorContext *pitr;
231static struct GNUNET_PEERINFO_IteratorContext *pitr_more; 231static struct GNUNET_PEERINFO_IteratorContext *pitr_more;
232 232
233 233
234/**
235 * Entry in linked list of active 'disconnect' requests that we have issued.
236 */
237struct DisconnectList
238{
239 /**
240 * This is a doubly-linked list.
241 */
242 struct DisconnectList *next;
243
244 /**
245 * This is a doubly-linked list.
246 */
247 struct DisconnectList *prev;
248
249 /**
250 * Our request handle.
251 */
252 struct GNUNET_CORE_InformationRequestContext *rh;
253
254 /**
255 * Peer we tried to disconnect.
256 */
257 struct GNUNET_PeerIdentity peer;
258
259};
260
261
262/**
263 * Head of doubly-linked list of active 'disconnect' requests that we have issued.
264 */
265static struct DisconnectList *disconnect_head;
266
267/**
268 * Head of doubly-linked list of active 'disconnect' requests that we have issued.
269 */
270static struct DisconnectList *disconnect_tail;
271
272
273/**
274 * Function called once our request to 'disconnect' a peer
275 * has completed.
276 *
277 * @param cls our 'struct DisconnectList'
278 * @param peer NULL on error (then what?)
279 * @param bpm_in set to the current bandwidth limit (receiving) for this peer
280 * @param bpm_out set to the current bandwidth limit (sending) for this peer
281 * @param latency current latency estimate, "FOREVER" if we have been
282 * disconnected
283 * @param amount set to the amount that was actually reserved or unreserved
284 * @param preference current traffic preference for the given peer
285 */
286static void
287disconnect_done (void *cls,
288 const struct
289 GNUNET_PeerIdentity * peer,
290 unsigned int bpm_in,
291 unsigned int bpm_out,
292 struct GNUNET_TIME_Relative
293 latency, int amount,
294 unsigned long long preference)
295{
296 struct DisconnectList *dl = cls;
297
298 GNUNET_CONTAINER_DLL_remove (disconnect_head,
299 disconnect_tail,
300 dl);
301 GNUNET_free (dl);
302}
303
234 304
235/** 305/**
236 * Force a disconnect from the specified peer. 306 * Force a disconnect from the specified peer.
@@ -238,15 +308,21 @@ static struct GNUNET_PEERINFO_IteratorContext *pitr_more;
238static void 308static void
239force_disconnect (const struct GNUNET_PeerIdentity *peer) 309force_disconnect (const struct GNUNET_PeerIdentity *peer)
240{ 310{
241 // FIXME: do something with return value! 311 struct DisconnectList *dl;
242 GNUNET_CORE_peer_get_info (sched, cfg, 312
243 peer, 313 dl = GNUNET_malloc (sizeof (struct DisconnectList));
244 GNUNET_TIME_UNIT_FOREVER_REL, 314 dl->peer = *peer;
245 0, 315 GNUNET_CONTAINER_DLL_insert (disconnect_head,
246 0, 316 disconnect_tail,
247 0, 317 dl);
248 NULL, 318 dl->rh = GNUNET_CORE_peer_get_info (sched, cfg,
249 NULL); 319 peer,
320 GNUNET_TIME_UNIT_FOREVER_REL,
321 0,
322 0,
323 0,
324 &disconnect_done,
325 dl);
250} 326}
251 327
252 328
@@ -1177,6 +1253,7 @@ static void
1177cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 1253cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1178{ 1254{
1179 struct PeerList *pl; 1255 struct PeerList *pl;
1256 struct DisconnectList *dl;
1180 1257
1181 if (NULL != peerinfo_notify) 1258 if (NULL != peerinfo_notify)
1182 { 1259 {
@@ -1205,6 +1282,14 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1205 friends = pl->next; 1282 friends = pl->next;
1206 GNUNET_free (pl); 1283 GNUNET_free (pl);
1207 } 1284 }
1285 while (NULL != (dl = disconnect_head))
1286 {
1287 GNUNET_CONTAINER_DLL_remove (disconnect_head,
1288 disconnect_tail,
1289 dl);
1290 GNUNET_CORE_peer_get_info_cancel (dl->rh);
1291 GNUNET_free (dl);
1292 }
1208} 1293}
1209 1294
1210 1295