Skip to content

Commit

Permalink
fix(kqueue): use timer ns as kqueue identifier.
Browse files Browse the repository at this point in the history
This fixes actually removing a timer from kqueue.

Signed-off-by: Federico Di Pierro <[email protected]>
  • Loading branch information
FedeDP committed Jun 9, 2023
1 parent fe2e7c4 commit 5480e28
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 1 addition & 2 deletions Lib/core/poll/kqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ int poll_create(poll_priv_t *priv) {
}

int poll_set_new_evt(poll_priv_t *priv, ev_src_t *tmp, const enum op_type flag) {
static int timer_ids = 1;
GET_PRIV_DATA();

/* Eventually alloc kqueue data if needed */
Expand Down Expand Up @@ -53,7 +52,7 @@ int poll_set_new_evt(poll_priv_t *priv, ev_src_t *tmp, const enum op_type flag)
#else
const int flags = 0; // unsupported...
#endif
EV_SET(_ev, timer_ids++, EVFILT_TIMER, f, flags | NOTE_NSECONDS, tmp->tmr_src.its.ns, tmp);
EV_SET(_ev, tmp->tmr_src.its.ns, EVFILT_TIMER, f, flags | NOTE_NSECONDS, tmp->tmr_src.its.ns, tmp);
break;
}
case M_SRC_TYPE_SGN:
Expand Down
2 changes: 2 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
### Src
- [x] add an M_SRC_FORCE flag to register_mod_src to force register a src even if the same is already existing (deregistering the old one)?
- [x] double check m_bst_insert/remove usage in src API + add unit tests!
- [ ] Impl M_SRC_FORCE for topic too?
- [ ] add a poll_refresh_src API that calls: epoll_ctl with EPOLL_CTL_MOD, or kqueue ADD to refresh an event trigger, instead of removing and adding back the event

#### Ctx
- [ ] use pthread_setname_np() to store each context thread name (max 16chars len; drop ctx->name field) ?
Expand Down
2 changes: 1 addition & 1 deletion tests/test_mod.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ void test_mod_srcs(void **state) {
(void) state; /* unused */

// 1000s just to test
const m_src_tmr_t my_tmr = {.ns = 1000000000000 };
const m_src_tmr_t my_tmr = {.ns = 5000 };

int ret = m_mod_src_register_tmr(test_mod, &my_tmr, M_SRC_FD_AUTOCLOSE, NULL);
assert_true(ret == 0);
Expand Down

0 comments on commit 5480e28

Please sign in to comment.