aboutsummaryrefslogtreecommitdiff
path: root/src/fs
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-12-16 17:34:18 +0000
committerChristian Grothoff <christian@grothoff.org>2014-12-16 17:34:18 +0000
commit0b92336e16fd941ec085c66579486244c6bd83f4 (patch)
treebbb47f96c7bba867018003de148654fd8ca0eab5 /src/fs
parentf1cc760d1c98e2738430ad24d8004c5c700c1c49 (diff)
downloadgnunet-0b92336e16fd941ec085c66579486244c6bd83f4.tar.gz
gnunet-0b92336e16fd941ec085c66579486244c6bd83f4.zip
do not poll empty database every 100ms for migration, doxygen fixes, code cleanup
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/fs_test_lib_data.conf4
-rw-r--r--src/fs/gnunet-service-fs.c13
-rw-r--r--src/fs/gnunet-service-fs_cp.c114
-rw-r--r--src/fs/gnunet-service-fs_cp.h47
-rw-r--r--src/fs/gnunet-service-fs_pr.c50
-rw-r--r--src/fs/gnunet-service-fs_push.c167
6 files changed, 247 insertions, 148 deletions
diff --git a/src/fs/fs_test_lib_data.conf b/src/fs/fs_test_lib_data.conf
index 155c38269..c4e508324 100644
--- a/src/fs/fs_test_lib_data.conf
+++ b/src/fs/fs_test_lib_data.conf
@@ -10,8 +10,8 @@ WAN_QUOTA_OUT = 3932160
10QUOTA = 2 GB 10QUOTA = 2 GB
11#PLUGIN = heap 11#PLUGIN = heap
12# 12#
13#[fs] 13[fs]
14#DELAY = YES 14FORCESTART = YES
15 15
16[testbed] 16[testbed]
17OVERLAY_TOPOLOGY = CLIQUE 17OVERLAY_TOPOLOGY = CLIQUE
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c
index 7a4b9acef..4a70b518d 100644
--- a/src/fs/gnunet-service-fs.c
+++ b/src/fs/gnunet-service-fs.c
@@ -220,9 +220,9 @@ GSF_update_datastore_delay_ (struct GNUNET_TIME_Absolute start)
220 * all. 220 * all.
221 * 221 *
222 * @param priority priority of the request (used as a reference point to compare with the load) 222 * @param priority priority of the request (used as a reference point to compare with the load)
223 * @return GNUNET_YES if the load is too high to do anything (load high) 223 * @return #GNUNET_YES if the load is too high to do anything (load high)
224 * GNUNET_NO to process normally (load normal) 224 * #GNUNET_NO to process normally (load normal)
225 * GNUNET_SYSERR to process for free (load low) 225 * #GNUNET_SYSERR to process for free (load low)
226 */ 226 */
227int 227int
228GSF_test_get_load_too_high_ (uint32_t priority) 228GSF_test_get_load_too_high_ (uint32_t priority)
@@ -248,7 +248,7 @@ GSF_test_get_load_too_high_ (uint32_t priority)
248 * @param bandwidth_out assigned outbound bandwidth for the connection 248 * @param bandwidth_out assigned outbound bandwidth for the connection
249 * @param bandwidth_in assigned inbound bandwidth for the connection 249 * @param bandwidth_in assigned inbound bandwidth for the connection
250 * @param ats performance data for the address (as far as known) 250 * @param ats performance data for the address (as far as known)
251 * @param ats_count number of performance records in 'ats' 251 * @param ats_count number of performance records in @a ats
252 */ 252 */
253static void 253static void
254update_latencies (void *cls, 254update_latencies (void *cls,
@@ -306,6 +306,9 @@ handle_p2p_put (void *cls,
306{ 306{
307 struct GSF_ConnectedPeer *cp; 307 struct GSF_ConnectedPeer *cp;
308 308
309 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
310 "Received P2P PUT from %s\n",
311 GNUNET_i2s (other));
309 cp = GSF_peer_get_ (other); 312 cp = GSF_peer_get_ (other);
310 if (NULL == cp) 313 if (NULL == cp)
311 { 314 {
@@ -321,7 +324,7 @@ handle_p2p_put (void *cls,
321 * We have a new request, consider forwarding it to the given 324 * We have a new request, consider forwarding it to the given
322 * peer. 325 * peer.
323 * 326 *
324 * @param cls the 'struct GSF_PendingRequest' 327 * @param cls the `struct GSF_PendingRequest`
325 * @param peer identity of the peer 328 * @param peer identity of the peer
326 * @param cp handle to the connected peer record 329 * @param cp handle to the connected peer record
327 * @param ppd peer performance data 330 * @param ppd peer performance data
diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c
index bca07db32..c1c3f01f1 100644
--- a/src/fs/gnunet-service-fs_cp.c
+++ b/src/fs/gnunet-service-fs_cp.c
@@ -368,13 +368,15 @@ GSF_get_peer_performance_data_ (struct GSF_ConnectedPeer *cp)
368/** 368/**
369 * Core is ready to transmit to a peer, get the message. 369 * Core is ready to transmit to a peer, get the message.
370 * 370 *
371 * @param cls the 'struct GSF_PeerTransmitHandle' of the message 371 * @param cls the `struct GSF_PeerTransmitHandle` of the message
372 * @param size number of bytes core is willing to take 372 * @param size number of bytes core is willing to take
373 * @param buf where to copy the message 373 * @param buf where to copy the message
374 * @return number of bytes copied to buf 374 * @return number of bytes copied to @a buf
375 */ 375 */
376static size_t 376static size_t
377peer_transmit_ready_cb (void *cls, size_t size, void *buf); 377peer_transmit_ready_cb (void *cls,
378 size_t size,
379 void *buf);
378 380
379 381
380/** 382/**
@@ -388,8 +390,10 @@ peer_transmit_ready_cb (void *cls, size_t size, void *buf);
388 * long should the client wait until re-trying? 390 * long should the client wait until re-trying?
389 */ 391 */
390static void 392static void
391ats_reserve_callback (void *cls, const struct GNUNET_PeerIdentity *peer, 393ats_reserve_callback (void *cls,
392 int32_t amount, struct GNUNET_TIME_Relative res_delay); 394 const struct GNUNET_PeerIdentity *peer,
395 int32_t amount,
396 struct GNUNET_TIME_Relative res_delay);
393 397
394 398
395/** 399/**
@@ -447,10 +451,10 @@ schedule_transmission (struct GSF_PeerTransmitHandle *pth)
447/** 451/**
448 * Core is ready to transmit to a peer, get the message. 452 * Core is ready to transmit to a peer, get the message.
449 * 453 *
450 * @param cls the 'struct GSF_PeerTransmitHandle' of the message 454 * @param cls the `struct GSF_PeerTransmitHandle` of the message
451 * @param size number of bytes core is willing to take 455 * @param size number of bytes core is willing to take
452 * @param buf where to copy the message 456 * @param buf where to copy the message
453 * @return number of bytes copied to buf 457 * @return number of bytes copied to @a buf
454 */ 458 */
455static size_t 459static size_t
456peer_transmit_ready_cb (void *cls, size_t size, void *buf) 460peer_transmit_ready_cb (void *cls, size_t size, void *buf)
@@ -502,7 +506,7 @@ peer_transmit_ready_cb (void *cls, size_t size, void *buf)
502/** 506/**
503 * (re)try to reserve bandwidth from the given peer. 507 * (re)try to reserve bandwidth from the given peer.
504 * 508 *
505 * @param cls the 'struct GSF_ConnectedPeer' to reserve from 509 * @param cls the `struct GSF_ConnectedPeer` to reserve from
506 * @param tc scheduler context 510 * @param tc scheduler context
507 */ 511 */
508static void 512static void
@@ -564,6 +568,7 @@ ats_reserve_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
564 } 568 }
565} 569}
566 570
571
567/** 572/**
568 * Function called by PEERSTORE with peer respect record 573 * Function called by PEERSTORE with peer respect record
569 * 574 *
@@ -573,7 +578,9 @@ ats_reserve_callback (void *cls, const struct GNUNET_PeerIdentity *peer,
573 * @return #GNUNET_NO to stop iterating since we only expect 0 or 1 records 578 * @return #GNUNET_NO to stop iterating since we only expect 0 or 1 records
574 */ 579 */
575static int 580static int
576peer_respect_cb (void *cls, struct GNUNET_PEERSTORE_Record *record, char *emsg) 581peer_respect_cb (void *cls,
582 struct GNUNET_PEERSTORE_Record *record,
583 char *emsg)
577{ 584{
578 struct GSF_ConnectedPeer *cp = cls; 585 struct GSF_ConnectedPeer *cp = cls;
579 586
@@ -631,11 +638,12 @@ GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer,
631 * It may be time to re-start migrating content to this 638 * It may be time to re-start migrating content to this
632 * peer. Check, and if so, restart migration. 639 * peer. Check, and if so, restart migration.
633 * 640 *
634 * @param cls the 'struct GSF_ConnectedPeer' 641 * @param cls the `struct GSF_ConnectedPeer`
635 * @param tc scheduler context 642 * @param tc scheduler context
636 */ 643 */
637static void 644static void
638revive_migration (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 645revive_migration (void *cls,
646 const struct GNUNET_SCHEDULER_TaskContext *tc)
639{ 647{
640 struct GSF_ConnectedPeer *cp = cls; 648 struct GSF_ConnectedPeer *cp = cls;
641 struct GNUNET_TIME_Relative bt; 649 struct GNUNET_TIME_Relative bt;
@@ -675,8 +683,8 @@ GSF_peer_get_ (const struct GNUNET_PeerIdentity *peer)
675 * @param other the other peer involved (sender or receiver, NULL 683 * @param other the other peer involved (sender or receiver, NULL
676 * for loopback messages where we are both sender and receiver) 684 * for loopback messages where we are both sender and receiver)
677 * @param message the actual message 685 * @param message the actual message
678 * @return GNUNET_OK to keep the connection open, 686 * @return #GNUNET_OK to keep the connection open,
679 * GNUNET_SYSERR to close it (signal serious error) 687 * #GNUNET_SYSERR to close it (signal serious error)
680 */ 688 */
681int 689int
682GSF_handle_p2p_migration_stop_ (void *cls, 690GSF_handle_p2p_migration_stop_ (void *cls,
@@ -707,7 +715,8 @@ GSF_handle_p2p_migration_stop_ (void *cls,
707 { 715 {
708 GSF_push_stop_ (cp); 716 GSF_push_stop_ (cp);
709 cp->mig_revive_task = 717 cp->mig_revive_task =
710 GNUNET_SCHEDULER_add_delayed (bt, &revive_migration, cp); 718 GNUNET_SCHEDULER_add_delayed (bt,
719 &revive_migration, cp);
711 } 720 }
712 return GNUNET_OK; 721 return GNUNET_OK;
713} 722}
@@ -716,8 +725,8 @@ GSF_handle_p2p_migration_stop_ (void *cls,
716/** 725/**
717 * Copy reply and free put message. 726 * Copy reply and free put message.
718 * 727 *
719 * @param cls the 'struct PutMessage' 728 * @param cls the `struct PutMessage`
720 * @param buf_size number of bytes available in buf 729 * @param buf_size number of bytes available in @a buf
721 * @param buf where to copy the message, NULL on error (peer disconnect) 730 * @param buf where to copy the message, NULL on error (peer disconnect)
722 * @return number of bytes copied to 'buf', can be 0 (without indicating an error) 731 * @return number of bytes copied to 'buf', can be 0 (without indicating an error)
723 */ 732 */
@@ -779,11 +788,13 @@ free_pending_request (struct PeerRequest *peerreq,
779 * 788 *
780 * @param cls unused 789 * @param cls unused
781 * @param query hash code of the request 790 * @param query hash code of the request
782 * @param value the 'struct GSF_PendingRequest' 791 * @param value the `struct GSF_PendingRequest`
783 * @return GNUNET_YES (continue to iterate) 792 * @return #GNUNET_YES (continue to iterate)
784 */ 793 */
785static int 794static int
786cancel_pending_request (void *cls, const struct GNUNET_HashCode * query, void *value) 795cancel_pending_request (void *cls,
796 const struct GNUNET_HashCode *query,
797 void *value)
787{ 798{
788 struct PeerRequest *peerreq = value; 799 struct PeerRequest *peerreq = value;
789 struct GSF_PendingRequest *pr = peerreq->pr; 800 struct GSF_PendingRequest *pr = peerreq->pr;
@@ -803,7 +814,8 @@ cancel_pending_request (void *cls, const struct GNUNET_HashCode * query, void *v
803 * @param tc task context 814 * @param tc task context
804 */ 815 */
805static void 816static void
806peer_request_destroy (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 817peer_request_destroy (void *cls,
818 const struct GNUNET_SCHEDULER_TaskContext *tc)
807{ 819{
808 struct PeerRequest *peerreq = cls; 820 struct PeerRequest *peerreq = cls;
809 struct GSF_PendingRequest *pr = peerreq->pr; 821 struct GSF_PendingRequest *pr = peerreq->pr;
@@ -822,7 +834,8 @@ peer_request_destroy (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
822 * @param tc scheduler context 834 * @param tc scheduler context
823 */ 835 */
824static void 836static void
825transmit_delayed_now (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 837transmit_delayed_now (void *cls,
838 const struct GNUNET_SCHEDULER_TaskContext *tc)
826{ 839{
827 struct GSF_DelayedHandle *dh = cls; 840 struct GSF_DelayedHandle *dh = cls;
828 struct GSF_ConnectedPeer *cp = dh->cp; 841 struct GSF_ConnectedPeer *cp = dh->cp;
@@ -873,22 +886,25 @@ get_randomized_delay ()
873 * and will also not be called anymore after a call signalling 886 * and will also not be called anymore after a call signalling
874 * expiration. 887 * expiration.
875 * 888 *
876 * @param cls 'struct PeerRequest' this is an answer for 889 * @param cls `struct PeerRequest` this is an answer for
877 * @param eval evaluation of the result 890 * @param eval evaluation of the result
878 * @param pr handle to the original pending request 891 * @param pr handle to the original pending request
879 * @param reply_anonymity_level anonymity level for the reply, UINT32_MAX for "unknown" 892 * @param reply_anonymity_level anonymity level for the reply, UINT32_MAX for "unknown"
880 * @param expiration when does 'data' expire? 893 * @param expiration when does @a data expire?
881 * @param last_transmission when did we last transmit a request for this block 894 * @param last_transmission when did we last transmit a request for this block
882 * @param type type of the block 895 * @param type type of the block
883 * @param data response data, NULL on request expiration 896 * @param data response data, NULL on request expiration
884 * @param data_len number of bytes in data 897 * @param data_len number of bytes in @a data
885 */ 898 */
886static void 899static void
887handle_p2p_reply (void *cls, enum GNUNET_BLOCK_EvaluationResult eval, 900handle_p2p_reply (void *cls,
888 struct GSF_PendingRequest *pr, uint32_t reply_anonymity_level, 901 enum GNUNET_BLOCK_EvaluationResult eval,
902 struct GSF_PendingRequest *pr,
903 uint32_t reply_anonymity_level,
889 struct GNUNET_TIME_Absolute expiration, 904 struct GNUNET_TIME_Absolute expiration,
890 struct GNUNET_TIME_Absolute last_transmission, 905 struct GNUNET_TIME_Absolute last_transmission,
891 enum GNUNET_BLOCK_Type type, const void *data, 906 enum GNUNET_BLOCK_Type type,
907 const void *data,
892 size_t data_len) 908 size_t data_len)
893{ 909{
894 struct PeerRequest *peerreq = cls; 910 struct PeerRequest *peerreq = cls;
@@ -1328,7 +1344,8 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other,
1328 * @param tc scheduler context 1344 * @param tc scheduler context
1329 */ 1345 */
1330static void 1346static void
1331peer_transmit_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 1347peer_transmit_timeout (void *cls,
1348 const struct GNUNET_SCHEDULER_TaskContext *tc)
1332{ 1349{
1333 struct GSF_PeerTransmitHandle *pth = cls; 1350 struct GSF_PeerTransmitHandle *pth = cls;
1334 struct GSF_ConnectedPeer *cp; 1351 struct GSF_ConnectedPeer *cp;
@@ -1369,9 +1386,12 @@ peer_transmit_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1369 * @return handle to cancel request 1386 * @return handle to cancel request
1370 */ 1387 */
1371struct GSF_PeerTransmitHandle * 1388struct GSF_PeerTransmitHandle *
1372GSF_peer_transmit_ (struct GSF_ConnectedPeer *cp, int is_query, 1389GSF_peer_transmit_ (struct GSF_ConnectedPeer *cp,
1373 uint32_t priority, struct GNUNET_TIME_Relative timeout, 1390 int is_query,
1374 size_t size, GSF_GetMessageCallback gmc, void *gmc_cls) 1391 uint32_t priority,
1392 struct GNUNET_TIME_Relative timeout,
1393 size_t size,
1394 GSF_GetMessageCallback gmc, void *gmc_cls)
1375{ 1395{
1376 struct GSF_PeerTransmitHandle *pth; 1396 struct GSF_PeerTransmitHandle *pth;
1377 struct GSF_PeerTransmitHandle *pos; 1397 struct GSF_PeerTransmitHandle *pos;
@@ -1500,7 +1520,8 @@ GSF_peer_update_responder_peer_ (struct GSF_ConnectedPeer *cp,
1500 * @param peer identity of peer that connected 1520 * @param peer identity of peer that connected
1501 */ 1521 */
1502void 1522void
1503GSF_peer_disconnect_handler_ (void *cls, const struct GNUNET_PeerIdentity *peer) 1523GSF_peer_disconnect_handler_ (void *cls,
1524 const struct GNUNET_PeerIdentity *peer)
1504{ 1525{
1505 struct GSF_ConnectedPeer *cp; 1526 struct GSF_ConnectedPeer *cp;
1506 struct GSF_PeerTransmitHandle *pth; 1527 struct GSF_PeerTransmitHandle *pth;
@@ -1581,7 +1602,7 @@ GSF_peer_disconnect_handler_ (void *cls, const struct GNUNET_PeerIdentity *peer)
1581 1602
1582 1603
1583/** 1604/**
1584 * Closure for 'call_iterator'. 1605 * Closure for #call_iterator().
1585 */ 1606 */
1586struct IterationContext 1607struct IterationContext
1587{ 1608{
@@ -1591,7 +1612,7 @@ struct IterationContext
1591 GSF_ConnectedPeerIterator it; 1612 GSF_ConnectedPeerIterator it;
1592 1613
1593 /** 1614 /**
1594 * Closure for 'it'. 1615 * Closure for @e it.
1595 */ 1616 */
1596 void *it_cls; 1617 void *it_cls;
1597}; 1618};
@@ -1606,12 +1627,16 @@ struct IterationContext
1606 * @return #GNUNET_YES to continue iteration 1627 * @return #GNUNET_YES to continue iteration
1607 */ 1628 */
1608static int 1629static int
1609call_iterator (void *cls, const struct GNUNET_PeerIdentity * key, void *value) 1630call_iterator (void *cls,
1631 const struct GNUNET_PeerIdentity *key,
1632 void *value)
1610{ 1633{
1611 struct IterationContext *ic = cls; 1634 struct IterationContext *ic = cls;
1612 struct GSF_ConnectedPeer *cp = value; 1635 struct GSF_ConnectedPeer *cp = value;
1613 1636
1614 ic->it (ic->it_cls, (const struct GNUNET_PeerIdentity *) key, cp, &cp->ppd); 1637 ic->it (ic->it_cls,
1638 key, cp,
1639 &cp->ppd);
1615 return GNUNET_YES; 1640 return GNUNET_YES;
1616} 1641}
1617 1642
@@ -1623,13 +1648,16 @@ call_iterator (void *cls, const struct GNUNET_PeerIdentity * key, void *value)
1623 * @param it_cls closure for @a it 1648 * @param it_cls closure for @a it
1624 */ 1649 */
1625void 1650void
1626GSF_iterate_connected_peers_ (GSF_ConnectedPeerIterator it, void *it_cls) 1651GSF_iterate_connected_peers_ (GSF_ConnectedPeerIterator it,
1652 void *it_cls)
1627{ 1653{
1628 struct IterationContext ic; 1654 struct IterationContext ic;
1629 1655
1630 ic.it = it; 1656 ic.it = it;
1631 ic.it_cls = it_cls; 1657 ic.it_cls = it_cls;
1632 GNUNET_CONTAINER_multipeermap_iterate (cp_map, &call_iterator, &ic); 1658 GNUNET_CONTAINER_multipeermap_iterate (cp_map,
1659 &call_iterator,
1660 &ic);
1633} 1661}
1634 1662
1635 1663
@@ -1665,13 +1693,15 @@ GSF_connected_peer_get_identity2_ (const struct GSF_ConnectedPeer *cp)
1665/** 1693/**
1666 * Assemble a migration stop message for transmission. 1694 * Assemble a migration stop message for transmission.
1667 * 1695 *
1668 * @param cls the 'struct GSF_ConnectedPeer' to use 1696 * @param cls the `struct GSF_ConnectedPeer` to use
1669 * @param size number of bytes we're allowed to write to buf 1697 * @param size number of bytes we're allowed to write to @a buf
1670 * @param buf where to copy the message 1698 * @param buf where to copy the message
1671 * @return number of bytes copied to buf 1699 * @return number of bytes copied to @a buf
1672 */ 1700 */
1673static size_t 1701static size_t
1674create_migration_stop_message (void *cls, size_t size, void *buf) 1702create_migration_stop_message (void *cls,
1703 size_t size,
1704 void *buf)
1675{ 1705{
1676 struct GSF_ConnectedPeer *cp = cls; 1706 struct GSF_ConnectedPeer *cp = cls;
1677 struct MigrationStopMessage msm; 1707 struct MigrationStopMessage msm;
diff --git a/src/fs/gnunet-service-fs_cp.h b/src/fs/gnunet-service-fs_cp.h
index 6b5fb4b0c..5b20c7cd2 100644
--- a/src/fs/gnunet-service-fs_cp.h
+++ b/src/fs/gnunet-service-fs_cp.h
@@ -158,23 +158,25 @@ struct GSF_PeerPerformanceData
158 * @param cp handle to the connected peer record 158 * @param cp handle to the connected peer record
159 * @param perf peer performance data 159 * @param perf peer performance data
160 */ 160 */
161typedef void (*GSF_ConnectedPeerIterator) (void *cls, 161typedef void
162 const struct GNUNET_PeerIdentity * 162(*GSF_ConnectedPeerIterator) (void *cls,
163 peer, struct GSF_ConnectedPeer * cp, 163 const struct GNUNET_PeerIdentity *peer,
164 const struct GSF_PeerPerformanceData 164 struct GSF_ConnectedPeer *cp,
165 * ppd); 165 const struct GSF_PeerPerformanceData *ppd);
166 166
167 167
168/** 168/**
169 * Function called to get a message for transmission. 169 * Function called to get a message for transmission.
170 * 170 *
171 * @param cls closure 171 * @param cls closure
172 * @param buf_size number of bytes available in buf 172 * @param buf_size number of bytes available in @a buf
173 * @param buf where to copy the message, NULL on error (peer disconnect) 173 * @param buf where to copy the message, NULL on error (peer disconnect)
174 * @return number of bytes copied to 'buf', can be 0 (without indicating an error) 174 * @return number of bytes copied to @a buf, can be 0 (without indicating an error)
175 */ 175 */
176typedef size_t (*GSF_GetMessageCallback) (void *cls, size_t buf_size, 176typedef size_t
177 void *buf); 177(*GSF_GetMessageCallback) (void *cls,
178 size_t buf_size,
179 void *buf);
178 180
179 181
180/** 182/**
@@ -182,11 +184,12 @@ typedef size_t (*GSF_GetMessageCallback) (void *cls, size_t buf_size,
182 * 184 *
183 * @param cls closure 185 * @param cls closure
184 * @param cp handle to the connected peer record 186 * @param cp handle to the connected peer record
185 * @param success GNUNET_YES on success, GNUNET_NO on failure 187 * @param success #GNUNET_YES on success, #GNUNET_NO on failure
186 */ 188 */
187typedef void (*GSF_PeerReserveCallback) (void *cls, 189typedef void
188 struct GSF_ConnectedPeer * cp, 190(*GSF_PeerReserveCallback) (void *cls,
189 int success); 191 struct GSF_ConnectedPeer *cp,
192 int success);
190 193
191 194
192/** 195/**
@@ -195,8 +198,9 @@ typedef void (*GSF_PeerReserveCallback) (void *cls,
195 * @param cls closure 198 * @param cls closure
196 * @param cp handle to the newly created connected peer record 199 * @param cp handle to the newly created connected peer record
197 */ 200 */
198typedef void (*GSF_ConnectedPeerCreationCallback) (void *cls, 201typedef void
199 struct GSF_ConnectedPeer *cp); 202(*GSF_ConnectedPeerCreationCallback) (void *cls,
203 struct GSF_ConnectedPeer *cp);
200 204
201 205
202/** 206/**
@@ -255,9 +259,12 @@ GSF_update_peer_latency_ (const struct GNUNET_PeerIdentity *id,
255 * @return handle to cancel request 259 * @return handle to cancel request
256 */ 260 */
257struct GSF_PeerTransmitHandle * 261struct GSF_PeerTransmitHandle *
258GSF_peer_transmit_ (struct GSF_ConnectedPeer *cp, int is_query, 262GSF_peer_transmit_ (struct GSF_ConnectedPeer *cp,
259 uint32_t priority, struct GNUNET_TIME_Relative timeout, 263 int is_query,
260 size_t size, GSF_GetMessageCallback gmc, void *gmc_cls); 264 uint32_t priority,
265 struct GNUNET_TIME_Relative timeout,
266 size_t size, GSF_GetMessageCallback gmc,
267 void *gmc_cls);
261 268
262 269
263/** 270/**
@@ -314,8 +321,8 @@ GSF_peer_update_responder_peer_ (struct GSF_ConnectedPeer *cp,
314 * @param other the other peer involved (sender or receiver, NULL 321 * @param other the other peer involved (sender or receiver, NULL
315 * for loopback messages where we are both sender and receiver) 322 * for loopback messages where we are both sender and receiver)
316 * @param message the actual message 323 * @param message the actual message
317 * @return GNUNET_OK to keep the connection open, 324 * @return #GNUNET_OK to keep the connection open,
318 * GNUNET_SYSERR to close it (signal serious error) 325 * #GNUNET_SYSERR to close it (signal serious error)
319 */ 326 */
320int 327int
321GSF_handle_p2p_migration_stop_ (void *cls, 328GSF_handle_p2p_migration_stop_ (void *cls,
diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c
index a9530f53a..f809efd6c 100644
--- a/src/fs/gnunet-service-fs_pr.c
+++ b/src/fs/gnunet-service-fs_pr.c
@@ -918,8 +918,8 @@ struct PutMigrationContext
918 struct GNUNET_PeerIdentity origin; 918 struct GNUNET_PeerIdentity origin;
919 919
920 /** 920 /**
921 * GNUNET_YES if we had a matching request for this block, 921 * #GNUNET_YES if we had a matching request for this block,
922 * GNUNET_NO if not. 922 * #GNUNET_NO if not.
923 */ 923 */
924 int requested; 924 int requested;
925}; 925};
@@ -992,8 +992,10 @@ put_migration_continuation (void *cls, int success,
992 ppd->migration_delay = GNUNET_TIME_relative_multiply (ppd->migration_delay, 2); 992 ppd->migration_delay = GNUNET_TIME_relative_multiply (ppd->migration_delay, 2);
993 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 993 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
994 "Replicated content already exists locally, asking to stop migration for %s\n", 994 "Replicated content already exists locally, asking to stop migration for %s\n",
995 GNUNET_STRINGS_relative_time_to_string (mig_pause, GNUNET_YES)); 995 GNUNET_STRINGS_relative_time_to_string (mig_pause,
996 GSF_block_peer_migration_ (cp, GNUNET_TIME_relative_to_absolute (mig_pause)); 996 GNUNET_YES));
997 GSF_block_peer_migration_ (cp,
998 GNUNET_TIME_relative_to_absolute (mig_pause));
997 } 999 }
998 } 1000 }
999 GNUNET_free (pmc); 1001 GNUNET_free (pmc);
@@ -1048,13 +1050,16 @@ test_put_load_too_high (uint32_t priority)
1048 * @param data pointer to the result data 1050 * @param data pointer to the result data
1049 */ 1051 */
1050static void 1052static void
1051handle_dht_reply (void *cls, struct GNUNET_TIME_Absolute exp, 1053handle_dht_reply (void *cls,
1052 const struct GNUNET_HashCode * key, 1054 struct GNUNET_TIME_Absolute exp,
1055 const struct GNUNET_HashCode *key,
1053 const struct GNUNET_PeerIdentity *get_path, 1056 const struct GNUNET_PeerIdentity *get_path,
1054 unsigned int get_path_length, 1057 unsigned int get_path_length,
1055 const struct GNUNET_PeerIdentity *put_path, 1058 const struct GNUNET_PeerIdentity *put_path,
1056 unsigned int put_path_length, enum GNUNET_BLOCK_Type type, 1059 unsigned int put_path_length,
1057 size_t size, const void *data) 1060 enum GNUNET_BLOCK_Type type,
1061 size_t size,
1062 const void *data)
1058{ 1063{
1059 struct GSF_PendingRequest *pr = cls; 1064 struct GSF_PendingRequest *pr = cls;
1060 struct ProcessReplyClosure prq; 1065 struct ProcessReplyClosure prq;
@@ -1089,7 +1094,10 @@ handle_dht_reply (void *cls, struct GNUNET_TIME_Absolute exp,
1089 GNUNET_CONSTANTS_SERVICE_TIMEOUT, 1094 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
1090 &put_migration_continuation, pmc)) 1095 &put_migration_continuation, pmc))
1091 { 1096 {
1092 put_migration_continuation (pmc, GNUNET_SYSERR, GNUNET_TIME_UNIT_ZERO_ABS, NULL); 1097 put_migration_continuation (pmc,
1098 GNUNET_SYSERR,
1099 GNUNET_TIME_UNIT_ZERO_ABS,
1100 NULL);
1093 } 1101 }
1094 } 1102 }
1095} 1103}
@@ -1629,8 +1637,8 @@ GSF_local_lookup_ (struct GSF_PendingRequest *pr,
1629 * @param cp the other peer involved (sender or receiver, NULL 1637 * @param cp the other peer involved (sender or receiver, NULL
1630 * for loopback messages where we are both sender and receiver) 1638 * for loopback messages where we are both sender and receiver)
1631 * @param message the actual message 1639 * @param message the actual message
1632 * @return GNUNET_OK if the message was well-formed, 1640 * @return #GNUNET_OK if the message was well-formed,
1633 * GNUNET_SYSERR if the message was malformed (close connection, 1641 * #GNUNET_SYSERR if the message was malformed (close connection,
1634 * do not cache under any circumstances) 1642 * do not cache under any circumstances)
1635 */ 1643 */
1636int 1644int
@@ -1661,10 +1669,14 @@ GSF_handle_p2p_content_ (struct GSF_ConnectedPeer *cp,
1661 /* do not allow migrated content to live longer than 1 year */ 1669 /* do not allow migrated content to live longer than 1 year */
1662 expiration = GNUNET_TIME_absolute_min (GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_YEARS), 1670 expiration = GNUNET_TIME_absolute_min (GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_YEARS),
1663 expiration); 1671 expiration);
1664 if (type == GNUNET_BLOCK_TYPE_FS_ONDEMAND) 1672 if (GNUNET_BLOCK_TYPE_FS_ONDEMAND == type)
1665 return GNUNET_SYSERR; 1673 return GNUNET_SYSERR;
1666 if (GNUNET_OK != 1674 if (GNUNET_OK !=
1667 GNUNET_BLOCK_get_key (GSF_block_ctx, type, &put[1], dsize, &query)) 1675 GNUNET_BLOCK_get_key (GSF_block_ctx,
1676 type,
1677 &put[1],
1678 dsize,
1679 &query))
1668 { 1680 {
1669 GNUNET_break_op (0); 1681 GNUNET_break_op (0);
1670 return GNUNET_SYSERR; 1682 return GNUNET_SYSERR;
@@ -1681,7 +1693,9 @@ GSF_handle_p2p_content_ (struct GSF_ConnectedPeer *cp,
1681 prq.priority = 0; 1693 prq.priority = 0;
1682 prq.anonymity_level = UINT32_MAX; 1694 prq.anonymity_level = UINT32_MAX;
1683 prq.request_found = GNUNET_NO; 1695 prq.request_found = GNUNET_NO;
1684 GNUNET_CONTAINER_multihashmap_get_multiple (pr_map, &query, &process_reply, 1696 GNUNET_CONTAINER_multihashmap_get_multiple (pr_map,
1697 &query,
1698 &process_reply,
1685 &prq); 1699 &prq);
1686 if (NULL != cp) 1700 if (NULL != cp)
1687 { 1701 {
@@ -1696,7 +1710,8 @@ GSF_handle_p2p_content_ (struct GSF_ConnectedPeer *cp,
1696 { 1710 {
1697 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1711 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1698 "Replicating result for query `%s' with priority %u\n", 1712 "Replicating result for query `%s' with priority %u\n",
1699 GNUNET_h2s (&query), prq.priority); 1713 GNUNET_h2s (&query),
1714 prq.priority);
1700 pmc = GNUNET_new (struct PutMigrationContext); 1715 pmc = GNUNET_new (struct PutMigrationContext);
1701 pmc->start = GNUNET_TIME_absolute_get (); 1716 pmc->start = GNUNET_TIME_absolute_get ();
1702 pmc->requested = prq.request_found; 1717 pmc->requested = prq.request_found;
@@ -1711,7 +1726,10 @@ GSF_handle_p2p_content_ (struct GSF_ConnectedPeer *cp,
1711 GNUNET_CONSTANTS_SERVICE_TIMEOUT, 1726 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
1712 &put_migration_continuation, pmc)) 1727 &put_migration_continuation, pmc))
1713 { 1728 {
1714 put_migration_continuation (pmc, GNUNET_SYSERR, GNUNET_TIME_UNIT_ZERO_ABS, NULL); 1729 put_migration_continuation (pmc,
1730 GNUNET_SYSERR,
1731 GNUNET_TIME_UNIT_ZERO_ABS,
1732 NULL);
1715 } 1733 }
1716 } 1734 }
1717 else if (NULL != cp) 1735 else if (NULL != cp)
diff --git a/src/fs/gnunet-service-fs_push.c b/src/fs/gnunet-service-fs_push.c
index c80dc8b08..f099f7fdc 100644
--- a/src/fs/gnunet-service-fs_push.c
+++ b/src/fs/gnunet-service-fs_push.c
@@ -181,6 +181,11 @@ static unsigned int mig_size;
181 */ 181 */
182static int enabled; 182static int enabled;
183 183
184/**
185 * Did we find anything in the datastore?
186 */
187static int value_found;
188
184 189
185/** 190/**
186 * Delete the given migration block. 191 * Delete the given migration block.
@@ -205,16 +210,17 @@ find_content (struct MigrationReadyPeer *mrp);
205 210
206 211
207/** 212/**
208 * Transmit the message currently scheduled for 213 * Transmit the message currently scheduled for transmission.
209 * transmission.
210 * 214 *
211 * @param cls the 'struct MigrationReadyPeer' 215 * @param cls the `struct MigrationReadyPeer`
212 * @param buf_size number of bytes available in buf 216 * @param buf_size number of bytes available in @a buf
213 * @param buf where to copy the message, NULL on error (peer disconnect) 217 * @param buf where to copy the message, NULL on error (peer disconnect)
214 * @return number of bytes copied to 'buf', can be 0 (without indicating an error) 218 * @return number of bytes copied to @a buf, can be 0 (without indicating an error)
215 */ 219 */
216static size_t 220static size_t
217transmit_message (void *cls, size_t buf_size, void *buf) 221transmit_message (void *cls,
222 size_t buf_size,
223 void *buf)
218{ 224{
219 struct MigrationReadyPeer *peer = cls; 225 struct MigrationReadyPeer *peer = cls;
220 struct PutMessage *msg; 226 struct PutMessage *msg;
@@ -223,7 +229,7 @@ transmit_message (void *cls, size_t buf_size, void *buf)
223 peer->th = NULL; 229 peer->th = NULL;
224 msg = peer->msg; 230 msg = peer->msg;
225 peer->msg = NULL; 231 peer->msg = NULL;
226 if (buf == NULL) 232 if (NULL == buf)
227 { 233 {
228 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 234 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
229 "Failed to migrate content to another peer (disconnect)\n"); 235 "Failed to migrate content to another peer (disconnect)\n");
@@ -234,8 +240,10 @@ transmit_message (void *cls, size_t buf_size, void *buf)
234 GNUNET_assert (msize <= buf_size); 240 GNUNET_assert (msize <= buf_size);
235 memcpy (buf, msg, msize); 241 memcpy (buf, msg, msize);
236 GNUNET_free (msg); 242 GNUNET_free (msg);
237 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Pushing %u bytes to another peer\n", 243 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
238 msize); 244 "Pushing %u bytes to %s\n",
245 msize,
246 GNUNET_i2s (GSF_connected_peer_get_identity2_(peer->peer)));
239 find_content (peer); 247 find_content (peer);
240 return msize; 248 return msize;
241} 249}
@@ -246,7 +254,7 @@ transmit_message (void *cls, size_t buf_size, void *buf)
246 * 254 *
247 * @param peer target peer 255 * @param peer target peer
248 * @param block the block 256 * @param block the block
249 * @return GNUNET_YES if the block was deleted (!) 257 * @return #GNUNET_YES if the block was deleted (!)
250 */ 258 */
251static int 259static int
252transmit_content (struct MigrationReadyPeer *peer, 260transmit_content (struct MigrationReadyPeer *peer,
@@ -287,9 +295,13 @@ transmit_content (struct MigrationReadyPeer *peer,
287 ret = GNUNET_NO; 295 ret = GNUNET_NO;
288 } 296 }
289 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 297 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
290 "Asking for transmission of %u bytes for migration\n", msize); 298 "Asking for transmission of %u bytes to %s for migration\n",
291 peer->th = GSF_peer_transmit_ (peer->peer, GNUNET_NO, 0 /* priority */ , 299 msize,
292 GNUNET_TIME_UNIT_FOREVER_REL, msize, 300 GNUNET_i2s (GSF_connected_peer_get_identity2_(peer->peer)));
301 peer->th = GSF_peer_transmit_ (peer->peer,
302 GNUNET_NO, 0 /* priority */ ,
303 GNUNET_TIME_UNIT_FOREVER_REL,
304 msize,
293 &transmit_message, peer); 305 &transmit_message, peer);
294 return ret; 306 return ret;
295} 307}
@@ -436,19 +448,27 @@ consider_gathering ()
436{ 448{
437 struct GNUNET_TIME_Relative delay; 449 struct GNUNET_TIME_Relative delay;
438 450
439 if (GSF_dsh == NULL) 451 if (NULL == GSF_dsh)
440 return; 452 return;
441 if (mig_qe != NULL) 453 if (NULL != mig_qe)
442 return; 454 return;
443 if (mig_task != GNUNET_SCHEDULER_NO_TASK) 455 if (GNUNET_SCHEDULER_NO_TASK != mig_task)
444 return; 456 return;
445 if (mig_size >= MAX_MIGRATION_QUEUE) 457 if (mig_size >= MAX_MIGRATION_QUEUE)
446 return; 458 return;
447 delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, mig_size); 459 delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, mig_size);
448 delay = GNUNET_TIME_relative_divide (delay, MAX_MIGRATION_QUEUE); 460 delay = GNUNET_TIME_relative_divide (delay, MAX_MIGRATION_QUEUE);
449 delay = GNUNET_TIME_relative_max (delay, min_migration_delay); 461 delay = GNUNET_TIME_relative_max (delay, min_migration_delay);
462 if (GNUNET_NO == value_found)
463 {
464 /* wait at least 5s if the datastore is empty */
465 delay = GNUNET_TIME_relative_max (delay,
466 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
467 5));
468 }
450 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 469 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
451 "Scheduling gathering task (queue size: %u)\n", mig_size); 470 "Scheduling gathering task (queue size: %u)\n",
471 mig_size);
452 mig_task = 472 mig_task =
453 GNUNET_SCHEDULER_add_delayed (delay, &gather_migration_blocks, NULL); 473 GNUNET_SCHEDULER_add_delayed (delay, &gather_migration_blocks, NULL);
454} 474}
@@ -469,21 +489,28 @@ consider_gathering ()
469 * maybe 0 if no unique identifier is available 489 * maybe 0 if no unique identifier is available
470 */ 490 */
471static void 491static void
472process_migration_content (void *cls, const struct GNUNET_HashCode * key, size_t size, 492process_migration_content (void *cls,
473 const void *data, enum GNUNET_BLOCK_Type type, 493 const struct GNUNET_HashCode *key,
474 uint32_t priority, uint32_t anonymity, 494 size_t size,
475 struct GNUNET_TIME_Absolute expiration, uint64_t uid) 495 const void *data,
496 enum GNUNET_BLOCK_Type type,
497 uint32_t priority,
498 uint32_t anonymity,
499 struct GNUNET_TIME_Absolute expiration,
500 uint64_t uid)
476{ 501{
477 struct MigrationReadyBlock *mb; 502 struct MigrationReadyBlock *mb;
478 struct MigrationReadyPeer *pos; 503 struct MigrationReadyPeer *pos;
479 504
480 mig_qe = NULL; 505 mig_qe = NULL;
481 if (key == NULL) 506 if (NULL == key)
482 { 507 {
483 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "No content found for migration...\n"); 508 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
509 "No content found for migration...\n");
484 consider_gathering (); 510 consider_gathering ();
485 return; 511 return;
486 } 512 }
513 value_found = GNUNET_YES;
487 if (GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us < 514 if (GNUNET_TIME_absolute_get_remaining (expiration).rel_value_us <
488 MIN_MIGRATION_CONTENT_LIFETIME.rel_value_us) 515 MIN_MIGRATION_CONTENT_LIFETIME.rel_value_us)
489 { 516 {
@@ -494,34 +521,44 @@ process_migration_content (void *cls, const struct GNUNET_HashCode * key, size_t
494 if (type == GNUNET_BLOCK_TYPE_FS_ONDEMAND) 521 if (type == GNUNET_BLOCK_TYPE_FS_ONDEMAND)
495 { 522 {
496 if (GNUNET_OK != 523 if (GNUNET_OK !=
497 GNUNET_FS_handle_on_demand_block (key, size, data, type, priority, 524 GNUNET_FS_handle_on_demand_block (key,
498 anonymity, expiration, uid, 525 size,
526 data,
527 type,
528 priority,
529 anonymity,
530 expiration,
531 uid,
499 &process_migration_content, NULL)) 532 &process_migration_content, NULL))
500 consider_gathering (); 533 consider_gathering ();
501 return; 534 return;
502 } 535 }
503 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 536 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
504 "Retrieved block `%s' of type %u for migration (queue size: %u/%u)\n", 537 "Retrieved block `%s' of type %u for migration (queue size: %u/%u)\n",
505 GNUNET_h2s (key), type, mig_size + 1, MAX_MIGRATION_QUEUE); 538 GNUNET_h2s (key),
539 type, mig_size + 1,
540 MAX_MIGRATION_QUEUE);
506 mb = GNUNET_malloc (sizeof (struct MigrationReadyBlock) + size); 541 mb = GNUNET_malloc (sizeof (struct MigrationReadyBlock) + size);
507 mb->query = *key; 542 mb->query = *key;
508 mb->expiration = expiration; 543 mb->expiration = expiration;
509 mb->size = size; 544 mb->size = size;
510 mb->type = type; 545 mb->type = type;
511 memcpy (&mb[1], data, size); 546 memcpy (&mb[1], data, size);
512 GNUNET_CONTAINER_DLL_insert_after (mig_head, mig_tail, mig_tail, mb); 547 GNUNET_CONTAINER_DLL_insert_after (mig_head,
548 mig_tail,
549 mig_tail,
550 mb);
513 mig_size++; 551 mig_size++;
514 pos = peer_head; 552 for (pos = peer_head; NULL != pos; pos = pos->next)
515 while (pos != NULL)
516 { 553 {
517 if (NULL == pos->th) 554 if (NULL == pos->th)
518 { 555 {
519 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 556 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
520 "Preparing to push best content to peer\n"); 557 "Preparing to push best content to peer %s\n",
558 GNUNET_i2s (GSF_connected_peer_get_identity2_(pos->peer)));
521 if (GNUNET_YES == transmit_content (pos, mb)) 559 if (GNUNET_YES == transmit_content (pos, mb))
522 break; /* 'mb' was freed! */ 560 break; /* 'mb' was freed! */
523 } 561 }
524 pos = pos->next;
525 } 562 }
526 consider_gathering (); 563 consider_gathering ();
527} 564}
@@ -541,18 +578,18 @@ gather_migration_blocks (void *cls,
541 mig_task = GNUNET_SCHEDULER_NO_TASK; 578 mig_task = GNUNET_SCHEDULER_NO_TASK;
542 if (mig_size >= MAX_MIGRATION_QUEUE) 579 if (mig_size >= MAX_MIGRATION_QUEUE)
543 return; 580 return;
544 if (GSF_dsh != NULL) 581 if (NULL == GSF_dsh)
545 { 582 return;
546 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 583 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
547 "Asking datastore for content for replication (queue size: %u)\n", 584 "Asking datastore for content for replication (queue size: %u)\n",
548 mig_size); 585 mig_size);
549 mig_qe = 586 value_found = GNUNET_NO;
550 GNUNET_DATASTORE_get_for_replication (GSF_dsh, 0, UINT_MAX, 587 mig_qe =
551 GNUNET_TIME_UNIT_FOREVER_REL, 588 GNUNET_DATASTORE_get_for_replication (GSF_dsh, 0, UINT_MAX,
552 &process_migration_content, NULL); 589 GNUNET_TIME_UNIT_FOREVER_REL,
553 if (NULL == mig_qe) 590 &process_migration_content, NULL);
554 consider_gathering (); 591 if (NULL == mig_qe)
555 } 592 consider_gathering ();
556} 593}
557 594
558 595
@@ -569,10 +606,16 @@ GSF_push_start_ (struct GSF_ConnectedPeer *peer)
569 606
570 if (GNUNET_YES != enabled) 607 if (GNUNET_YES != enabled)
571 return; 608 return;
609 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
610 "Adding peer %s to list for pushing\n",
611 GNUNET_i2s (GSF_connected_peer_get_identity2_(peer)));
612
572 mrp = GNUNET_new (struct MigrationReadyPeer); 613 mrp = GNUNET_new (struct MigrationReadyPeer);
573 mrp->peer = peer; 614 mrp->peer = peer;
574 find_content (mrp); 615 find_content (mrp);
575 GNUNET_CONTAINER_DLL_insert (peer_head, peer_tail, mrp); 616 GNUNET_CONTAINER_DLL_insert (peer_head,
617 peer_tail,
618 mrp);
576} 619}
577 620
578 621
@@ -587,27 +630,25 @@ GSF_push_stop_ (struct GSF_ConnectedPeer *peer)
587{ 630{
588 struct MigrationReadyPeer *pos; 631 struct MigrationReadyPeer *pos;
589 632
590 pos = peer_head; 633 for (pos = peer_head; NULL != pos; pos = pos->next)
591 while (pos != NULL)
592 {
593 if (pos->peer == peer) 634 if (pos->peer == peer)
594 { 635 break;
595 GNUNET_CONTAINER_DLL_remove (peer_head, peer_tail, pos); 636 if (NULL == pos)
596 if (NULL != pos->th) 637 return;
597 { 638 GNUNET_CONTAINER_DLL_remove (peer_head,
598 GSF_peer_transmit_cancel_ (pos->th); 639 peer_tail,
599 pos->th = NULL; 640 pos);
600 } 641 if (NULL != pos->th)
601 if (NULL != pos->msg) 642 {
602 { 643 GSF_peer_transmit_cancel_ (pos->th);
603 GNUNET_free (pos->msg); 644 pos->th = NULL;
604 pos->msg = NULL; 645 }
605 } 646 if (NULL != pos->msg)
606 GNUNET_free (pos); 647 {
607 return; 648 GNUNET_free (pos->msg);
608 } 649 pos->msg = NULL;
609 pos = pos->next;
610 } 650 }
651 GNUNET_free (pos);
611} 652}
612 653
613 654