libevent/libevent — pull request #103 by dgiagio (2014-01-23 19:51:52+00:00)
Title: Implemented EV_CLOSED event for kqueue backend.

- Implemented EV_CLOSED event for kqueue. Detects premature connection close by clients
without the necessity of reading all the pending data. Does not depend on EV_READ and/or EV_WRITE.

- Added new EV_FEATURE_EARLY_CLOSED feature for kqueue. Must be supported for listening to EV_CLOSED event.

- Existing regression test now working for kqueue: test-closed.c

- All regression tests passed (test/regress and test/test.sh). Tested on OS X Mavericks and FreeBSD 9.0

- FreeBSD truss output:
```
kqueue(0x801021070,0x0,0x0,0x0,0x30,0x7fffffffd010) = 3 (0x3)
kevent(3,{0xffffffffffffffff,EVFILT_READ,EV_ADD,0,0x0,0x0},1,
{0xffffffffffffffff,EVFILT_READ,EV_ERROR,0,0x9,0x0},
64,0x0) = 1 (0x1)
socketpair(0x1,0x1,0x0,0x7fffffffda70,0x10,0x7fffffffd010) = 0 (0x0)
sendto(4,"test string\0",12,0x0,NULL,0x0) = 12 (0xc)
shutdown(4,SHUT_WR) = 0 (0x0)
kevent(3,{0x5,EVFILT_READ,EV_ADD,0,0x0,0x8000},1,
{0x5,EVFILT_READ,EV_EOF,0,0xc,0x8000},
64,{2.999297000 }) = 1 (0x1)
write(1,"closed_cb: detected socket close"...,46) = 46 (0x2e)
```