Make sure ev_io_stop before ev_io_set

This commit is contained in:
Max Lv
2018-05-07 09:05:38 +08:00
parent 320668e628
commit 8d3ce8b77c
+1 -4
View File
@@ -460,12 +460,9 @@ static void
resolv_sock_state_cb(void *data, int s, int read, int write)
{
struct resolv_ctx *ctx = (struct resolv_ctx *)data;
int io_active = ev_is_active(&ctx->io);
if (read || write) {
if (io_active && ctx->io.fd != s) {
ev_io_stop(default_loop, &ctx->io);
}
ev_io_stop(default_loop, &ctx->io);
ev_io_set(&ctx->io, s, (read ? EV_READ : 0) | (write ? EV_WRITE : 0));
ev_io_start(default_loop, &ctx->io);
} else {