--- libev/ev_kqueue.c 2014/01/16 11:51:05 1.55 +++ libev/ev_kqueue.c 2019/07/01 20:47:38 1.60 @@ -1,7 +1,7 @@ /* * libev kqueue backend * - * Copyright (c) 2007,2008,2009,2010,2011,2012,2013 Marc Alexander Lehmann + * Copyright (c) 2007,2008,2009,2010,2011,2012,2013,2016,2019 Marc Alexander Lehmann * All rights reserved. * * Redistribution and use in source and binary forms, with or without modifica- @@ -43,11 +43,12 @@ #include #include -void inline_speed +inline_speed +void kqueue_change (EV_P_ int fd, int filter, int flags, int fflags) { ++kqueue_changecnt; - array_needsize (struct kevent, kqueue_changes, kqueue_changemax, kqueue_changecnt, EMPTY2); + array_needsize (struct kevent, kqueue_changes, kqueue_changemax, kqueue_changecnt, array_needsize_noinit); EV_SET (&kqueue_changes [kqueue_changecnt - 1], fd, filter, flags, fflags, 0, 0); } @@ -102,10 +103,10 @@ EV_ACQUIRE_CB; kqueue_changecnt = 0; - if (expect_false (res < 0)) + if (ecb_expect_false (res < 0)) { if (errno != EINTR) - ev_syserr ("(libev) kevent"); + ev_syserr ("(libev) kqueue kevent"); return; } @@ -114,7 +115,7 @@ { int fd = kqueue_events [i].ident; - if (expect_false (kqueue_events [i].flags & EV_ERROR)) + if (ecb_expect_false (kqueue_events [i].flags & EV_ERROR)) { int err = kqueue_events [i].data; @@ -128,10 +129,16 @@ if (fd_valid (fd)) kqueue_modify (EV_A_ fd, 0, anfds [fd].events); else - fd_kill (EV_A_ fd); + { + assert (("libev: kqueue found invalid fd", 0)); + fd_kill (EV_A_ fd); + } } else /* on all other errors, we error out on the fd */ - fd_kill (EV_A_ fd); + { + assert (("libev: kqueue found invalid fd", 0)); + fd_kill (EV_A_ fd); + } } } else @@ -144,7 +151,7 @@ ); } - if (expect_false (res == kqueue_eventmax)) + if (ecb_expect_false (res == kqueue_eventmax)) { ev_free (kqueue_events); kqueue_eventmax = array_nextsize (sizeof (struct kevent), kqueue_eventmax, kqueue_eventmax + 1); @@ -152,7 +159,8 @@ } } -int inline_size +inline_size +int kqueue_init (EV_P_ int flags) { /* initialize the kernel queue */ @@ -176,14 +184,16 @@ return EVBACKEND_KQUEUE; } -void inline_size +inline_size +void kqueue_destroy (EV_P) { ev_free (kqueue_events); ev_free (kqueue_changes); } -void inline_size +inline_size +void kqueue_fork (EV_P) { /* some BSD kernels don't just destroy the kqueue itself,