diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-06-21 21:02:45 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-06-21 21:02:45 +0000 |
commit | 7121694a98f57aab4dd60e683b02a84b907d6ad7 (patch) | |
tree | 38f08a3af89de7d02595f5fa59e1816c0294da3b /src/fs | |
parent | cce70bba3782e392b4aaf13d144ddc374cc5b1d0 (diff) | |
download | gnunet-7121694a98f57aab4dd60e683b02a84b907d6ad7.tar.gz gnunet-7121694a98f57aab4dd60e683b02a84b907d6ad7.zip |
-some more work on probes
Diffstat (limited to 'src/fs')
-rw-r--r-- | src/fs/fs_api.c | 77 |
1 files changed, 74 insertions, 3 deletions
diff --git a/src/fs/fs_api.c b/src/fs/fs_api.c index 8a5b1df76..5c6f373ae 100644 --- a/src/fs/fs_api.c +++ b/src/fs/fs_api.c | |||
@@ -174,10 +174,81 @@ process_job_queue (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
174 | break; | 174 | break; |
175 | } | 175 | } |
176 | } | 176 | } |
177 | |||
178 | /* calculate stop decisions */ | ||
179 | num_probes_change = 0; | ||
180 | num_download_change = 0; | ||
181 | if (h->active_downloads + num_download_waiting > h->max_parallel_requests) | ||
182 | { | ||
183 | if (num_probes_active > 0) | ||
184 | num_probes_change = - GNUNET_MIN (num_probes_active, | ||
185 | h->max_parallel_requests - (h->active_downloads + num_download_waiting)); | ||
186 | else if (h->active_downloads + num_download_waiting > h->max_parallel_requests) | ||
187 | num_download_change = - GNUNET_MIN (num_download_expired, | ||
188 | h->max_parallel_requests - (h->active_downloads + num_download_waiting)); | ||
189 | } | ||
190 | |||
191 | /* then, check if we should stop some jobs */ | ||
192 | next = h->running_head; | ||
193 | while (NULL != (qe = next)) | ||
194 | { | ||
195 | next = qe->next; | ||
196 | run_time = | ||
197 | GNUNET_TIME_relative_multiply (h->avg_block_latency, | ||
198 | qe->blocks * qe->start_times); | ||
199 | switch (qe->priority) | ||
200 | { | ||
201 | case GNUNET_FS_QUEUE_PRIORITY_PROBE: | ||
202 | /* run probes for at most 1s * number-of-restarts; note that | ||
203 | as the total runtime of a probe is limited to 2m, we don't | ||
204 | need to additionally limit the total time of a probe to | ||
205 | strictly limit its lifetime. */ | ||
206 | run_time = GNUNET_TIME_relative_min (run_time, | ||
207 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | ||
208 | 1 + qe->start_times)); | ||
209 | end_time = GNUNET_TIME_absolute_add (qe->start_time, run_time); | ||
210 | rst = GNUNET_TIME_absolute_get_remaining (end_time); | ||
211 | restart_at = GNUNET_TIME_relative_min (rst, restart_at); | ||
212 | if ( (num_probes_change < 0) && | ||
213 | ( (num_probes_expired < - num_probes_change) || | ||
214 | (0 == rst.rel_value) ) ) | ||
215 | { | ||
216 | stop_job (qe); | ||
217 | num_probes_change++; | ||
218 | if (0 == rst.rel_value) | ||
219 | num_probes_expired--; | ||
220 | } | ||
221 | break; | ||
222 | case GNUNET_FS_QUEUE_PRIORITY_NORMAL: | ||
223 | end_time = GNUNET_TIME_absolute_add (qe->start_time, run_time); | ||
224 | rst = GNUNET_TIME_absolute_get_remaining (end_time); | ||
225 | restart_at = GNUNET_TIME_relative_min (rst, restart_at); | ||
226 | if ( (num_download_change < 0) && | ||
227 | ( (num_download_expired < - num_download_change) || | ||
228 | (0 == rst.rel_value) ) ) | ||
229 | { | ||
230 | stop_job (qe); | ||
231 | num_download_change++; | ||
232 | if (0 == rst.rel_value) | ||
233 | num_download_expired--; | ||
234 | } | ||
235 | break; | ||
236 | default: | ||
237 | GNUNET_break (0); | ||
238 | break; | ||
239 | } | ||
240 | } | ||
241 | |||
242 | /* FIXME: calculate start decisions */ | ||
243 | num_probes_change = 0; | ||
244 | num_download_change = 0; | ||
245 | if (h->active_downloads + num_download_waiting < h->max_parallel_requests) | ||
246 | { | ||
247 | num_download_change = num_download_waiting; | ||
248 | num_probes_change = GNUNET_MIN (num_probes_waiting, | ||
249 | h->max_parallel_requests - (h->active_downloads + num_download_waiting)); | ||
250 | } | ||
177 | 251 | ||
178 | // FIXME: calculate how many probes/downloads to start/stop | ||
179 | num_probes_change = 42; | ||
180 | num_download_change = 42; | ||
181 | 252 | ||
182 | next = h->pending_head; | 253 | next = h->pending_head; |
183 | while (NULL != (qe = next)) | 254 | while (NULL != (qe = next)) |