X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ucw%2Fmain-block.c;h=929533b383a2483391476effdcc7ec976318ae65;hb=0db6e10eac28f38bfc3b325b13ad95107c58ce1e;hp=918cb77762fa4a6c068c3f9858e389f95bee973c;hpb=b0941ddd9272670d8a0b8313191999dcc26993a1;p=libucw.git diff --git a/ucw/main-block.c b/ucw/main-block.c index 918cb777..929533b3 100644 --- a/ucw/main-block.c +++ b/ucw/main-block.c @@ -9,8 +9,8 @@ #undef LOCAL_DEBUG -#include "ucw/lib.h" -#include "ucw/mainloop.h" +#include +#include #include #include @@ -24,7 +24,7 @@ block_io_timer_expired(struct main_timer *tm) struct main_block_io *bio = tm->data; timer_del(&bio->timer); if (bio->error_handler) - bio->error_handler(bio, MFERR_TIMEOUT); + bio->error_handler(bio, BIO_ERR_TIMEOUT); } void @@ -55,8 +55,8 @@ block_io_read_handler(struct main_file *fi) if (l < 0) { if (errno != EINTR && errno != EAGAIN && bio->error_handler) - bio->error_handler(bio, MFERR_READ); - return 0; + bio->error_handler(bio, BIO_ERR_READ); + return HOOK_IDLE; } else if (!l) break; @@ -66,7 +66,7 @@ block_io_read_handler(struct main_file *fi) fi->read_handler = NULL; file_chg(fi); bio->read_done(bio); - return 1; + return HOOK_RETRY; } static int @@ -81,8 +81,8 @@ block_io_write_handler(struct main_file *fi) if (l < 0) { if (errno != EINTR && errno != EAGAIN && bio->error_handler) - bio->error_handler(bio, MFERR_WRITE); - return 0; + bio->error_handler(bio, BIO_ERR_WRITE); + return HOOK_IDLE; } bio->wpos += l; } @@ -90,7 +90,7 @@ block_io_write_handler(struct main_file *fi) fi->write_handler = NULL; file_chg(fi); bio->write_done(bio); - return 1; + return HOOK_RETRY; } void @@ -132,3 +132,12 @@ block_io_write(struct main_block_io *bio, void *buf, uns len) } file_chg(&bio->file); } + +void +block_io_set_timeout(struct main_block_io *bio, timestamp_t expires_delta) +{ + if (!expires_delta) + timer_del(&bio->timer); + else + timer_add_rel(&bio->timer, expires_delta); +}