Skip to content

Commit

Permalink
modify poll events
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikwidlund committed Jan 9, 2020
1 parent f86a521 commit 07d8cb5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/dynamic/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ void core_loop(core *core)

void core_add(core *core, core_callback *callback, void *state, int fd, int events)
{
int e;
core_handler *handlers;
int e;

while (vector_size(&core->handlers) <= (size_t) fd)
vector_push_back(&core->handlers, &core_handler_default);
Expand All @@ -79,6 +79,20 @@ void core_add(core *core, core_callback *callback, void *state, int fd, int even
core->handlers_active ++;
}

void core_modify(core *core, int fd, int events)
{
core_handler *handlers;
int e;

e = epoll_ctl(core->fd, EPOLL_CTL_MOD, fd, (struct epoll_event[]){{.events = events, .data.fd = fd}});
if (e == -1)
{
handlers = vector_data(&core->handlers);
handlers[fd] = core_handler_default;
core->errors ++;
}
}

void core_delete(core *core, int fd)
{
core_handler *handlers;
Expand Down
1 change: 1 addition & 0 deletions src/dynamic/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ void core_destruct(core *);
core_status core_dispatch(core_handler *, int, uintptr_t);
void core_loop(core *);
void core_add(core *, core_callback *, void *, int, int);
void core_modify(core *, int, int);
void core_delete(core *, int);
int core_queue(core *, core_callback *, void *);
void core_cancel(core *, int);
Expand Down

0 comments on commit 07d8cb5

Please sign in to comment.