X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=ucw%2Fmain-rec.c;h=ca313187fdf905490bb498035bff01b7d5e7a1a5;hb=ac5c029143b60498116adbea326eb7b3ce6fa160;hp=3d6ad524e4392d44b1166e291a8f12e1eaa38e01;hpb=5467f05c05e6e41dd1f87f9718c0db01634ab9ae;p=libucw.git diff --git a/ucw/main-rec.c b/ucw/main-rec.c index 3d6ad524..ca313187 100644 --- a/ucw/main-rec.c +++ b/ucw/main-rec.c @@ -1,7 +1,7 @@ /* * UCW Library -- Main Loop: Record I/O * - * (c) 2011 Martin Mares + * (c) 2011--2012 Martin Mares * * This software may be freely distributed and used according to the terms * of the GNU Lesser General Public License. @@ -9,8 +9,8 @@ #undef LOCAL_DEBUG -#include "ucw/lib.h" -#include "ucw/mainloop.h" +#include +#include #include #include @@ -51,9 +51,11 @@ rec_io_add(struct main_rec_io *rio, int fd) void rec_io_del(struct main_rec_io *rio) { + if (!rec_io_is_active(rio)) + return; + timer_del(&rio->timer); - if (hook_is_active(&rio->start_read_hook)) - hook_del(&rio->start_read_hook); + hook_del(&rio->start_read_hook); file_del(&rio->file); if (rio->read_buf) @@ -113,7 +115,6 @@ restart: ; DBG("RIO READ: rec_start=%u avail=%u prev_avail=%u free=%u/%u", rec_start_pos, rio->read_avail, rio->read_prev_avail, free_space, rio->read_buf_size); - // FIXME: Constants? if (free_space <= rio->read_buf_size/8) { if (rec_start_pos && rec_start_pos >= rio->read_buf_size/2) @@ -240,7 +241,8 @@ static void rec_io_stop_write(struct main_rec_io *rio) { DBG("RIO WRITE: Stopping write"); - ASSERT(!rio->write_watermark); + // XXX: When we are called after a write error, there might still + // be some data queued, but we need not care. rio->file.write_handler = NULL; file_chg(&rio->file); }