From: Pavel Charvat Date: Sun, 11 Feb 2018 16:32:48 +0000 (+0100) Subject: Main recio: Avoid calling of read_handler() with zero available bytes. X-Git-Tag: v6.5.9~5 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=555f79c1d4e8279370f365bcb9bc4a5e136e0e9e;p=libucw.git Main recio: Avoid calling of read_handler() with zero available bytes. The problem was in the deferred hook. Also changed it's return value, hooks like this should always return HOOK_IDLE and not slower HOOK_RETRY. --- diff --git a/ucw/main-rec.c b/ucw/main-rec.c index 7279d99d..f13758e3 100644 --- a/ucw/main-rec.c +++ b/ucw/main-rec.c @@ -77,11 +77,13 @@ static int rec_io_process_read_buf(struct main_rec_io *rio) { uint got; + ASSERT(rio->read_prev_avail < rio->read_avail); while (rio->read_running && (got = rio->read_handler(rio))) { DBG("RIO READ: Ate %u bytes", got); if (got == ~0U) return HOOK_IDLE; + ASSERT(got <= rio->read_avail); rio->read_rec_start += got; rio->read_avail -= got; rio->read_prev_avail = 0; @@ -181,7 +183,10 @@ rec_io_deferred_start_read(struct main_hook *ho) rio->read_running = 1; rio->read_prev_avail = 0; - return rec_io_process_read_buf(rio); + if (rio->read_avail) + rec_io_process_read_buf(rio); + + return HOOK_IDLE; } static void