Skip to content

Commit

Permalink
Only update interests if they have changed.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Feb 2, 2018
1 parent 62e6973 commit f9a856e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions ext/nio4r/monitor.c
Expand Up @@ -296,9 +296,11 @@ static void NIO_Monitor_update_interests(VALUE self, int interests)
rb_ivar_set(self, rb_intern("interests"), Qnil);
}

monitor->interests = interests;
if(monitor->interests != interests) {
monitor->interests = interests;

ev_io_stop(monitor->selector->ev_loop, &monitor->ev_io);
ev_io_set(&monitor->ev_io, monitor->ev_io.fd, monitor->interests);
ev_io_start(monitor->selector->ev_loop, &monitor->ev_io);
ev_io_stop(monitor->selector->ev_loop, &monitor->ev_io);
ev_io_set(&monitor->ev_io, monitor->ev_io.fd, monitor->interests);
ev_io_start(monitor->selector->ev_loop, &monitor->ev_io);
}
}

0 comments on commit f9a856e

Please sign in to comment.