aboutsummaryrefslogtreecommitdiff
path: root/src/fs
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs')
-rw-r--r--src/fs/gnunet-auto-share.c12
-rw-r--r--src/fs/gnunet-daemon-fsprofiler.c12
-rw-r--r--src/fs/gnunet-download.c4
-rw-r--r--src/fs/gnunet-fs-profiler.c29
-rw-r--r--src/fs/gnunet-publish.c5
-rw-r--r--src/fs/gnunet-search.c20
-rw-r--r--src/fs/gnunet-service-fs.c10
-rw-r--r--src/fs/gnunet-service-fs_cp.c43
-rw-r--r--src/fs/gnunet-service-fs_put.c4
-rw-r--r--src/fs/gnunet-unindex.c4
-rw-r--r--src/fs/test_gnunet_service_fs_migration.c17
11 files changed, 84 insertions, 76 deletions
diff --git a/src/fs/gnunet-auto-share.c b/src/fs/gnunet-auto-share.c
index aef66614c..96f86bf5d 100644
--- a/src/fs/gnunet-auto-share.c
+++ b/src/fs/gnunet-auto-share.c
@@ -95,11 +95,6 @@ static int disable_extractor;
95static int do_disable_creation_time; 95static int do_disable_creation_time;
96 96
97/** 97/**
98 * Handle for the 'shutdown' task.
99 */
100static struct GNUNET_SCHEDULER_Task *kill_task;
101
102/**
103 * Handle for the main task that does scanning and working. 98 * Handle for the main task that does scanning and working.
104 */ 99 */
105static struct GNUNET_SCHEDULER_Task *run_task; 100static struct GNUNET_SCHEDULER_Task *run_task;
@@ -321,7 +316,6 @@ save_state ()
321static void 316static void
322do_stop_task (void *cls) 317do_stop_task (void *cls)
323{ 318{
324 kill_task = NULL;
325 do_shutdown = GNUNET_YES; 319 do_shutdown = GNUNET_YES;
326 if (NULL != publish_proc) 320 if (NULL != publish_proc)
327 { 321 {
@@ -729,10 +723,8 @@ run (void *cls,
729 run_task = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, 723 run_task = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
730 &scan, 724 &scan,
731 NULL); 725 NULL);
732 kill_task = 726 GNUNET_SCHEDULER_add_shutdown (&do_stop_task,
733 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 727 NULL);
734 &do_stop_task,
735 NULL);
736} 728}
737 729
738 730
diff --git a/src/fs/gnunet-daemon-fsprofiler.c b/src/fs/gnunet-daemon-fsprofiler.c
index 326178df9..e6bc33e10 100644
--- a/src/fs/gnunet-daemon-fsprofiler.c
+++ b/src/fs/gnunet-daemon-fsprofiler.c
@@ -500,12 +500,8 @@ start_publish (void *cls)
500{ 500{
501 struct Pattern *p = cls; 501 struct Pattern *p = cls;
502 struct GNUNET_FS_FileInformation *fi; 502 struct GNUNET_FS_FileInformation *fi;
503 const struct GNUNET_SCHEDULER_TaskContext *tc;
504 503
505 p->task = NULL; 504 p->task = NULL;
506 tc = GNUNET_SCHEDULER_get_task_context ();
507 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
508 return;
509 fi = make_file (p->x, p->y, p); 505 fi = make_file (p->x, p->y, p);
510 p->start_time = GNUNET_TIME_absolute_get (); 506 p->start_time = GNUNET_TIME_absolute_get ();
511 p->ctx = GNUNET_FS_publish_start (fs_handle, 507 p->ctx = GNUNET_FS_publish_start (fs_handle,
@@ -525,12 +521,8 @@ start_download (void *cls)
525{ 521{
526 struct Pattern *p = cls; 522 struct Pattern *p = cls;
527 struct GNUNET_FS_Uri *keywords; 523 struct GNUNET_FS_Uri *keywords;
528 const struct GNUNET_SCHEDULER_TaskContext *tc;
529 524
530 p->task = NULL; 525 p->task = NULL;
531 tc = GNUNET_SCHEDULER_get_task_context ();
532 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
533 return;
534 keywords = make_keywords (p->x); 526 keywords = make_keywords (p->x);
535 p->start_time = GNUNET_TIME_absolute_get (); 527 p->start_time = GNUNET_TIME_absolute_get ();
536 p->sctx = GNUNET_FS_search_start (fs_handle, keywords, 528 p->sctx = GNUNET_FS_search_start (fs_handle, keywords,
@@ -558,8 +550,8 @@ run (void *cls, char *const *args GNUNET_UNUSED,
558 550
559 cfg = cfg_; 551 cfg = cfg_;
560 /* Scheduled the task to clean up when shutdown is called */ 552 /* Scheduled the task to clean up when shutdown is called */
561 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, 553 GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
562 NULL); 554 NULL);
563 555
564 if (GNUNET_OK != 556 if (GNUNET_OK !=
565 GNUNET_CONFIGURATION_get_value_number (cfg, 557 GNUNET_CONFIGURATION_get_value_number (cfg,
diff --git a/src/fs/gnunet-download.c b/src/fs/gnunet-download.c
index a2b0aa5fc..6d9adb8ab 100644
--- a/src/fs/gnunet-download.c
+++ b/src/fs/gnunet-download.c
@@ -284,8 +284,8 @@ run (void *cls, char *const *args, const char *cfgfile,
284 ctx = NULL; 284 ctx = NULL;
285 return; 285 return;
286 } 286 }
287 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, 287 GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
288 NULL); 288 NULL);
289} 289}
290 290
291 291
diff --git a/src/fs/gnunet-fs-profiler.c b/src/fs/gnunet-fs-profiler.c
index 69433346f..cfbe57bbd 100644
--- a/src/fs/gnunet-fs-profiler.c
+++ b/src/fs/gnunet-fs-profiler.c
@@ -105,7 +105,7 @@ process_stats (void *cls,
105 105
106 106
107/** 107/**
108 * Task run on timeout to terminate. Triggers printing out 108 * Task run on shutdown to terminate. Triggers printing out
109 * all statistics. 109 * all statistics.
110 * 110 *
111 * @param cls NULL 111 * @param cls NULL
@@ -113,7 +113,11 @@ process_stats (void *cls,
113static void 113static void
114terminate_task (void *cls) 114terminate_task (void *cls)
115{ 115{
116 terminate_taskid = NULL; 116 if (NULL != terminate_taskid)
117 {
118 GNUNET_SCHEDULER_cancel (terminate_taskid);
119 terminate_taskid = NULL;
120 }
117 GNUNET_TESTBED_get_statistics (0, NULL, 121 GNUNET_TESTBED_get_statistics (0, NULL,
118 NULL, NULL, 122 NULL, NULL,
119 &process_stats, 123 &process_stats,
@@ -123,6 +127,20 @@ terminate_task (void *cls)
123 127
124 128
125/** 129/**
130 * Task run on timeout to terminate. Triggers printing out
131 * all statistics.
132 *
133 * @param cls NULL
134 */
135static void
136timeout_task (void *cls)
137{
138 terminate_taskid = NULL;
139 GNUNET_SCHEDULER_shutdown ();
140}
141
142
143/**
126 * Signature of a main function for a testcase. 144 * Signature of a main function for a testcase.
127 * 145 *
128 * @param cls closure 146 * @param cls closure
@@ -148,11 +166,10 @@ test_master (void *cls,
148 166
149 if (0 != timeout.rel_value_us) 167 if (0 != timeout.rel_value_us)
150 terminate_taskid = GNUNET_SCHEDULER_add_delayed (timeout, 168 terminate_taskid = GNUNET_SCHEDULER_add_delayed (timeout,
151 &terminate_task, NULL); 169 &timeout_task,
152 else
153 terminate_taskid = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
154 &terminate_task,
155 NULL); 170 NULL);
171 GNUNET_SCHEDULER_add_shutdown (&terminate_task,
172 NULL);
156} 173}
157 174
158 175
diff --git a/src/fs/gnunet-publish.c b/src/fs/gnunet-publish.c
index f058c10b2..a563d7b7a 100644
--- a/src/fs/gnunet-publish.c
+++ b/src/fs/gnunet-publish.c
@@ -872,9 +872,8 @@ run (void *cls,
872 ret = 1; 872 ret = 1;
873 return; 873 return;
874 } 874 }
875 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 875 GNUNET_SCHEDULER_add_shutdown (&do_stop_task,
876 &do_stop_task, 876 NULL);
877 NULL);
878 if (NULL != pseudonym) 877 if (NULL != pseudonym)
879 identity = GNUNET_IDENTITY_connect (cfg, 878 identity = GNUNET_IDENTITY_connect (cfg,
880 &identity_cb, 879 &identity_cb,
diff --git a/src/fs/gnunet-search.c b/src/fs/gnunet-search.c
index a15d0d883..0ddcd892e 100644
--- a/src/fs/gnunet-search.c
+++ b/src/fs/gnunet-search.c
@@ -55,6 +55,9 @@ static int verbose;
55 55
56static int local_only; 56static int local_only;
57 57
58static struct GNUNET_SCHEDULER_Task *tt;
59
60
58/** 61/**
59 * Type of a function that libextractor calls for each 62 * Type of a function that libextractor calls for each
60 * meta data item found. 63 * meta data item found.
@@ -220,6 +223,14 @@ shutdown_task (void *cls)
220} 223}
221 224
222 225
226static void
227timeout_task (void *cls)
228{
229 tt = NULL;
230 GNUNET_SCHEDULER_shutdown ();
231}
232
233
223/** 234/**
224 * Main function that will be run by the scheduler. 235 * Main function that will be run by the scheduler.
225 * 236 *
@@ -272,10 +283,11 @@ run (void *cls, char *const *args, const char *cfgfile,
272 return; 283 return;
273 } 284 }
274 if (0 != timeout.rel_value_us) 285 if (0 != timeout.rel_value_us)
275 GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_task, NULL); 286 tt = GNUNET_SCHEDULER_add_delayed (timeout,
276 else 287 &timeout_task,
277 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, 288 NULL);
278 NULL); 289 GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
290 NULL);
279} 291}
280 292
281 293
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c
index 2ba96334c..348bab092 100644
--- a/src/fs/gnunet-service-fs.c
+++ b/src/fs/gnunet-service-fs.c
@@ -191,7 +191,8 @@ age_cover_counters (void *cls)
191 GSF_cover_content_count = (GSF_cover_content_count * 15) / 16; 191 GSF_cover_content_count = (GSF_cover_content_count * 15) / 16;
192 GSF_cover_query_count = (GSF_cover_query_count * 15) / 16; 192 GSF_cover_query_count = (GSF_cover_query_count * 15) / 16;
193 cover_age_task = 193 cover_age_task =
194 GNUNET_SCHEDULER_add_delayed (COVER_AGE_FREQUENCY, &age_cover_counters, 194 GNUNET_SCHEDULER_add_delayed (COVER_AGE_FREQUENCY,
195 &age_cover_counters,
195 NULL); 196 NULL);
196} 197}
197 198
@@ -759,13 +760,14 @@ main_init (struct GNUNET_SERVER_Handle *server,
759 NULL); 760 NULL);
760 GNUNET_SERVER_add_handlers (server, handlers); 761 GNUNET_SERVER_add_handlers (server, handlers);
761 cover_age_task = 762 cover_age_task =
762 GNUNET_SCHEDULER_add_delayed (COVER_AGE_FREQUENCY, &age_cover_counters, 763 GNUNET_SCHEDULER_add_delayed (COVER_AGE_FREQUENCY,
764 &age_cover_counters,
763 NULL); 765 NULL);
764 datastore_get_load = GNUNET_LOAD_value_init (DATASTORE_LOAD_AUTODECLINE); 766 datastore_get_load = GNUNET_LOAD_value_init (DATASTORE_LOAD_AUTODECLINE);
765 GSF_cadet_start_server (); 767 GSF_cadet_start_server ();
766 GSF_cadet_start_client (); 768 GSF_cadet_start_client ();
767 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, 769 GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
768 NULL); 770 NULL);
769 return GNUNET_OK; 771 return GNUNET_OK;
770} 772}
771 773
diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c
index e916a73a8..53838a542 100644
--- a/src/fs/gnunet-service-fs_cp.c
+++ b/src/fs/gnunet-service-fs_cp.c
@@ -335,6 +335,11 @@ static struct GNUNET_CONTAINER_MultiPeerMap *cp_map;
335 */ 335 */
336static struct GNUNET_PEERSTORE_Handle *peerstore; 336static struct GNUNET_PEERSTORE_Handle *peerstore;
337 337
338/**
339 * Task used to flush respect values to disk.
340 */
341static struct GNUNET_SCHEDULER_Task *fr_task;
342
338 343
339/** 344/**
340 * Update the latency information kept for the given peer. 345 * Update the latency information kept for the given peer.
@@ -876,19 +881,11 @@ transmit_delayed_now (void *cls)
876{ 881{
877 struct GSF_DelayedHandle *dh = cls; 882 struct GSF_DelayedHandle *dh = cls;
878 struct GSF_ConnectedPeer *cp = dh->cp; 883 struct GSF_ConnectedPeer *cp = dh->cp;
879 const struct GNUNET_SCHEDULER_TaskContext *tc;
880 884
881 GNUNET_CONTAINER_DLL_remove (cp->delayed_head, 885 GNUNET_CONTAINER_DLL_remove (cp->delayed_head,
882 cp->delayed_tail, 886 cp->delayed_tail,
883 dh); 887 dh);
884 cp->delay_queue_size--; 888 cp->delay_queue_size--;
885 tc = GNUNET_SCHEDULER_get_task_context ();
886 if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason))
887 {
888 GNUNET_free (dh->pm);
889 GNUNET_free (dh);
890 return;
891 }
892 (void) GSF_peer_transmit_ (cp, 889 (void) GSF_peer_transmit_ (cp,
893 GNUNET_NO, 890 GNUNET_NO,
894 UINT32_MAX, 891 UINT32_MAX,
@@ -1977,18 +1974,13 @@ GSF_connected_peer_change_preference_ (struct GSF_ConnectedPeer *cp,
1977static void 1974static void
1978cron_flush_respect (void *cls) 1975cron_flush_respect (void *cls)
1979{ 1976{
1980 const struct GNUNET_SCHEDULER_TaskContext *tc; 1977 fr_task = NULL;
1981
1982 if (NULL == cp_map)
1983 return;
1984 GNUNET_CONTAINER_multipeermap_iterate (cp_map, 1978 GNUNET_CONTAINER_multipeermap_iterate (cp_map,
1985 &flush_respect, NULL); 1979 &flush_respect,
1986 tc = GNUNET_SCHEDULER_get_task_context (); 1980 NULL);
1987 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 1981 fr_task = GNUNET_SCHEDULER_add_delayed_with_priority (RESPECT_FLUSH_FREQ,
1988 return; 1982 GNUNET_SCHEDULER_PRIORITY_HIGH,
1989 GNUNET_SCHEDULER_add_delayed_with_priority (RESPECT_FLUSH_FREQ, 1983 &cron_flush_respect, NULL);
1990 GNUNET_SCHEDULER_PRIORITY_HIGH,
1991 &cron_flush_respect, NULL);
1992} 1984}
1993 1985
1994 1986
@@ -2000,8 +1992,8 @@ GSF_connected_peer_init_ ()
2000{ 1992{
2001 cp_map = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_YES); 1993 cp_map = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_YES);
2002 peerstore = GNUNET_PEERSTORE_connect (GSF_cfg); 1994 peerstore = GNUNET_PEERSTORE_connect (GSF_cfg);
2003 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_HIGH, 1995 fr_task = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_HIGH,
2004 &cron_flush_respect, NULL); 1996 &cron_flush_respect, NULL);
2005} 1997}
2006 1998
2007 1999
@@ -2033,10 +2025,15 @@ GSF_connected_peer_done_ ()
2033 &flush_respect, 2025 &flush_respect,
2034 NULL); 2026 NULL);
2035 GNUNET_CONTAINER_multipeermap_iterate (cp_map, 2027 GNUNET_CONTAINER_multipeermap_iterate (cp_map,
2036 &clean_peer, NULL); 2028 &clean_peer,
2029 NULL);
2030 GNUNET_SCHEDULER_cancel (fr_task);
2031 fr_task = NULL;
2037 GNUNET_CONTAINER_multipeermap_destroy (cp_map); 2032 GNUNET_CONTAINER_multipeermap_destroy (cp_map);
2038 cp_map = NULL; 2033 cp_map = NULL;
2039 GNUNET_PEERSTORE_disconnect (peerstore, GNUNET_YES); 2034 GNUNET_PEERSTORE_disconnect (peerstore,
2035 GNUNET_YES);
2036
2040} 2037}
2041 2038
2042 2039
diff --git a/src/fs/gnunet-service-fs_put.c b/src/fs/gnunet-service-fs_put.c
index fa5aa461d..045b640db 100644
--- a/src/fs/gnunet-service-fs_put.c
+++ b/src/fs/gnunet-service-fs_put.c
@@ -215,12 +215,8 @@ static void
215gather_dht_put_blocks (void *cls) 215gather_dht_put_blocks (void *cls)
216{ 216{
217 struct PutOperator *po = cls; 217 struct PutOperator *po = cls;
218 const struct GNUNET_SCHEDULER_TaskContext *tc;
219 218
220 po->dht_task = NULL; 219 po->dht_task = NULL;
221 tc = GNUNET_SCHEDULER_get_task_context ();
222 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
223 return;
224 po->dht_qe = 220 po->dht_qe =
225 GNUNET_DATASTORE_get_zero_anonymity (GSF_dsh, po->current_offset++, 0, 221 GNUNET_DATASTORE_get_zero_anonymity (GSF_dsh, po->current_offset++, 0,
226 UINT_MAX, 222 UINT_MAX,
diff --git a/src/fs/gnunet-unindex.c b/src/fs/gnunet-unindex.c
index cab963e0d..40fa13b62 100644
--- a/src/fs/gnunet-unindex.c
+++ b/src/fs/gnunet-unindex.c
@@ -147,8 +147,8 @@ run (void *cls, char *const *args, const char *cfgfile,
147 GNUNET_FS_stop (ctx); 147 GNUNET_FS_stop (ctx);
148 return; 148 return;
149 } 149 }
150 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, 150 GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
151 NULL); 151 NULL);
152} 152}
153 153
154 154
diff --git a/src/fs/test_gnunet_service_fs_migration.c b/src/fs/test_gnunet_service_fs_migration.c
index f00290b0d..2ff495ac3 100644
--- a/src/fs/test_gnunet_service_fs_migration.c
+++ b/src/fs/test_gnunet_service_fs_migration.c
@@ -142,15 +142,13 @@ static void
142stop_source_peer (void *cls) 142stop_source_peer (void *cls)
143{ 143{
144 struct DownloadContext *dc = cls; 144 struct DownloadContext *dc = cls;
145 const struct GNUNET_SCHEDULER_TaskContext *tc;
146 145
147 tc = GNUNET_SCHEDULER_get_task_context (); 146 /* FIXME: We should not interact with testbed when shutting down */
148 /* Do not interact with testbed when shutting down */
149 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
150 return;
151 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 147 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
152 "Stopping source peer\n"); 148 "Stopping source peer\n");
153 op = GNUNET_TESTBED_peer_stop (NULL, daemons[1], &do_download, dc); 149 op = GNUNET_TESTBED_peer_stop (NULL,
150 daemons[1],
151 &do_download, dc);
154 GNUNET_assert (NULL != op); 152 GNUNET_assert (NULL != op);
155} 153}
156 154
@@ -176,7 +174,9 @@ do_wait (void *cls,
176 dc->uri = GNUNET_FS_uri_dup (uri); 174 dc->uri = GNUNET_FS_uri_dup (uri);
177 if (NULL != fn) 175 if (NULL != fn)
178 dc->fn = GNUNET_strdup (fn); 176 dc->fn = GNUNET_strdup (fn);
179 (void) GNUNET_SCHEDULER_add_delayed (MIGRATION_DELAY, &stop_source_peer, dc); 177 (void) GNUNET_SCHEDULER_add_delayed (MIGRATION_DELAY,
178 &stop_source_peer,
179 dc);
180} 180}
181 181
182 182
@@ -196,7 +196,8 @@ do_publish (void *cls,
196 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 196 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
197 "Publishing %llu bytes\n", 197 "Publishing %llu bytes\n",
198 (unsigned long long) FILESIZE); 198 (unsigned long long) FILESIZE);
199 GNUNET_FS_TEST_publish (daemons[1], TIMEOUT, 1, GNUNET_NO, FILESIZE, SEED, 199 GNUNET_FS_TEST_publish (daemons[1], TIMEOUT, 1, GNUNET_NO,
200 FILESIZE, SEED,
200 VERBOSE, &do_wait, NULL); 201 VERBOSE, &do_wait, NULL);
201} 202}
202 203