Skip to content

Commit

Permalink
event: set signal events to max priority
Browse files Browse the repository at this point in the history
Signed-off-by: hexian000 <hexian000@outlook.com>
  • Loading branch information
hexian000 committed Aug 6, 2023
1 parent 317bee8 commit e1767c8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,15 @@ int main(int argc, char **argv)
{
struct ev_signal *restrict w_sighup = &app.w_sighup;
ev_signal_init(w_sighup, signal_cb, SIGHUP);
ev_set_priority(w_sighup, EV_MAXPRI);
ev_signal_start(loop, w_sighup);
struct ev_signal *restrict w_sigint = &app.w_sigint;
ev_signal_init(w_sigint, signal_cb, SIGINT);
ev_set_priority(w_sigint, EV_MAXPRI);
ev_signal_start(loop, w_sigint);
struct ev_signal *restrict w_sigterm = &app.w_sigterm;
ev_signal_init(w_sigterm, signal_cb, SIGTERM);
ev_set_priority(w_sigterm, EV_MAXPRI);
ev_signal_start(loop, w_sigterm);
}

Expand Down
10 changes: 5 additions & 5 deletions src/transfer.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
} while (0)
#define XFER_CTX_LOG(level, t, message) XFER_CTX_LOG_F(level, t, "%s", message)

static void ev_set_active(
static void ev_io_set_active(
struct ev_loop *loop, struct ev_io *restrict watcher, const bool active)
{
if (!!ev_is_active(watcher) == active) {
Expand Down Expand Up @@ -123,13 +123,13 @@ transfer_cb(struct ev_loop *loop, struct ev_io *watcher, int revents)
/* fallthrough */
case XFER_CONNECTED: {
const bool has_data = t->buf.len > 0;
ev_set_active(loop, &t->w_recv, !has_data);
ev_set_active(loop, &t->w_send, has_data);
ev_io_set_active(loop, &t->w_recv, !has_data);
ev_io_set_active(loop, &t->w_send, has_data);
} break;
case XFER_LINGER:
if (t->buf.len > 0) {
ev_set_active(loop, &t->w_recv, false);
ev_set_active(loop, &t->w_send, true);
ev_io_set_active(loop, &t->w_recv, false);
ev_io_set_active(loop, &t->w_send, true);
break;
}
state = XFER_CLOSED;
Expand Down

0 comments on commit e1767c8

Please sign in to comment.