check n for BSD event set
parent
e46333c00a
commit
c049d85f96
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue