summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2014-03-25 09:57:32 +0100
committerYorhel <git@yorhel.nl>2014-03-25 09:58:04 +0100
commit3f4d46fa7dae01cd3f356e174abeb63605cf1068 (patch)
treea9b6cc0e1470fa2eec77e7cc6be245fe3f35986f
parenteda794dace3e9c68a3ad1e1fa874487662203c0b (diff)
dl: Simplify + randomize dl_queue_sync_kill()brps
-rw-r--r--src/dl.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/dl.c b/src/dl.c
index ca4fd3b..e1d935a 100644
--- a/src/dl.c
+++ b/src/dl.c
@@ -486,13 +486,12 @@ static void dl_queue_sync_kill() {
}
g_debug("dl_queue_sync_kill(): %d selected, %d active, %d not selected but active", numsel, numactive, (int)lst->len);
- if(DL_BRPS_NAIVE || (lst && numactive > numsel)) {
- g_ptr_array_sort(lst, dl_queue_sort_speed);
- // Slowest sorted last, so disconnect last users
- for(i=DL_BRPS_NAIVE ? 0 : lst->len - (numactive-numsel); i<lst->len; i++) {
- dl_user_t *du = lst->pdata[i];
- cc_disconnect(du->cc, TRUE);
- }
+ int max = DL_BRPS_NAIVE ? lst->len : numactive-numsel;
+ for(i=0; i<max; i++) {
+ int idx = g_random_int_range(0, lst->len);
+ du = lst->pdata[idx];
+ g_ptr_array_remove_index_fast(lst, idx);
+ cc_disconnect(du->cc, TRUE);
}
g_ptr_array_unref(lst);