You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by tr...@apache.org on 2009/03/01 13:10:34 UTC
svn commit: r749008 - /apr/apr/trunk/poll/unix/kqueue.c
Author: trawick
Date: Sun Mar 1 12:10:34 2009
New Revision: 749008
URL: http://svn.apache.org/viewvc?rev=749008&view=rev
Log:
Don't return failure or fail to clean up the event queue if the caller
overspecifies the conditions (e.g., APR_POLLIN|APR_POLLOUT when checking
only for APR_POLLOUT).
Modified:
apr/apr/trunk/poll/unix/kqueue.c
Modified: apr/apr/trunk/poll/unix/kqueue.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/poll/unix/kqueue.c?rev=749008&r1=749007&r2=749008&view=diff
==============================================================================
--- apr/apr/trunk/poll/unix/kqueue.c (original)
+++ apr/apr/trunk/poll/unix/kqueue.c Sun Mar 1 12:10:34 2009
@@ -190,7 +190,7 @@
const apr_pollfd_t *descriptor)
{
pfd_elem_t *ep;
- apr_status_t rv = APR_SUCCESS;
+ apr_status_t rv;
apr_os_sock_t fd;
pollset_lock_rings();
@@ -202,21 +202,22 @@
fd = descriptor->desc.f->filedes;
}
+ rv = APR_NOTFOUND; /* unless at least one of the specified conditions is */
if (descriptor->reqevents & APR_POLLIN) {
EV_SET(&pollset->p->kevent, fd, EVFILT_READ, EV_DELETE, 0, 0, NULL);
if (kevent(pollset->p->kqueue_fd, &pollset->p->kevent, 1, NULL, 0,
- NULL) == -1) {
- rv = APR_NOTFOUND;
+ NULL) != -1) {
+ rv = APR_SUCCESS;
}
}
- if (descriptor->reqevents & APR_POLLOUT && rv == APR_SUCCESS) {
+ if (descriptor->reqevents & APR_POLLOUT) {
EV_SET(&pollset->p->kevent, fd, EVFILT_WRITE, EV_DELETE, 0, 0, NULL);
if (kevent(pollset->p->kqueue_fd, &pollset->p->kevent, 1, NULL, 0,
- NULL) == -1) {
- rv = APR_NOTFOUND;
+ NULL) != -1) {
+ rv = APR_SUCCESS;
}
}
@@ -389,7 +390,7 @@
static apr_status_t impl_pollcb_remove(apr_pollcb_t *pollcb,
apr_pollfd_t *descriptor)
{
- apr_status_t rv = APR_SUCCESS;
+ apr_status_t rv;
struct kevent ev;
apr_os_sock_t fd;
@@ -399,23 +400,21 @@
else {
fd = descriptor->desc.f->filedes;
}
-
+
+ rv = APR_NOTFOUND; /* unless at least one of the specified conditions is */
if (descriptor->reqevents & APR_POLLIN) {
EV_SET(&ev, fd, EVFILT_READ, EV_DELETE, 0, 0, NULL);
- if (kevent(pollcb->fd, &ev, 1, NULL, 0, NULL) == -1) {
- rv = APR_NOTFOUND;
+ if (kevent(pollcb->fd, &ev, 1, NULL, 0, NULL) != -1) {
+ rv = APR_SUCCESS;
}
}
- if (descriptor->reqevents & APR_POLLOUT && rv == APR_SUCCESS) {
- /* XXXX: this is less than optimal, shouldn't we still try to
- * remove the FD even if it wasn't in the readset?
- */
+ if (descriptor->reqevents & APR_POLLOUT) {
EV_SET(&ev, fd, EVFILT_WRITE, EV_DELETE, 0, 0, NULL);
- if (kevent(pollcb->fd, &ev, 1, NULL, 0, NULL) == -1) {
- rv = APR_NOTFOUND;
+ if (kevent(pollcb->fd, &ev, 1, NULL, 0, NULL) != -1) {
+ rv = APR_SUCCESS;
}
}