Skip to content

Commit 3683ce3

Browse files
committed
lib: monkey: upgrade to v1.8.6
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
1 parent 7caffd1 commit 3683ce3

File tree

6 files changed

+20
-28
lines changed

6 files changed

+20
-28
lines changed

lib/monkey/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ endif()
2323
# Monkey Version
2424
set(MK_VERSION_MAJOR 1)
2525
set(MK_VERSION_MINOR 8)
26-
set(MK_VERSION_PATCH 5)
26+
set(MK_VERSION_PATCH 6)
2727
set(MK_VERSION_STR "${MK_VERSION_MAJOR}.${MK_VERSION_MINOR}.${MK_VERSION_PATCH}")
2828

2929
# Output paths

lib/monkey/mk_core/mk_event_epoll.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,14 +398,11 @@ static inline int _mk_event_channel_destroy(struct mk_event_ctx *ctx,
398398
}
399399

400400
ret = _mk_event_del(ctx, event);
401-
if (ret != 0) {
402-
return ret;
403-
}
404401

405402
close(r_fd);
406403
close(w_fd);
407404

408-
return 0;
405+
return ret;
409406
}
410407

411408
static inline int _mk_event_inject(struct mk_event_loop *loop,

lib/monkey/mk_core/mk_event_kqueue.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,9 @@ static inline int _mk_event_add(struct mk_event_ctx *ctx, int fd,
7474
int ret;
7575
int set = MK_FALSE;
7676
struct mk_event *event;
77-
struct kevent ke = {0, 0, 0, 0, 0, 0};
77+
struct kevent ke;
7878

79+
EV_SET(&ke, 0, 0, 0, 0, 0, 0);
7980
mk_bug(ctx == NULL);
8081
mk_bug(data == NULL);
8182

@@ -142,8 +143,9 @@ static inline int _mk_event_add(struct mk_event_ctx *ctx, int fd,
142143
static inline int _mk_event_del(struct mk_event_ctx *ctx, struct mk_event *event)
143144
{
144145
int ret;
145-
struct kevent ke = {0, 0, 0, 0, 0, 0};
146+
struct kevent ke;
146147

148+
EV_SET(&ke, 0, 0, 0, 0, 0, 0);
147149
mk_bug(ctx == NULL);
148150
mk_bug(event == NULL);
149151

@@ -208,12 +210,16 @@ static inline int _mk_event_timeout_create(struct mk_event_ctx *ctx,
208210
event->priority = MK_EVENT_PRIORITY_DEFAULT;
209211
mk_list_entry_init(&event->_priority_head);
210212

211-
#if defined(NOTE_SECONDS) && !defined(__APPLE__)
212-
/* FreeBSD or LINUX_KQUEUE defined */
213-
/* TODO : high resolution interval support. */
213+
#if defined(NOTE_NSECONDS)
214+
/* The modern FreeBSD & NetBSD & OpenBSD & macOS have a high-resolution
215+
event timer. */
216+
EV_SET(&ke, fd, EVFILT_TIMER, EV_ADD, NOTE_NSECONDS,
217+
(sec * 1000000000) + nsec, event);
218+
#elif defined(NOTE_SECONDS) && !defined(__APPLE__)
219+
/* LINUX_KQUEUE defined */
214220
EV_SET(&ke, fd, EVFILT_TIMER, EV_ADD, NOTE_SECONDS, sec, event);
215221
#else
216-
/* Other BSD have no NOTE_SECONDS & specify milliseconds */
222+
/* Keep backward compatibility; use the millisecond-resolution event timer. */
217223
/* Also, on macOS, NOTE_SECONDS has severe side effect that cause
218224
* performance degradation. */
219225
EV_SET(&ke, fd, EVFILT_TIMER, EV_ADD, 0, (sec * 1000) + (nsec / 1000000) , event);
@@ -239,8 +245,9 @@ static inline int _mk_event_timeout_destroy(struct mk_event_ctx *ctx, void *data
239245
{
240246
int ret;
241247
struct mk_event *event;
242-
struct kevent ke = {0, 0, 0, 0, 0, 0};
248+
struct kevent ke;
243249

250+
EV_SET(&ke, 0, 0, 0, 0, 0, 0);
244251
if (data == NULL) {
245252
return 0;
246253
}
@@ -316,14 +323,11 @@ static inline int _mk_event_channel_destroy(struct mk_event_ctx *ctx,
316323
}
317324

318325
ret = _mk_event_del(ctx, event);
319-
if (ret != 0) {
320-
return ret;
321-
}
322326

323327
close(r_fd);
324328
close(w_fd);
325329

326-
return 0;
330+
return ret;
327331
}
328332

329333
static inline int _mk_event_inject(struct mk_event_loop *loop,

lib/monkey/mk_core/mk_event_libevent.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,14 +404,11 @@ static inline int _mk_event_channel_destroy(struct mk_event_ctx *ctx,
404404
}
405405

406406
ret = _mk_event_del(ctx, event);
407-
if (ret != 0) {
408-
return ret;
409-
}
410407

411408
evutil_closesocket(r_fd);
412409
evutil_closesocket(w_fd);
413410

414-
return 0;
411+
return ret;
415412
}
416413

417414
static inline int _mk_event_inject(struct mk_event_loop *loop,

lib/monkey/mk_core/mk_event_poll.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,14 +332,11 @@ static inline int _mk_event_channel_destroy(struct mk_event_ctx *ctx,
332332
}
333333

334334
ret = _mk_event_del(ctx, event);
335-
if (ret != 0) {
336-
return ret;
337-
}
338335

339336
close(r_fd);
340337
close(w_fd);
341338

342-
return 0;
339+
return ret;
343340
}
344341

345342
static inline int _mk_event_inject(struct mk_event_loop *loop,

lib/monkey/mk_core/mk_event_select.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,14 +345,11 @@ static inline int _mk_event_channel_destroy(struct mk_event_ctx *ctx,
345345
}
346346

347347
ret = _mk_event_del(ctx, event);
348-
if (ret != 0) {
349-
return ret;
350-
}
351348

352349
close(r_fd);
353350
close(w_fd);
354351

355-
return 0;
352+
return ret;
356353
}
357354

358355
static inline int _mk_event_inject(struct mk_event_loop *loop,

0 commit comments

Comments
 (0)