[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r20252 - gnunet/src/fs
From: |
gnunet |
Subject: |
[GNUnet-SVN] r20252 - gnunet/src/fs |
Date: |
Sun, 4 Mar 2012 23:10:40 +0100 |
Author: grothoff
Date: 2012-03-04 23:10:40 +0100 (Sun, 04 Mar 2012)
New Revision: 20252
Modified:
gnunet/src/fs/fs_api.c
Log:
fixing #1927 by further limiting the time a download probe can be active at a
time in the download queue; this is equivalent to it having a low priority
Modified: gnunet/src/fs/fs_api.c
===================================================================
--- gnunet/src/fs/fs_api.c 2012-03-04 21:51:00 UTC (rev 20251)
+++ gnunet/src/fs/fs_api.c 2012-03-04 22:10:40 UTC (rev 20252)
@@ -99,6 +99,8 @@
struct GNUNET_TIME_Absolute end_time;
h->queue_job = GNUNET_SCHEDULER_NO_TASK;
+ restart_at = GNUNET_TIME_UNIT_FOREVER_REL;
+ /* first, see if we can start all the jobs */
next = h->pending_head;
while (NULL != (qe = next))
{
@@ -109,7 +111,7 @@
continue;
}
if ((qe->blocks + h->active_blocks <= h->max_parallel_requests) &&
- (h->active_downloads + 1 <= h->max_parallel_downloads))
+ (h->active_downloads < h->max_parallel_downloads))
{
start_job (qe);
continue;
@@ -117,7 +119,7 @@
}
if (h->pending_head == NULL)
return; /* no need to stop anything */
- restart_at = GNUNET_TIME_UNIT_FOREVER_REL;
+ /* then, check if we should stop some jobs */
next = h->running_head;
while (NULL != (qe = next))
{
@@ -125,6 +127,22 @@
run_time =
GNUNET_TIME_relative_multiply (h->avg_block_latency,
qe->blocks * qe->start_times);
+ switch (qe->priority)
+ {
+ case GNUNET_FS_QUEUE_PRIORITY_PROBE:
+ /* run probes for at most 1s * number-of-restarts; note that
+ as the total runtime of a probe is limited to 2m, we don't
+ need to additionally limit the total time of a probe to
+ strictly limit its lifetime. */
+ run_time = GNUNET_TIME_relative_min (run_time,
+ GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_SECONDS,
+ 1 +
qe->start_times));
+ break;
+ case GNUNET_FS_QUEUE_PRIORITY_NORMAL:
+ break;
+ default:
+ GNUNET_break (0);
+ }
end_time = GNUNET_TIME_absolute_add (qe->start_time, run_time);
rst = GNUNET_TIME_absolute_get_remaining (end_time);
restart_at = GNUNET_TIME_relative_min (rst, restart_at);
@@ -132,6 +150,18 @@
continue;
stop_job (qe);
}
+ /* finally, start some more tasks if we now have empty slots */
+ next = h->pending_head;
+ while (NULL != (qe = next))
+ {
+ next = qe->next;
+ if ((qe->blocks + h->active_blocks <= h->max_parallel_requests) &&
+ (h->active_downloads < h->max_parallel_downloads))
+ {
+ start_job (qe);
+ continue;
+ }
+ }
h->queue_job =
GNUNET_SCHEDULER_add_delayed (restart_at, &process_job_queue, h);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r20252 - gnunet/src/fs,
gnunet <=