From bf0ece96fbca9ceee6ebc3c15513fd5ec9052e87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BChler?= Date: Sun, 2 Jan 2011 13:52:18 +0100 Subject: [PATCH] [throttle] Fix segfaults --- src/main/connection.c | 4 ++-- src/main/throttle.c | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/connection.c b/src/main/connection.c index df0c8b7..3033522 100644 --- a/src/main/connection.c +++ b/src/main/connection.c @@ -598,10 +598,10 @@ void li_connection_reset(liConnection *con) { li_buffer_release(con->raw_in_buffer); con->raw_in_buffer = NULL; - li_throttle_reset(con->mainvr); - li_vrequest_reset(con->mainvr, FALSE); + li_throttle_reset(con->mainvr); + /* restore chunkqueue limits */ li_chunkqueue_set_limit(con->raw_in, con->in->limit); li_chunkqueue_set_limit(con->raw_out, con->out->limit); diff --git a/src/main/throttle.c b/src/main/throttle.c index 27750dd..0e49524 100644 --- a/src/main/throttle.c +++ b/src/main/throttle.c @@ -337,7 +337,7 @@ void li_throttle_cb(liWaitQueue *wq, gpointer data) { vr->throttle.magazine += vr->throttle.con.rate / 1000 * THROTTLE_GRANULARITY; } - vr->coninfo->callbacks->handle_check_io(vr); + if (!vr->coninfo->callbacks->handle_check_io(vr)) continue; /* vr got reset */ if (vr->throttle.magazine <= 0) li_throttle_update(vr, 0, 0); @@ -346,6 +346,8 @@ void li_throttle_cb(liWaitQueue *wq, gpointer data) { } void li_throttle_update(liVRequest *vr, goffset transferred, goffset write_max) { + assert(vr->state != LI_VRS_CLEAN); + vr->throttle.magazine -= transferred; if (vr->throttle.magazine <= 0) {