kqueue.c


Log

Author Commit Date CI Message
Nick Mathewson e465623a 2012-02-10T12:05:39 Merge remote-tracking branch 'origin/patches-2.0'
Nick Mathewson 5d7bfa15 2012-02-10T11:24:51 In the kqueue backend, do not report EBADF as an EV_READ We were doing this because of (correct) reports that NetBSD gives an EBADF when you try to add the write side of a pipe for which the read side has been closed. But on most kqueue platforms, that doesn't happen, and on *all* kqueue platforms, reporting a nonexistent fd (which we usually have if we have seen EBADF) as readable tends to give programs a case of the vapors. Nicholas Marriott wrote the original patch here; I did the comment fixes.
Nick Mathewson 0cb70e33 2011-10-26T10:17:21 Merge remote-tracking branch 'origin/patches-2.0'
Nick Mathewson 3c824bd3 2011-10-24T13:18:09 Update copyright dates to 2011.
Zack Weinberg 148458e0 2011-08-11T09:34:51 Use SIG_IGN instead of a do-nothing handler for signal events with kqueue
Nick Mathewson 89def539 2011-06-16T13:28:40 Merge remote-tracking branch 'origin/patches-2.0'
Nick Mathewson 1fd34ab4 2011-06-08T14:56:19 Report kqueue ebadf, epipe, and eperm as EV_READ events When asked to add one side of a pipe, and the other side has been closed, kqueue on NetBSD will say EBADF; kqueue on FreeBSD will say EPIPE, and kqueue on OpenBSD will say EPERM. So treat all of these as EV_READ events, to give the user an opportunity to notice that the pipe is closed. Diagnosed by Nicholas Marriott and Dale Rahn; based on a patch by Nicholas Marriott.
Nick Mathewson 96107974 2011-05-03T14:29:44 Merge remote-tracking branch 'origin/patches-2.0'
Nick Mathewson 28317a08 2011-05-03T13:54:57 Fix a warn-and-fail bug in kqueue by providing kevent() room to report errors Apparently, kevent fails gracefully if there is not enough space in its output events array to report every _event_... but it just dies and returns -1 if there is not enough space to report every _error_. There are a couple of possible fixes here. One would to handle -1 returns from kevent better by re-growing the array and retrying... but that seems a little error prone. Instead, I'm just going to say that the events array must be large enough to handle all the errors. This patch also adds a unit test designed to make sure that our many-events-out code works even if not all the events are added at once.
Kevin Bowling c13e1859 2011-01-07T00:34:22 Remove use and reference to event-private.h
Kevin Bowling 0915ca0a 2011-01-02T08:43:45 Include evconfig-private.h in internal files for great good.
Kevin Bowling 3b265412 2010-12-22T23:08:10 Remove internal usage of _GNU_SOURCE
Nick Mathewson 5e4bafbb 2010-10-14T13:15:32 fix a signed/unsigned warning in kqueue.c
Sebastian Hahn b3953927 2010-09-27T21:14:28 Fix compile in kqueue.c Commit 38d09606 removed the evsigbase pointer, but forgot to remove an assignment to it in kqueue.c.
Nick Mathewson 4858b794 2010-09-15T01:54:51 Remove the now-useless evsig_caught and evsig_process
Nick Mathewson ec347b92 2010-07-07T16:45:03 Move event-config.h to include/event2 This change means that all required include files are in event2, and all files not in event2/* are optional.
Nick Mathewson 2c2618d8 2010-03-05T13:00:15 more whitespace normalization
Nick Mathewson 17efc1cd 2010-03-04T01:25:51 Update all our copyright notices to say "2010"
Nick Mathewson e5bbd40a 2010-02-18T17:41:15 Clean up formatting: use tabs, not 8-spaces, to indent.
Nick Mathewson 3225dfb9 2010-01-14T17:04:08 Remove kqueue->pend_changes. Since we're no longer writing directly to it from add/del, we don't need to worry about it changing as kq_dispatch releases the lock. We would make it a local variable, except that we wouldn't want to malloc and free it all the time.
Nick Mathewson 45e5ae37 2010-01-14T16:31:05 Make kqueue use changelists. This fixes a bug in kqueue identified by Charles Kerr and various Transmission users, where adding and deleting an event in succession would make the event get reported, even if we didn't actually want to see it. Of course, this also makes the array of changes passed to kevent smaller, which could help performance.
William Ahern 56771a3e 2009-11-29T10:20:46 Valgrind fix: Clear struct kevent before checking for OSX bug. William's original commit message: Valgrind complains on startup because kq_init passes to kevent only a partially initialized structure. The code doesn't expect kevent to look at .fflags, .udata, or .data, I suppose, because it merely tickles the kernel looking for an error response. But perhaps that's unwarranted chuminess (notwithstanding that it's checking for an OS X bug), and needless noise nonetheless.
Nick Mathewson 76cd2b70 2009-11-27T16:44:47 Stop passing EVTHREAD_READ and EVTHREAD_WRITE to non-rw locks. Previously, our default lock model kind of assumed that every lock was potentially a read-write lock. This was a poor choice, since read-write locks are far more expensive than regular locks, and so the lock API should only use them when we can actually take advantage of them. Neither our pthreads or win32 lock implementation provided rw locks. Now that we have a way (not currently used!) to indicate that we really want a read-write lock, we shouldn't actually say "lock this for reading" or "lock this for writing" unless we mean it.
Nick Mathewson e1ffbb82 2009-11-21T01:11:49 Fix memory-leak of signal handler array with kqueue. It turns out that kqueue_dealloc wasn't calling evsig_dealloc() (because it doesn't use the main signal handler logic) so the sh_old array was leaking. This patch also introduces a fix in evsig_dealloc() where we set the sh_old array to NULL when we free it, so that main/fork can pass.
Nick Mathewson 18a8cfac 2009-11-15T19:00:12 Prefer calloc(a,b) to malloc(a*b). via openbsd. svn:r1531
Nick Mathewson 784b8773 2009-11-06T21:46:57 We do not work any more without an event-config.h; stop pretending that it is meaningful to check for HAVE_CONFIG_H svn:r1516
Nick Mathewson 4d48cf61 2009-11-06T21:13:25 Fix kqueue.c build on GNU/kFreeBSD systems. Yes, some people like to have a BSD-family kernel (thus getting kqueue) with a GNU-family libc (thus occasionally mandating _GNU_SOURCE). Thanks to Debian for noticing this. svn:r1514
Nick Mathewson 0fd0255f 2009-11-03T19:54:56 Remove compat/sys/_time.h I've gone through everything that it declared to see where it was used, and it seems that we probably don't need it anywhere. Here's what it declared, and why I think we're okay dropping it. o struct timeval {} (Used all over, and we can't really get away with declaring it ourselves; we need the same definition the system uses. If we can't find struct timeval, we're pretty much sunk.) o struct timespec {} (Used in event.c, evdns.c, kqueue.c, evport.c. Of these, kqueue.c and event.c include sys/_time.h. event.c conditions its use on _EVENT_HAVE_CLOCK_GETTIME, and kqueue() only works if timespec is defined.) o TIMEVAL_TO_TIMESPEC (Used in kqueue.c, but every place with kqueue has sys/time.h) o struct timezone {} (event2/util.h has a forward declaration; only evutil.c references it and doesn't look at its contents.) o timerclear, timerisset, timercmp, timeradd, timersub (Everything now uses the evutil_timer* variants.) o ITIMER_REAL, ITIMER_VIRTUAL, ITIMER_PROF, struct itemerval (These are only used in test/regress.c, which does not include _time.h) o CLOCK_REALTIME (Only used in evdns.c, which does not include _time.h) o TIMESPEC_TO_TIMEVAL o DST_* o timespecclear, timespecisset, timespeccmp, timespecadd, timespecsub o struct clockinfo {} o CLOCK_VIRTUAL, CLOCK_PROF o TIMER_RELTIME, TIMER_ABSTIME (unused) svn:r1494
Nick Mathewson 315fde1a 2009-10-30T22:43:53 Remove some duplicate code in kqueue.c and fix a small memory leak. svn:r1483
Nick Mathewson 369aafc4 2009-10-27T04:03:58 Refactor kq_init error handling. svn:r1467
Nick Mathewson 2e36dbe1 2009-10-26T20:00:43 Use EVUTIL_ASSERT() consistently instead of assert. svn:r1464
Nick Mathewson b89b58b5 2009-10-21T06:03:00 OSX compilation issues svn:r1453
Nick Mathewson 6b22e74a 2009-10-21T03:54:00 Add locking to event_base_loop. This is harder than it sounds, since we need to make sure to release the lock around the key call to the kernel (e.g., select, epoll_wait, kevent), AND we need to make sure that none of the fields that are used in that call are touched by anything that might be running concurrently in another thread. I managed to do this pretty well for everything but poll(). With poll, I needed to introduce a copy of the event_set structure. This patch also fixes a bug in win32.c where we called realloc() instead of mm_realloc(). svn:r1450
Nick Mathewson e3fd294a 2009-10-16T13:19:57 Spelling fixes in comments and strings. svn:r1445
Nick Mathewson b85b710c 2009-01-27T22:34:36 Update copyright statements to reflect the facts that: a) this is 2009 b) niels and nick have been comaintainers for a while c) saying "all rights reserved" when you then go on to explicitly disclaim some rights is sheer cargo-cultism. svn:r1065
Nick Mathewson 8889a770 2009-01-27T22:30:46 Replace all use of config.h with event-config.h. svn:r1064
Nick Mathewson 9993137c 2009-01-27T21:10:31 Remove all trailing whitespace in all the source files. svn:r1063
Nick Mathewson 2b7febc8 2009-01-18T01:33:18 Fix osx compile svn:r1018
Nick Mathewson 554e1493 2009-01-14T20:52:32 Move per-fd info from eventops into evmap. Not done for win32.c yet. svn:r1008
Nick Mathewson 169321c9 2009-01-13T20:26:37 Rename four internal headers to follow the -internal.h convention. svn:r1000
Niels Provos b225e756 2008-12-23T22:24:32 remove unused variable svn:r974
Niels Provos d776f846 2008-12-23T22:23:37 deprecate the usage of signal_{add,del,set} and name it evsignal_{add,del,set} instead; move the old definitions to compat svn:r973
Niels Provos 02b2b4d1 2008-12-23T16:37:01 Restructure the event backends so that they do not need to keep track of events themselves, as a side effect multiple events can use the same fd or signal. svn:r972
Niels Provos f7e61870 2008-07-11T15:49:04 support multiple events listening on the same signal; make signals regular events that go on the same event queue svn:r901
Niels Provos 5512be01 2008-07-11T15:15:04 fix a bug where deleting signals with kqueue would delete subsequent adds svn:r899
Nick Mathewson 05965921 2008-05-31T14:37:31 Add new functions to access backends by their features and to query the features of a backend. svn:r842
Nick Mathewson 39400e68 2008-05-30T16:56:34 Patch from Valery Kholodkov: support for edge-triggered events with epoll and kqueue. Changed from original patch: made test into a regression test, with explicit success/failure for edge-triggered and non-edge-triggered cases. Closes SF request 1968284. svn:r840
Niels Provos 2deb3ce0 2008-05-29T01:39:43 simplify handling of environment variables for disabling backends; make event_get_supported_methods obey environment variables; this fixes make verify; problem reported by Scott Lamb. svn:r838
Nick Mathewson 49868b61 2008-04-25T01:18:08 r15316@tombo: nickm | 2008-04-24 20:58:36 -0400 Rename internal memory management functions from event_malloc() etc to mm_malloc() etc. svn:r725
Nick Mathewson 0ac73078 2008-04-16T20:01:51 r15193@tombo: nickm | 2008-04-16 16:00:35 -0400 Split event.h into several new headers in include/event2. event.h is now just a wrapper that includes all the subheaders. svn:r711
Niels Provos ca42671a 2008-03-29T01:45:45 make event methods static so that they are not exported; from Andrei Nigmatulin svn:r692
Niels Provos 19dad166 2008-03-02T01:46:00 Do not free the kqop file descriptor in other processes, also allow it to be 0; from Andrei Nigmatulin svn:r682
Niels Provos 2fde2217 2008-02-09T16:03:01 address some compiler warnings in debug mode svn:r630
Niels Provos fbe24f43 2007-12-09T05:07:20 remove obsoleted recalc code svn:r581
Niels Provos 5f3e3159 2007-11-27T01:39:10 move EV_PERSIST handling out of the event backends svn:r555
Nick Mathewson 2823cb05 2007-11-25T17:15:28 r14944@tombo: nickm | 2007-11-25 12:12:28 -0500 Make kqueue pass more unit tests. svn:r544
Nick Mathewson 7eb250e9 2007-11-25T17:14:19 r14939@tombo: nickm | 2007-11-25 11:59:26 -0500 New function event_set_mem_functions to replace internal calls to malloc, free, etc with a user-supplied functions. svn:r541
Niels Provos 88897852 2007-11-25T06:57:59 provide event_reinit() to reinitialized an event_base after fork - necessary for epoll/kqueue svn:r539
Nick Mathewson 7d821580 2007-08-10T16:31:02 Fix compile warning on osx: the udata field in struct kevent is supposed to be void*, not intptr_t. svn:r387
Niels Provos 3ad6b47e 2007-07-30T22:41:00 make clock_monotonic work; do not use default timeout; from Scott Lamb, plus some fixes from me. svn:r371
Niels Provos 41b7cbc3 2007-03-10T06:37:53 more the signal base into the event base; this removes global state and makes signals work better with threading; from Wouter Wijngaards small fixes for kqueue and style by me svn:r351
Niels Provos b5d2f9a2 2007-03-01T06:25:18 rolling back r339: evconfig.h does not work svn:r341
Niels Provos 127c260b 2007-02-28T04:02:29 make evconfig.h available as installed header file; not really ideal but good enough for me; from Nick Mathewson svn:r339
Niels Provos 64c76fbe 2006-09-03T21:12:59 typo in kqueue delete; from Bert JW Regeer svn:r232
Niels Provos 2e8051f5 2006-03-28T04:40:54 introduce a way to free the base from Nick Mathewson <nickm@freehaven.net> svn:r210
Niels Provos 139e862e 2005-12-17T20:15:25 do not remove kq inkernel flag before event_del gets to it; bug reported by Tassilo von Parseval; also add a test for this behavior. svn:r190
Niels Provos 9938aaf5 2005-06-11T21:15:22 treate EINVAL as per fd error in kqueue; use argument for debug macros in poll; version 1.1a; EINVAL fix from Nick Mathewson svn:r168
Niels Provos 57fafe6b 2005-05-11T03:34:42 detect kqueue bug in Mac OS X 10.4; from Nick Mathewson svn:r165
Niels Provos 5e2ba12a 2005-04-14T23:28:06 fixes from alexander von gernler svn:r148
Niels Provos d47798be 2005-04-07T03:35:56 return error code when kqueue fails on a specific fd; from alexander von gernler. svn:r145
Niels Provos fbdaf3ab 2005-03-29T07:03:10 debugging callbacks from Nick Mathewson <nickm@freehaven.net> svn:r136
Niels Provos 3ba224db 2005-01-03T18:58:40 fixes for threaded operations from Andrew Danforth svn:r129
Niels Provos 8773c4c9 2004-11-25T09:50:18 make libevent thread-safe; first cut svn:r122
Niels Provos d829ccea 2004-07-30T05:00:44 fix a warning on freebsd; svn:r114
Niels Provos 1b974101 2003-12-20T20:05:17 fix kqueue behaviour; requires special kernel patch to make kqueue semantics consistent; from marius@umich.edu svn:r92
Niels Provos e9cd9b56 2003-10-11T02:54:41 bad realloc; found by awohl at chessclub svn:r87
Niels Provos c3f496c7 2003-10-04T23:27:26 minor corrections; change license to 3-clause BSD license svn:r84
Niels Provos e506eaf7 2003-09-25T03:26:53 constify; some windows stuff by mike davis; fix a poll bug svn:r77
Niels Provos 6ce5b876 2003-06-12T23:33:19 clean up from NetBSD integration svn:r72
Niels Provos 6551780a 2003-06-02T19:37:13 bug fix from Ira Lee svn:r71
Niels Provos 9eb31e53 2003-04-09T18:11:31 proper indent svn:r62
Niels Provos c48e71d8 2003-03-08T16:44:51 oneshot means that its removed from the kernel list already svn:r51
Niels Provos 0036d79a 2003-03-08T16:33:18 fix kqueue problem svn:r50
Niels Provos e72dff13 2003-03-01T20:31:28 replace references to __FUNCTION__ with __func__ svn:r40
Niels Provos 3c2916aa 2003-03-01T19:48:05 ifdef config.h svn:r39
Niels Provos 9d2401ff 2002-10-07T00:47:34 portability fixes from marius@umich.edu. svn:r35
Niels Provos eb15f4d8 2002-09-08T02:46:44 fix from marius@umich.edu svn:r31
Niels Provos 5f865858 2002-07-26T14:45:50 sync with openbsd; API change: timeout_ is now evtimer_ svn:r29
Niels Provos 3821c7e2 2002-06-13T01:54:07 make kqueue signal callback work with sigchld. cast and better timeout. svn:r27
Niels Provos 484e594e 2002-06-11T18:38:37 make kqueue work for callbacks that use both read and write events simultaneously svn:r26
Niels Provos d10f85db 2002-04-10T02:10:47 signal support for kqueue; support of EV_PERSIST flag to event_set svn:r18
Niels Provos aa6567fe 2002-04-09T15:14:06 Initial revision svn:r2