aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-02-02 13:02:50 +0000
committerChristian Grothoff <christian@grothoff.org>2010-02-02 13:02:50 +0000
commit9b3998e7d575c4a21e259b1859230e4caaf1296e (patch)
treec1f25faf8dfc928dbd11d459575e464335867bd6 /src
parent53d0e2a26886c03a7d92cb400da9ddf5cb841d65 (diff)
downloadgnunet-9b3998e7d575c4a21e259b1859230e4caaf1296e.tar.gz
gnunet-9b3998e7d575c4a21e259b1859230e4caaf1296e.zip
code cleanup, fixing leak
Diffstat (limited to 'src')
-rw-r--r--src/fs/gnunet-service-fs.c52
1 files changed, 16 insertions, 36 deletions
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c
index 2f9af1ad1..19f05d247 100644
--- a/src/fs/gnunet-service-fs.c
+++ b/src/fs/gnunet-service-fs.c
@@ -322,26 +322,6 @@ struct ClientList
322 322
323 323
324/** 324/**
325 * Hash map entry of requests we are performing
326 * on behalf of the same peer.
327 */
328struct PeerRequestEntry
329{
330
331 /**
332 * Request this entry represents.
333 */
334 struct PendingRequest *req;
335
336 /**
337 * Entry of peer responsible for this entry.
338 */
339 struct ConnectedPeer *cp;
340
341};
342
343
344/**
345 * Doubly-linked list of messages we are performing 325 * Doubly-linked list of messages we are performing
346 * due to a pending request. 326 * due to a pending request.
347 */ 327 */
@@ -389,12 +369,12 @@ struct PendingRequest
389 * client request list; otherwise NULL. 369 * client request list; otherwise NULL.
390 */ 370 */
391 struct ClientRequestList *client_request_list; 371 struct ClientRequestList *client_request_list;
392 372
393 /** 373 /**
394 * If this request was made by a peer, this is our entry in the 374 * Entry of peer responsible for this entry (if this request
395 * per-peer multi-hash map; otherwise NULL. 375 * was made by a peer).
396 */ 376 */
397 struct PeerRequestEntry *pht_entry; 377 struct ConnectedPeer *cp;
398 378
399 /** 379 /**
400 * If this is a namespace query, pointer to the hash of the public 380 * If this is a namespace query, pointer to the hash of the public
@@ -670,15 +650,14 @@ destroy_pending_request (struct PendingRequest *pr)
670 GNUNET_free (pr->client_request_list); 650 GNUNET_free (pr->client_request_list);
671 pr->client_request_list = NULL; 651 pr->client_request_list = NULL;
672 } 652 }
673 if (pr->pht_entry != NULL) 653 if (pr->cp != NULL)
674 { 654 {
675 GNUNET_PEER_resolve (pr->pht_entry->cp->pid, 655 GNUNET_PEER_resolve (pr->cp->pid,
676 &pid); 656 &pid);
677 GNUNET_CONTAINER_multihashmap_remove (peer_request_map, 657 GNUNET_CONTAINER_multihashmap_remove (peer_request_map,
678 &pid.hashPubKey, 658 &pid.hashPubKey,
679 pr->pht_entry); 659 pr);
680 GNUNET_free (pr->pht_entry); 660 pr->cp = NULL;
681 pr->pht_entry = NULL;
682 } 661 }
683 if (pr->bf != NULL) 662 if (pr->bf != NULL)
684 { 663 {
@@ -1253,7 +1232,7 @@ target_reservation_cb (void *cls,
1253 no_route = GNUNET_NO; 1232 no_route = GNUNET_NO;
1254 if (amount != DBLOCK_SIZE) 1233 if (amount != DBLOCK_SIZE)
1255 { 1234 {
1256 if (pr->pht_entry == NULL) 1235 if (pr->cp == NULL)
1257 return; /* this target round failed */ 1236 return; /* this target round failed */
1258 /* FIXME: if we are "quite" busy, we may still want to skip 1237 /* FIXME: if we are "quite" busy, we may still want to skip
1259 this round; need more load detection code! */ 1238 this round; need more load detection code! */
@@ -1295,7 +1274,7 @@ target_reservation_cb (void *cls,
1295 ext = (GNUNET_HashCode*) &gm[1]; 1274 ext = (GNUNET_HashCode*) &gm[1];
1296 k = 0; 1275 k = 0;
1297 if (GNUNET_YES == no_route) 1276 if (GNUNET_YES == no_route)
1298 GNUNET_PEER_resolve (pr->pht_entry->cp->pid, (struct GNUNET_PeerIdentity*) &ext[k++]); 1277 GNUNET_PEER_resolve (pr->cp->pid, (struct GNUNET_PeerIdentity*) &ext[k++]);
1299 if (pr->namespace != NULL) 1278 if (pr->namespace != NULL)
1300 memcpy (&ext[k++], pr->namespace, sizeof (GNUNET_HashCode)); 1279 memcpy (&ext[k++], pr->namespace, sizeof (GNUNET_HashCode));
1301 if (pr->target_pid != 0) 1280 if (pr->target_pid != 0)
@@ -1767,7 +1746,7 @@ process_reply (void *cls,
1767 } 1746 }
1768 else 1747 else
1769 { 1748 {
1770 cp = pr->pht_entry->cp; 1749 cp = pr->cp;
1771#if DEBUG_FS 1750#if DEBUG_FS
1772 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1751 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1773 "Transmitting result for query `%s' to other peer (PID=%u)\n", 1752 "Transmitting result for query `%s' to other peer (PID=%u)\n",
@@ -2125,7 +2104,6 @@ handle_p2p_get (void *cls,
2125 uint32_t distance) 2104 uint32_t distance)
2126{ 2105{
2127 struct PendingRequest *pr; 2106 struct PendingRequest *pr;
2128 struct PeerRequestEntry *pre;
2129 struct ConnectedPeer *cp; 2107 struct ConnectedPeer *cp;
2130 struct ConnectedPeer *cps; 2108 struct ConnectedPeer *cps;
2131 struct CheckDuplicateRequestClosure cdc; 2109 struct CheckDuplicateRequestClosure cdc;
@@ -2281,13 +2259,15 @@ handle_p2p_get (void *cls,
2281 } 2259 }
2282 } 2260 }
2283 2261
2284 pre = GNUNET_malloc (sizeof (struct PeerRequestEntry)); 2262 pr->cp = cp;
2285 pre->cp = cp;
2286 pre->req = pr;
2287 GNUNET_CONTAINER_multihashmap_put (query_request_map, 2263 GNUNET_CONTAINER_multihashmap_put (query_request_map,
2288 &gm->query, 2264 &gm->query,
2289 pr, 2265 pr,
2290 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 2266 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
2267 GNUNET_CONTAINER_multihashmap_put (peer_request_map,
2268 &other->hashPubKey,
2269 pr,
2270 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
2291 2271
2292 pr->hnode = GNUNET_CONTAINER_heap_insert (requests_by_expiration_heap, 2272 pr->hnode = GNUNET_CONTAINER_heap_insert (requests_by_expiration_heap,
2293 pr, 2273 pr,