aboutsummaryrefslogtreecommitdiff
path: root/src/fs/gnunet-download.c
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-11-05 18:21:50 +0000
committerNathan S. Evans <evans@in.tum.de>2010-11-05 18:21:50 +0000
commit75a33a1499cf60ea4364c9aa673816629a6c1413 (patch)
tree0620da4312bb04de4d7b65074fdd3b0c3dd6cc0e /src/fs/gnunet-download.c
parent7217c601ad30760872823193d62307e7a335d226 (diff)
downloadgnunet-75a33a1499cf60ea4364c9aa673816629a6c1413.tar.gz
gnunet-75a33a1499cf60ea4364c9aa673816629a6c1413.zip
big scheduler refactoring, expect some issues
Diffstat (limited to 'src/fs/gnunet-download.c')
-rw-r--r--src/fs/gnunet-download.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/src/fs/gnunet-download.c b/src/fs/gnunet-download.c
index 36681e407..99ebb1435 100644
--- a/src/fs/gnunet-download.c
+++ b/src/fs/gnunet-download.c
@@ -38,8 +38,6 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg;
38 38
39static struct GNUNET_FS_Handle *ctx; 39static struct GNUNET_FS_Handle *ctx;
40 40
41static struct GNUNET_SCHEDULER_Handle *sched;
42
43static struct GNUNET_FS_DownloadContext *dc; 41static struct GNUNET_FS_DownloadContext *dc;
44 42
45static unsigned int anonymity = 1; 43static unsigned int anonymity = 1;
@@ -122,7 +120,7 @@ progress_cb (void *cls,
122 fprintf (stderr, 120 fprintf (stderr,
123 _("Error downloading: %s.\n"), 121 _("Error downloading: %s.\n"),
124 info->value.download.specifics.error.message); 122 info->value.download.specifics.error.message);
125 GNUNET_SCHEDULER_shutdown (sched); 123 GNUNET_SCHEDULER_shutdown ();
126 break; 124 break;
127 case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED: 125 case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED:
128 s = GNUNET_STRINGS_byte_size_fancy(info->value.download.completed * 1000 / (info->value.download.duration.rel_value + 1)); 126 s = GNUNET_STRINGS_byte_size_fancy(info->value.download.completed * 1000 / (info->value.download.duration.rel_value + 1));
@@ -132,12 +130,11 @@ progress_cb (void *cls,
132 s); 130 s);
133 GNUNET_free (s); 131 GNUNET_free (s);
134 if (info->value.download.dc == dc) 132 if (info->value.download.dc == dc)
135 GNUNET_SCHEDULER_shutdown (sched); 133 GNUNET_SCHEDULER_shutdown ();
136 break; 134 break;
137 case GNUNET_FS_STATUS_DOWNLOAD_STOPPED: 135 case GNUNET_FS_STATUS_DOWNLOAD_STOPPED:
138 if (info->value.download.dc == dc) 136 if (info->value.download.dc == dc)
139 GNUNET_SCHEDULER_add_continuation (sched, 137 GNUNET_SCHEDULER_add_continuation (&cleanup_task,
140 &cleanup_task,
141 NULL, 138 NULL,
142 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 139 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
143 break; 140 break;
@@ -158,14 +155,12 @@ progress_cb (void *cls,
158 * Main function that will be run by the scheduler. 155 * Main function that will be run by the scheduler.
159 * 156 *
160 * @param cls closure 157 * @param cls closure
161 * @param s the scheduler to use
162 * @param args remaining command-line arguments 158 * @param args remaining command-line arguments
163 * @param cfgfile name of the configuration file used (for saving, can be NULL!) 159 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
164 * @param c configuration 160 * @param c configuration
165 */ 161 */
166static void 162static void
167run (void *cls, 163run (void *cls,
168 struct GNUNET_SCHEDULER_Handle *s,
169 char *const *args, 164 char *const *args,
170 const char *cfgfile, 165 const char *cfgfile,
171 const struct GNUNET_CONFIGURATION_Handle *c) 166 const struct GNUNET_CONFIGURATION_Handle *c)
@@ -174,7 +169,6 @@ run (void *cls,
174 char *emsg; 169 char *emsg;
175 enum GNUNET_FS_DownloadOptions options; 170 enum GNUNET_FS_DownloadOptions options;
176 171
177 sched = s;
178 uri = GNUNET_FS_uri_parse (args[0], 172 uri = GNUNET_FS_uri_parse (args[0],
179 &emsg); 173 &emsg);
180 if (NULL == uri) 174 if (NULL == uri)
@@ -204,8 +198,7 @@ run (void *cls,
204 return; 198 return;
205 } 199 }
206 cfg = c; 200 cfg = c;
207 ctx = GNUNET_FS_start (sched, 201 ctx = GNUNET_FS_start (cfg,
208 cfg,
209 "gnunet-download", 202 "gnunet-download",
210 &progress_cb, 203 &progress_cb,
211 NULL, 204 NULL,
@@ -246,8 +239,7 @@ run (void *cls,
246 ctx = NULL; 239 ctx = NULL;
247 return; 240 return;
248 } 241 }
249 GNUNET_SCHEDULER_add_delayed (sched, 242 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
250 GNUNET_TIME_UNIT_FOREVER_REL,
251 &shutdown_task, 243 &shutdown_task,
252 NULL); 244 NULL);
253} 245}