diff options
author | Rob Austein <sra@hactrn.net> | 2011-10-06 23:40:58 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2011-10-06 23:40:58 +0000 |
commit | e9b805730ad2b5f529023655105792504cd7cd16 (patch) | |
tree | d78276c3ddcae789b2b290307d66ec7796bee4db | |
parent | cd06d1323877db74d658fecc49eef6a8b5e373c7 (diff) |
Rework loop in rsync_mgr() that checks for tasks that have become
runnable. [4018] changed rsync_run()'s behavior slightly, needed to
compensate for that to avoid skipping the next entry in the queue when
rsync_run() detects a cache hit. See #98 for the original problem.
svn path=/rcynic/rcynic.c; revision=4019
-rw-r--r-- | rcynic/rcynic.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/rcynic/rcynic.c b/rcynic/rcynic.c index 97a45d46..72b3af93 100644 --- a/rcynic/rcynic.c +++ b/rcynic/rcynic.c @@ -2234,13 +2234,24 @@ static void rsync_mgr(const rcynic_ctx_t *rc) assert(rsync_count_running(rc) <= rc->max_parallel_fetches); /* - * Look for rsync contexts that have become runable. + * Look for rsync contexts that have become runable. Odd loop + * structure is because rsync_run() might decide to remove the + * specified rsync task from the queue instead of running it. */ - for (i = 0; (ctx = sk_rsync_ctx_t_value(rc->rsync_queue, i)) != NULL; ++i) + i = 0; + n = sk_rsync_ctx_t_num(rc->rsync_queue); + while (i < n) { + ctx = sk_rsync_ctx_t_value(rc->rsync_queue, i); + assert(ctx != NULL); if (ctx->state != rsync_state_running && rsync_runable(rc, ctx) && rsync_count_running(rc) < rc->max_parallel_fetches) rsync_run(rc, ctx); + if (n < sk_rsync_ctx_t_num(rc->rsync_queue)) + n--; + else + i++; + } assert(rsync_count_running(rc) <= rc->max_parallel_fetches); |