diff options
author | Christian Grothoff <christian@grothoff.org> | 2018-05-10 21:28:38 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2018-05-10 21:28:38 +0200 |
commit | e7b6bcdfd095ba3dfc3f8721a2a1f8a7f69d792b (patch) | |
tree | eeca22e34ba8156374970d64b7e8abf5dc68343f /src | |
parent | c4202563fb4210adf3eb94fbdb6f40e059b63e37 (diff) | |
download | gnunet-e7b6bcdfd095ba3dfc3f8721a2a1f8a7f69d792b.tar.gz gnunet-e7b6bcdfd095ba3dfc3f8721a2a1f8a7f69d792b.zip |
add warning about slow monitors
Diffstat (limited to 'src')
-rw-r--r-- | src/namestore/gnunet-service-namestore.c | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/src/namestore/gnunet-service-namestore.c b/src/namestore/gnunet-service-namestore.c index 6dedcd754..b47b89fe8 100644 --- a/src/namestore/gnunet-service-namestore.c +++ b/src/namestore/gnunet-service-namestore.c | |||
@@ -40,6 +40,11 @@ | |||
40 | 40 | ||
41 | #define LOG_STRERROR_FILE(kind,syscall,filename) GNUNET_log_from_strerror_file (kind, "util", syscall, filename) | 41 | #define LOG_STRERROR_FILE(kind,syscall,filename) GNUNET_log_from_strerror_file (kind, "util", syscall, filename) |
42 | 42 | ||
43 | /** | ||
44 | * If a monitor takes more than 1 minute to process an event, print a warning. | ||
45 | */ | ||
46 | #define MONITOR_STALL_WARN_DELAY GNUNET_TIME_UNIT_MINUTES | ||
47 | |||
43 | 48 | ||
44 | /** | 49 | /** |
45 | * A namestore client | 50 | * A namestore client |
@@ -164,6 +169,16 @@ struct ZoneMonitor | |||
164 | struct GNUNET_SCHEDULER_Task *task; | 169 | struct GNUNET_SCHEDULER_Task *task; |
165 | 170 | ||
166 | /** | 171 | /** |
172 | * Task to warn about slow monitors. | ||
173 | */ | ||
174 | struct GNUNET_SCHEDULER_Task *sa_wait_warning; | ||
175 | |||
176 | /** | ||
177 | * Since when are we blocked on this monitor? | ||
178 | */ | ||
179 | struct GNUNET_TIME_Absolute sa_waiting_start; | ||
180 | |||
181 | /** | ||
167 | * Last sequence number in the zone iteration used to address next | 182 | * Last sequence number in the zone iteration used to address next |
168 | * result of the zone iteration in the store | 183 | * result of the zone iteration in the store |
169 | * | 184 | * |
@@ -825,6 +840,25 @@ refresh_block (struct NamestoreClient *nc, | |||
825 | 840 | ||
826 | 841 | ||
827 | /** | 842 | /** |
843 | * Print a warning that one of our monitors is no longer reacting. | ||
844 | * | ||
845 | * @param cls a `struct ZoneMonitor` to warn about | ||
846 | */ | ||
847 | static void | ||
848 | warn_monitor_slow (void *cls) | ||
849 | { | ||
850 | struct ZoneMonitor *zm = cls; | ||
851 | |||
852 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
853 | "No response from monitor since %s\n", | ||
854 | GNUNET_STRINGS_absolute_time_to_string (zm->sa_waiting_start)); | ||
855 | zm->sa_wait_warning = GNUNET_SCHEDULER_add_delayed (MONITOR_STALL_WARN_DELAY, | ||
856 | &warn_monitor_slow, | ||
857 | zm); | ||
858 | } | ||
859 | |||
860 | |||
861 | /** | ||
828 | * Continue processing the @a sa. | 862 | * Continue processing the @a sa. |
829 | * | 863 | * |
830 | * @param sa store activity to process | 864 | * @param sa store activity to process |
@@ -848,6 +882,12 @@ continue_store_activity (struct StoreActivity *sa) | |||
848 | if (zm->limit == zm->iteration_cnt) | 882 | if (zm->limit == zm->iteration_cnt) |
849 | { | 883 | { |
850 | zm->sa_waiting = GNUNET_YES; | 884 | zm->sa_waiting = GNUNET_YES; |
885 | zm->sa_waiting_start = GNUNET_TIME_absolute_get (); | ||
886 | if (NULL != zm->sa_wait_warning) | ||
887 | GNUNET_SCHEDULER_cancel (zm->sa_wait_warning); | ||
888 | zm->sa_wait_warning = GNUNET_SCHEDULER_add_delayed (MONITOR_STALL_WARN_DELAY, | ||
889 | &warn_monitor_slow, | ||
890 | zm); | ||
851 | return; /* blocked on zone monitor */ | 891 | return; /* blocked on zone monitor */ |
852 | } | 892 | } |
853 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 893 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -934,6 +974,11 @@ client_disconnect_cb (void *cls, | |||
934 | GNUNET_SCHEDULER_cancel (zm->task); | 974 | GNUNET_SCHEDULER_cancel (zm->task); |
935 | zm->task = NULL; | 975 | zm->task = NULL; |
936 | } | 976 | } |
977 | if (NULL != zm->sa_wait_warning) | ||
978 | { | ||
979 | GNUNET_SCHEDULER_cancel (zm->sa_wait_warning); | ||
980 | zm->sa_wait_warning = NULL; | ||
981 | } | ||
937 | for (struct StoreActivity *sa = sa_head; NULL != sa; sa = san) | 982 | for (struct StoreActivity *sa = sa_head; NULL != sa; sa = san) |
938 | { | 983 | { |
939 | san = sa->next; | 984 | san = sa->next; |
@@ -1804,7 +1849,23 @@ monitor_unblock (struct ZoneMonitor *zm) | |||
1804 | sa = sn; | 1849 | sa = sn; |
1805 | } | 1850 | } |
1806 | if (zm->limit > zm->iteration_cnt) | 1851 | if (zm->limit > zm->iteration_cnt) |
1852 | { | ||
1807 | zm->sa_waiting = GNUNET_NO; | 1853 | zm->sa_waiting = GNUNET_NO; |
1854 | if (NULL != zm->sa_wait_warning) | ||
1855 | { | ||
1856 | GNUNET_SCHEDULER_cancel (zm->sa_wait_warning); | ||
1857 | zm->sa_wait_warning = NULL; | ||
1858 | } | ||
1859 | } | ||
1860 | else if (GNUNET_YES == zm->sa_waiting) | ||
1861 | { | ||
1862 | zm->sa_waiting_start = GNUNET_TIME_absolute_get (); | ||
1863 | if (NULL != zm->sa_wait_warning) | ||
1864 | GNUNET_SCHEDULER_cancel (zm->sa_wait_warning); | ||
1865 | zm->sa_wait_warning = GNUNET_SCHEDULER_add_delayed (MONITOR_STALL_WARN_DELAY, | ||
1866 | &warn_monitor_slow, | ||
1867 | zm); | ||
1868 | } | ||
1808 | } | 1869 | } |
1809 | 1870 | ||
1810 | 1871 | ||
@@ -2015,7 +2076,18 @@ handle_monitor_next (void *cls, | |||
2015 | GNUNET_assert (zm->iteration_cnt <= zm->limit); | 2076 | GNUNET_assert (zm->iteration_cnt <= zm->limit); |
2016 | if ( (zm->limit > zm->iteration_cnt) && | 2077 | if ( (zm->limit > zm->iteration_cnt) && |
2017 | (zm->sa_waiting) ) | 2078 | (zm->sa_waiting) ) |
2079 | { | ||
2018 | monitor_unblock (zm); | 2080 | monitor_unblock (zm); |
2081 | } | ||
2082 | else if (GNUNET_YES == zm->sa_waiting) | ||
2083 | { | ||
2084 | if (NULL != zm->sa_wait_warning) | ||
2085 | GNUNET_SCHEDULER_cancel (zm->sa_wait_warning); | ||
2086 | zm->sa_waiting_start = GNUNET_TIME_absolute_get (); | ||
2087 | zm->sa_wait_warning = GNUNET_SCHEDULER_add_delayed (MONITOR_STALL_WARN_DELAY, | ||
2088 | &warn_monitor_slow, | ||
2089 | zm); | ||
2090 | } | ||
2019 | } | 2091 | } |
2020 | 2092 | ||
2021 | 2093 | ||