diff options
author | Nathan S. Evans <evans@in.tum.de> | 2010-11-05 18:21:50 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2010-11-05 18:21:50 +0000 |
commit | 75a33a1499cf60ea4364c9aa673816629a6c1413 (patch) | |
tree | 0620da4312bb04de4d7b65074fdd3b0c3dd6cc0e /src/fs/test_fs_download_persistence.c | |
parent | 7217c601ad30760872823193d62307e7a335d226 (diff) | |
download | gnunet-75a33a1499cf60ea4364c9aa673816629a6c1413.tar.gz gnunet-75a33a1499cf60ea4364c9aa673816629a6c1413.zip |
big scheduler refactoring, expect some issues
Diffstat (limited to 'src/fs/test_fs_download_persistence.c')
-rw-r--r-- | src/fs/test_fs_download_persistence.c | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/src/fs/test_fs_download_persistence.c b/src/fs/test_fs_download_persistence.c index 966d52412..66d1199ca 100644 --- a/src/fs/test_fs_download_persistence.c +++ b/src/fs/test_fs_download_persistence.c | |||
@@ -60,8 +60,6 @@ static struct PeerContext p1; | |||
60 | 60 | ||
61 | static struct GNUNET_TIME_Absolute start; | 61 | static struct GNUNET_TIME_Absolute start; |
62 | 62 | ||
63 | static struct GNUNET_SCHEDULER_Handle *sched; | ||
64 | |||
65 | static const struct GNUNET_CONFIGURATION_Handle *cfg; | 63 | static const struct GNUNET_CONFIGURATION_Handle *cfg; |
66 | 64 | ||
67 | static struct GNUNET_FS_Handle *fs; | 65 | static struct GNUNET_FS_Handle *fs; |
@@ -122,7 +120,7 @@ abort_download_task (void *cls, | |||
122 | GNUNET_DISK_directory_remove (fn); | 120 | GNUNET_DISK_directory_remove (fn); |
123 | GNUNET_free (fn); | 121 | GNUNET_free (fn); |
124 | fn = NULL; | 122 | fn = NULL; |
125 | GNUNET_SCHEDULER_cancel (sched, timeout_kill); | 123 | GNUNET_SCHEDULER_cancel (timeout_kill); |
126 | timeout_kill = GNUNET_SCHEDULER_NO_TASK; | 124 | timeout_kill = GNUNET_SCHEDULER_NO_TASK; |
127 | } | 125 | } |
128 | 126 | ||
@@ -137,8 +135,7 @@ restart_fs_task (void *cls, | |||
137 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 135 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
138 | { | 136 | { |
139 | GNUNET_FS_stop (fs); | 137 | GNUNET_FS_stop (fs); |
140 | fs = GNUNET_FS_start (sched, | 138 | fs = GNUNET_FS_start (cfg, |
141 | cfg, | ||
142 | "test-fs-download-persistence", | 139 | "test-fs-download-persistence", |
143 | &progress_cb, | 140 | &progress_cb, |
144 | NULL, | 141 | NULL, |
@@ -164,8 +161,7 @@ consider_restart (int ev) | |||
164 | if (prev[i] == ev) | 161 | if (prev[i] == ev) |
165 | return; | 162 | return; |
166 | prev[off++] = ev; | 163 | prev[off++] = ev; |
167 | GNUNET_SCHEDULER_add_with_priority (sched, | 164 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_URGENT, |
168 | GNUNET_SCHEDULER_PRIORITY_URGENT, | ||
169 | &restart_fs_task, | 165 | &restart_fs_task, |
170 | NULL); | 166 | NULL); |
171 | } | 167 | } |
@@ -207,8 +203,7 @@ progress_cb (void *cls, | |||
207 | consider_restart (event->status); | 203 | consider_restart (event->status); |
208 | printf ("Download complete, %llu kbps.\n", | 204 | printf ("Download complete, %llu kbps.\n", |
209 | (unsigned long long) (FILESIZE * 1000LL / (1+GNUNET_TIME_absolute_get_duration (start).rel_value) / 1024LL)); | 205 | (unsigned long long) (FILESIZE * 1000LL / (1+GNUNET_TIME_absolute_get_duration (start).rel_value) / 1024LL)); |
210 | GNUNET_SCHEDULER_add_now (sched, | 206 | GNUNET_SCHEDULER_add_now (&abort_download_task, |
211 | &abort_download_task, | ||
212 | NULL); | 207 | NULL); |
213 | break; | 208 | break; |
214 | case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS: | 209 | case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS: |
@@ -227,8 +222,7 @@ progress_cb (void *cls, | |||
227 | "Error publishing file: %s\n", | 222 | "Error publishing file: %s\n", |
228 | event->value.publish.specifics.error.message); | 223 | event->value.publish.specifics.error.message); |
229 | GNUNET_break (0); | 224 | GNUNET_break (0); |
230 | GNUNET_SCHEDULER_add_continuation (sched, | 225 | GNUNET_SCHEDULER_add_continuation (&abort_publish_task, |
231 | &abort_publish_task, | ||
232 | NULL, | 226 | NULL, |
233 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 227 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
234 | break; | 228 | break; |
@@ -236,8 +230,7 @@ progress_cb (void *cls, | |||
236 | fprintf (stderr, | 230 | fprintf (stderr, |
237 | "Error downloading file: %s\n", | 231 | "Error downloading file: %s\n", |
238 | event->value.download.specifics.error.message); | 232 | event->value.download.specifics.error.message); |
239 | GNUNET_SCHEDULER_add_now (sched, | 233 | GNUNET_SCHEDULER_add_now (&abort_download_task, |
240 | &abort_download_task, | ||
241 | NULL); | 234 | NULL); |
242 | break; | 235 | break; |
243 | case GNUNET_FS_STATUS_PUBLISH_SUSPEND: | 236 | case GNUNET_FS_STATUS_PUBLISH_SUSPEND: |
@@ -290,8 +283,7 @@ progress_cb (void *cls, | |||
290 | break; | 283 | break; |
291 | case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: | 284 | case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: |
292 | GNUNET_assert (download == event->value.download.dc); | 285 | GNUNET_assert (download == event->value.download.dc); |
293 | GNUNET_SCHEDULER_add_continuation (sched, | 286 | GNUNET_SCHEDULER_add_continuation (&abort_publish_task, |
294 | &abort_publish_task, | ||
295 | NULL, | 287 | NULL, |
296 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 288 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
297 | download = NULL; | 289 | download = NULL; |
@@ -340,7 +332,6 @@ stop_arm (struct PeerContext *p) | |||
340 | 332 | ||
341 | static void | 333 | static void |
342 | run (void *cls, | 334 | run (void *cls, |
343 | struct GNUNET_SCHEDULER_Handle *s, | ||
344 | char *const *args, | 335 | char *const *args, |
345 | const char *cfgfile, | 336 | const char *cfgfile, |
346 | const struct GNUNET_CONFIGURATION_Handle *c) | 337 | const struct GNUNET_CONFIGURATION_Handle *c) |
@@ -355,11 +346,9 @@ run (void *cls, | |||
355 | struct GNUNET_FS_FileInformation *fi; | 346 | struct GNUNET_FS_FileInformation *fi; |
356 | size_t i; | 347 | size_t i; |
357 | 348 | ||
358 | sched = s; | ||
359 | cfg = c; | 349 | cfg = c; |
360 | setup_peer (&p1, "test_fs_download_data.conf"); | 350 | setup_peer (&p1, "test_fs_download_data.conf"); |
361 | fs = GNUNET_FS_start (sched, | 351 | fs = GNUNET_FS_start (cfg, |
362 | cfg, | ||
363 | "test-fs-download-persistence", | 352 | "test-fs-download-persistence", |
364 | &progress_cb, | 353 | &progress_cb, |
365 | NULL, | 354 | NULL, |
@@ -384,8 +373,7 @@ run (void *cls, | |||
384 | GNUNET_FS_uri_destroy (kuri); | 373 | GNUNET_FS_uri_destroy (kuri); |
385 | GNUNET_CONTAINER_meta_data_destroy (meta); | 374 | GNUNET_CONTAINER_meta_data_destroy (meta); |
386 | GNUNET_assert (NULL != fi); | 375 | GNUNET_assert (NULL != fi); |
387 | timeout_kill = GNUNET_SCHEDULER_add_delayed (sched, | 376 | timeout_kill = GNUNET_SCHEDULER_add_delayed (TIMEOUT, |
388 | TIMEOUT, | ||
389 | &timeout_kill_task, | 377 | &timeout_kill_task, |
390 | NULL); | 378 | NULL); |
391 | start = GNUNET_TIME_absolute_get (); | 379 | start = GNUNET_TIME_absolute_get (); |