diff --git a/ChangeLog b/ChangeLog index 748d6b57..07caa5f2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -55,6 +55,7 @@ Changes in current version: o test support for PUT/DELETE requests; from Josh Rotenberg o rewrite of the evbuffer code to reduce memory copies o Some older Solaris versions demand that _REENTRANT be defined to get strtok_r(); do so. + o Do not free the kqop file descriptor in other processes, also allow it to be 0; from Andrei Nigmatulin Changes in 1.4.0: o allow \r or \n individually to separate HTTP headers instead of the standard "\r\n"; from Charles Kerr. diff --git a/kqueue.c b/kqueue.c index 4fb336cf..2c27a7e6 100644 --- a/kqueue.c +++ b/kqueue.c @@ -72,6 +72,7 @@ struct kqop { struct kevent *events; int nevents; int kq; + pid_t pid; }; void *kq_init (struct event_base *); @@ -114,6 +115,8 @@ kq_init(struct event_base *base) kqueueop->kq = kq; + kqueueop->pid = getpid(); + /* Initalize fields */ kqueueop->changes = event_malloc(NEVENT * sizeof(struct kevent)); if (kqueueop->changes == NULL) { @@ -411,7 +414,7 @@ kq_dealloc(struct event_base *base, void *arg) event_free(kqop->changes); if (kqop->events) event_free(kqop->events); - if (kqop->kq) + if (kqop->kq >= 0 && kqop->pid == getpid()) close(kqop->kq); memset(kqop, 0, sizeof(struct kqop)); event_free(kqop);