Skip to content
This repository has been archived by the owner on Sep 10, 2021. It is now read-only.

Commit

Permalink
Pull in NetBSD patch from pkgsrc, highlighted by r-stu31. Closes even…
Browse files Browse the repository at this point in the history
  • Loading branch information
raggi committed Sep 29, 2011
1 parent 2ce9e50 commit 922b97b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ext/em.cpp
Expand Up @@ -1396,7 +1396,11 @@ int EventMachine_t::DetachFD (EventableDescriptor *ed)
if (bKqueue) {
// remove any read/write events for this fd
struct kevent k;
#ifdef __NetBSD__
EV_SET (&k, ed->GetSocket(), EVFILT_READ | EVFILT_WRITE, EV_DELETE, 0, 0, (intptr_t)ed);
#else
EV_SET (&k, ed->GetSocket(), EVFILT_READ | EVFILT_WRITE, EV_DELETE, 0, 0, ed);
#endif
int t = kevent (kqfd, &k, 1, NULL, 0, NULL);
if (t < 0 && (errno != ENOENT) && (errno != EBADF)) {
char buf [200];
Expand Down Expand Up @@ -1652,7 +1656,11 @@ void EventMachine_t::ArmKqueueWriter (EventableDescriptor *ed)
if (!ed)
throw std::runtime_error ("added bad descriptor");
struct kevent k;
#ifdef __NetBSD__
EV_SET (&k, ed->GetSocket(), EVFILT_WRITE, EV_ADD | EV_ONESHOT, 0, 0, (intptr_t)ed);
#else
EV_SET (&k, ed->GetSocket(), EVFILT_WRITE, EV_ADD | EV_ONESHOT, 0, 0, ed);
#endif
int t = kevent (kqfd, &k, 1, NULL, 0, NULL);
if (t < 0) {
char buf [200];
Expand All @@ -1674,7 +1682,11 @@ void EventMachine_t::ArmKqueueReader (EventableDescriptor *ed)
if (!ed)
throw std::runtime_error ("added bad descriptor");
struct kevent k;
#ifdef __NetBSD__
EV_SET (&k, ed->GetSocket(), EVFILT_READ, EV_ADD, 0, 0, (intptr_t)ed);
#else
EV_SET (&k, ed->GetSocket(), EVFILT_READ, EV_ADD, 0, 0, ed);
#endif
int t = kevent (kqfd, &k, 1, NULL, 0, NULL);
if (t < 0) {
char buf [200];
Expand Down Expand Up @@ -1725,7 +1737,11 @@ void EventMachine_t::_AddNewDescriptors()
// INCOMPLETE. Some descriptors don't want to be readable.
assert (kqfd != -1);
struct kevent k;
#ifdef __NetBSD__
EV_SET (&k, ed->GetSocket(), EVFILT_READ, EV_ADD, 0, 0, (intptr_t)ed);
#else
EV_SET (&k, ed->GetSocket(), EVFILT_READ, EV_ADD, 0, 0, ed);
#endif
int t = kevent (kqfd, &k, 1, NULL, 0, NULL);
assert (t == 0);
}
Expand Down

0 comments on commit 922b97b

Please sign in to comment.