check n for BSD event set

pull/5/head
yuqing 2015-09-14 09:18:34 +08:00
parent e46333c00a
commit c049d85f96
1 changed files with 14 additions and 2 deletions

View File

@ -129,8 +129,14 @@ int ioevent_modify(IOEventPoller *ioevent, const int fd, const int e,
else if ((ioevent->care_events & IOEVENT_WRITE)) { else if ((ioevent->care_events & IOEVENT_WRITE)) {
EV_SET(&ev[n++], fd, EVFILT_WRITE, EV_DELETE, 0, 0, NULL); EV_SET(&ev[n++], fd, EVFILT_WRITE, EV_DELETE, 0, 0, NULL);
} }
ioevent->care_events = e; ioevent->care_events = e;
if (n > 0) {
return kevent(ioevent->poll_fd, ev, n, NULL, 0, NULL); return kevent(ioevent->poll_fd, ev, n, NULL, 0, NULL);
}
else {
return 0;
}
#elif IOEVENT_USE_PORT #elif IOEVENT_USE_PORT
return port_associate(ioevent->poll_fd, PORT_SOURCE_FD, fd, e, data); return port_associate(ioevent->poll_fd, PORT_SOURCE_FD, fd, e, data);
#endif #endif
@ -149,8 +155,14 @@ int ioevent_detach(IOEventPoller *ioevent, const int fd)
if ((ioevent->care_events & IOEVENT_WRITE)) { if ((ioevent->care_events & IOEVENT_WRITE)) {
EV_SET(&ev[n++], fd, EVFILT_WRITE, EV_DELETE, 0, 0, NULL); EV_SET(&ev[n++], fd, EVFILT_WRITE, EV_DELETE, 0, 0, NULL);
} }
ioevent->care_events = 0; ioevent->care_events = 0;
if (n > 0) {
return kevent(ioevent->poll_fd, ev, n, NULL, 0, NULL); return kevent(ioevent->poll_fd, ev, n, NULL, 0, NULL);
}
else {
return 0;
}
#elif IOEVENT_USE_PORT #elif IOEVENT_USE_PORT
return port_dissociate(ioevent->poll_fd, PORT_SOURCE_FD, fd); return port_dissociate(ioevent->poll_fd, PORT_SOURCE_FD, fd);
#endif #endif