diff --git a/src/box/wal.cc b/src/box/wal.cc index f9e4dff22569fcddf3284d81ee0293b62a97e8a2..c7456cac652920e4c370373c7f055b9cdffdb250 100644 --- a/src/box/wal.cc +++ b/src/box/wal.cc @@ -661,7 +661,7 @@ wal_writer_f(va_list ap) { struct wal_writer *writer = va_arg(ap, struct wal_writer *); /** Initialize eio in this thread */ - coeio_init(); + coeio_enable(); writer->main_f = fiber(); cbus_join(&writer->tx_wal_bus, &writer->wal_pipe); diff --git a/src/coeio.c b/src/coeio.c index 55e8cc9322cf9f12091e638b7b1233402f7c2c2d..f1a4dabe3d7c440af77e89eeb993e88b69c697f4 100644 --- a/src/coeio.c +++ b/src/coeio.c @@ -108,13 +108,39 @@ coeio_done_poll_cb(void *ptr) (void)ptr; } +static int +coeio_on_start(void *data) +{ + (void) data; + struct cord *cord = (struct cord *)calloc(sizeof(struct cord), 1); + if (!cord) + return -1; + cord_create(cord, "coeio"); + return 0; +} + +static int +coeio_on_stop(void *data) +{ + (void) data; + cord_destroy(cord()); + return 0; +} + +void +coeio_init(void) +{ + eio_set_thread_on_start(coeio_on_start, NULL); + eio_set_thread_on_stop(coeio_on_stop, NULL); +} + /** * Init coeio subsystem. * * Create idle and async watchers, init eio. */ void -coeio_init(void) +coeio_enable(void) { eio_init(&coeio_manager, coeio_want_poll_cb, coeio_done_poll_cb); coeio_manager.loop = loop(); @@ -125,14 +151,6 @@ coeio_init(void) ev_async_start(loop(), &coeio_manager.coeio_async); } -void -coeio_set_thread_cb(int (*on_start_cb)(void *), - int (*on_stop_cb)(void *), void *data) -{ - eio_set_thread_on_start(on_start_cb, data); - eio_set_thread_on_stop(on_stop_cb, data); -} - static void coio_on_exec(eio_req *req) { diff --git a/src/coeio.h b/src/coeio.h index 5ffe74c99cb69b78c56be07c2147d7ef44a58c6f..f572120cb0cb7a326d0de12299ee871dc9965d78 100644 --- a/src/coeio.h +++ b/src/coeio.h @@ -49,9 +49,8 @@ extern "C" { */ void coeio_init(void); +void coeio_enable(void); -void coeio_set_thread_cb(int (*on_start_cb)(void *), - int (*on_stop_cb)(void *), void *data); struct coio_task; diff --git a/src/main.cc b/src/main.cc index e755be1e0e1e13dface75906ed7e35f59f4c7ede..2ba2fbcc104dfb782ad81e770751e3cd66169c58 100644 --- a/src/main.cc +++ b/src/main.cc @@ -517,25 +517,6 @@ tarantool_free(void) #endif } -static int -coeio_cord_start(void *data) -{ - (void) data; - struct cord *cord = (struct cord *)calloc(sizeof(struct cord), 1); - if (!cord) - return -1; - cord_create(cord, "coeio"); - return 0; -} - -static int -coeio_cord_stop(void *data) -{ - (void) data; - cord_destroy(cord()); - return 0; -} - int main(int argc, char **argv) { @@ -645,7 +626,7 @@ main(int argc, char **argv) /* Init iobuf library with default readahead */ iobuf_init(); coeio_init(); - coeio_set_thread_cb(coeio_cord_start, coeio_cord_stop, NULL); + coeio_enable(); signal_init(); tarantool_lua_init(tarantool_bin, main_argc, main_argv); box_lua_init(tarantool_L); diff --git a/third_party/libeio/etp.c b/third_party/libeio/etp.c index 81921c85e0de097881beb3f59870dba6a6566303..42f7661ebeb9184d92f67846990e7ff05cad861f 100644 --- a/third_party/libeio/etp.c +++ b/third_party/libeio/etp.c @@ -331,8 +331,7 @@ X_THREAD_PROC (etp_proc) if (pool->on_start_cb) if (pool->on_start_cb(pool->on_start_data)) - goto quit; - + goto error; for (;;) { @@ -393,6 +392,13 @@ X_THREAD_PROC (etp_proc) pool->on_stop_cb(pool->on_stop_data); return 0; + +error: + assert(pool->started > 0); + pool->started--; + X_COND_BROADCAST (pool->wrkwait); + X_UNLOCK (pool->lock); + return 0; } static void ecb_cold