aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmar Tarabai <tarabai@devegypt.com>2014-12-21 01:26:46 +0000
committerOmar Tarabai <tarabai@devegypt.com>2014-12-21 01:26:46 +0000
commitb94ce15c0dd10f44f5e0c77a8270b4f75e0b322c (patch)
treefb8ed0e1adf3b565ec1767d22e62ecdc0d66dc50
parentebf56d861396a1367e4fe6b6bd5d5fdc7caeb8d3 (diff)
downloadgnunet-b94ce15c0dd10f44f5e0c77a8270b4f75e0b322c.tar.gz
gnunet-b94ce15c0dd10f44f5e0c77a8270b4f75e0b322c.zip
flush peer respect value on disconnect
-rw-r--r--src/fs/gnunet-service-fs_cp.c53
1 files changed, 27 insertions, 26 deletions
diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c
index e901af25e..91102af6e 100644
--- a/src/fs/gnunet-service-fs_cp.c
+++ b/src/fs/gnunet-service-fs_cp.c
@@ -1515,6 +1515,32 @@ GSF_peer_update_responder_peer_ (struct GSF_ConnectedPeer *cp,
1515 1515
1516 1516
1517/** 1517/**
1518 * Write peer-respect information to a file - flush the buffer entry!
1519 *
1520 * @param cls unused
1521 * @param key peer identity
1522 * @param value the 'struct GSF_ConnectedPeer' to flush
1523 * @return GNUNET_OK to continue iteration
1524 */
1525static int
1526flush_respect (void *cls, const struct GNUNET_PeerIdentity * key, void *value)
1527{
1528 struct GSF_ConnectedPeer *cp = value;
1529 struct GNUNET_PeerIdentity pid;
1530
1531 if (cp->ppd.respect == cp->disk_respect)
1532 return GNUNET_OK; /* unchanged */
1533 GNUNET_assert (0 != cp->ppd.pid);
1534 GNUNET_PEER_resolve (cp->ppd.pid, &pid);
1535 GNUNET_PEERSTORE_store (peerstore, "fs", &pid, "respect", &cp->ppd.respect,
1536 sizeof (cp->ppd.respect),
1537 GNUNET_TIME_UNIT_FOREVER_ABS,
1538 GNUNET_PEERSTORE_STOREOPTION_REPLACE, NULL, NULL);
1539 return GNUNET_OK;
1540}
1541
1542
1543/**
1518 * A peer disconnected from us. Tear down the connected peer 1544 * A peer disconnected from us. Tear down the connected peer
1519 * record. 1545 * record.
1520 * 1546 *
@@ -1533,6 +1559,7 @@ GSF_peer_disconnect_handler_ (void *cls,
1533 if (NULL == cp) 1559 if (NULL == cp)
1534 return; /* must have been disconnect from core with 1560 return; /* must have been disconnect from core with
1535 * 'peer' == my_id, ignore */ 1561 * 'peer' == my_id, ignore */
1562 flush_respect (NULL, peer, cp);
1536 GNUNET_assert (GNUNET_YES == 1563 GNUNET_assert (GNUNET_YES ==
1537 GNUNET_CONTAINER_multipeermap_remove (cp_map, 1564 GNUNET_CONTAINER_multipeermap_remove (cp_map,
1538 peer, 1565 peer,
@@ -1760,32 +1787,6 @@ GSF_block_peer_migration_ (struct GSF_ConnectedPeer *cp,
1760 1787
1761 1788
1762/** 1789/**
1763 * Write peer-respect information to a file - flush the buffer entry!
1764 *
1765 * @param cls unused
1766 * @param key peer identity
1767 * @param value the 'struct GSF_ConnectedPeer' to flush
1768 * @return GNUNET_OK to continue iteration
1769 */
1770static int
1771flush_respect (void *cls, const struct GNUNET_PeerIdentity * key, void *value)
1772{
1773 struct GSF_ConnectedPeer *cp = value;
1774 struct GNUNET_PeerIdentity pid;
1775
1776 if (cp->ppd.respect == cp->disk_respect)
1777 return GNUNET_OK; /* unchanged */
1778 GNUNET_assert (0 != cp->ppd.pid);
1779 GNUNET_PEER_resolve (cp->ppd.pid, &pid);
1780 GNUNET_PEERSTORE_store (peerstore, "fs", &pid, "respect", &cp->ppd.respect,
1781 sizeof (cp->ppd.respect),
1782 GNUNET_TIME_UNIT_FOREVER_ABS,
1783 GNUNET_PEERSTORE_STOREOPTION_REPLACE, NULL, NULL);
1784 return GNUNET_OK;
1785}
1786
1787
1788/**
1789 * Notify core about a preference we have for the given peer 1790 * Notify core about a preference we have for the given peer
1790 * (to allocate more resources towards it). The change will 1791 * (to allocate more resources towards it). The change will
1791 * be communicated the next time we reserve bandwidth with 1792 * be communicated the next time we reserve bandwidth with