aboutsummaryrefslogtreecommitdiff
path: root/src/namestore/gnunet-service-namestore.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-05-02 17:27:36 +0200
committerChristian Grothoff <christian@grothoff.org>2018-05-02 17:27:42 +0200
commit7fc3ecc8e8859e8cd47c37457f7991460d81b1ed (patch)
treebaab47fe05f324b10263bcd92828d74ffc1a5b63 /src/namestore/gnunet-service-namestore.c
parent32cc463b677a8bc46b61111fe1bbc38554cb2ca0 (diff)
downloadgnunet-7fc3ecc8e8859e8cd47c37457f7991460d81b1ed.tar.gz
gnunet-7fc3ecc8e8859e8cd47c37457f7991460d81b1ed.zip
start preparations for flow control by namestore monitors
Diffstat (limited to 'src/namestore/gnunet-service-namestore.c')
-rw-r--r--src/namestore/gnunet-service-namestore.c59
1 files changed, 57 insertions, 2 deletions
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c
index fa189dbc3..f47c8776b 100644
--- a/src/namestore/gnunet-service-namestore.c
+++ b/src/namestore/gnunet-service-namestore.c
@@ -169,6 +169,12 @@ struct ZoneMonitor
169 */ 169 */
170 uint64_t seq; 170 uint64_t seq;
171 171
172 /**
173 * Current limit of how many more messages we are allowed
174 * to queue to this monitor.
175 */
176 uint64_t limit;
177
172}; 178};
173 179
174 180
@@ -1667,7 +1673,7 @@ monitor_iterate_cb (void *cls,
1667 * Handles a #GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START message 1673 * Handles a #GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START message
1668 * 1674 *
1669 * @param cls the client sending the message 1675 * @param cls the client sending the message
1670 * @param message message from the client 1676 * @param zis_msg message from the client
1671 */ 1677 */
1672static void 1678static void
1673handle_monitor_start (void *cls, 1679handle_monitor_start (void *cls,
@@ -1685,7 +1691,7 @@ handle_monitor_start (void *cls,
1685 monitor_tail, 1691 monitor_tail,
1686 zm); 1692 zm);
1687 GNUNET_SERVICE_client_mark_monitor (nc->client); 1693 GNUNET_SERVICE_client_mark_monitor (nc->client);
1688 GNUNET_SERVICE_client_disable_continue_warning (nc->client); 1694 GNUNET_SERVICE_client_continue (nc->client);
1689 GNUNET_notification_context_add (monitor_nc, 1695 GNUNET_notification_context_add (monitor_nc,
1690 nc->mq); 1696 nc->mq);
1691 if (GNUNET_YES == ntohl (zis_msg->iterate_first)) 1697 if (GNUNET_YES == ntohl (zis_msg->iterate_first))
@@ -1733,6 +1739,51 @@ monitor_next (void *cls)
1733 1739
1734 1740
1735/** 1741/**
1742 * Handles a #GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_NEXT message
1743 *
1744 * @param cls the client sending the message
1745 * @param nm message from the client
1746 */
1747static void
1748handle_monitor_next (void *cls,
1749 const struct ZoneMonitorNextMessage *nm)
1750{
1751 struct NamestoreClient *nc = cls;
1752 struct ZoneMonitor *zm;
1753 uint64_t inc;
1754
1755 inc = GNUNET_ntohll (nm->limit);
1756 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1757 "Received ZONE_MONITOR_NEXT message with limit %llu\n",
1758 (unsigned long long) inc);
1759 for (zm = monitor_head; NULL != zm; zm = zm->next)
1760 if (zm->nc == nc)
1761 break;
1762 if (NULL == zm)
1763 {
1764 GNUNET_break (0);
1765 GNUNET_SERVICE_client_drop (nc->client);
1766 return;
1767 }
1768 GNUNET_SERVICE_client_continue (nc->client);
1769 if (zm->limit + inc < zm->limit)
1770 {
1771 GNUNET_break (0);
1772 GNUNET_SERVICE_client_drop (nc->client);
1773 return;
1774 }
1775 zm->limit += inc;
1776#if 0
1777 if (GNUNET_YES == ntohl (zis_msg->iterate_first))
1778 zm->task = GNUNET_SCHEDULER_add_now (&monitor_next,
1779 zm);
1780 else
1781 monitor_sync (zm);
1782#endif
1783}
1784
1785
1786/**
1736 * Process namestore requests. 1787 * Process namestore requests.
1737 * 1788 *
1738 * @param cls closure 1789 * @param cls closure
@@ -1831,6 +1882,10 @@ GNUNET_SERVICE_MAIN
1831 GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START, 1882 GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_START,
1832 struct ZoneMonitorStartMessage, 1883 struct ZoneMonitorStartMessage,
1833 NULL), 1884 NULL),
1885 GNUNET_MQ_hd_fixed_size (monitor_next,
1886 GNUNET_MESSAGE_TYPE_NAMESTORE_MONITOR_NEXT,
1887 struct ZoneMonitorNextMessage,
1888 NULL),
1834 GNUNET_MQ_handler_end ()); 1889 GNUNET_MQ_handler_end ());
1835 1890
1836 1891