View | Details | Raw Unified | Return to bug 59914
Collapse All | Expand All

(-)1.5.2/poll/unix/kqueue.c (-11 / +34 lines)
Lines 25-45 Link Here
25
25
26
#ifdef HAVE_KQUEUE
26
#ifdef HAVE_KQUEUE
27
27
28
static apr_int16_t get_kqueue_revent(apr_int16_t event, apr_int16_t flags)
28
static apr_int16_t get_kqueue_revent(apr_int16_t event, apr_int16_t flags,
29
                                     int fflags, intptr_t data)
29
{
30
{
30
    apr_int16_t rv = 0;
31
    apr_int16_t rv = 0;
31
32
32
    if (event == EVFILT_READ)
33
    /* APR_POLLPRI and APR_POLLNVAL are not handled by this implementation.
33
        rv |= APR_POLLIN;
34
    else if (event == EVFILT_WRITE)
35
        rv |= APR_POLLOUT;
36
    if (flags & EV_EOF)
37
        rv |= APR_POLLHUP;
38
    /* APR_POLLPRI, APR_POLLERR, and APR_POLLNVAL are not handled by this
39
     * implementation.
40
     * TODO: See if EV_ERROR + certain system errors in the returned data field
34
     * TODO: See if EV_ERROR + certain system errors in the returned data field
41
     * should map to APR_POLLNVAL.
35
     * should map to APR_POLLNVAL.
42
     */
36
     */
37
    if (event == EVFILT_READ) {
38
	if (data > 0 || fflags == 0)
39
	    rv |= APR_POLLIN;
40
	else
41
	    rv |= APR_POLLERR;
42
        /*
43
	 * Don't return POLLHUP if connect fails.  Apparently Linux
44
         * does not, and this is expected by serf in order for IPv6 to
45
	 * IPv4 or multihomed host fallback to work.
46
         *
47
	 * ETIMEDOUT is ambiguous here since we don't know if a
48
	 * connection was established.  We don't want to return
49
	 * POLLHUP here if the connection attempt timed out, but
50
	 * we do if the connection was successful but later dropped.
51
	 * For now, favor the latter.
52
	 */
53
	if ((flags & EV_EOF) != 0 && fflags != ECONNREFUSED &&
54
	    fflags != ENETUNREACH && fflags != EHOSTUNREACH)
55
	    rv |= APR_POLLHUP;
56
    } else if (event == EVFILT_WRITE) {
57
	if (data > 0 || fflags == 0)
58
	    rv |= APR_POLLOUT;
59
	else
60
	    rv |= APR_POLLERR;
61
    }
43
    return rv;
62
    return rv;
44
}
63
}
45
64
Lines 290-296 Link Here
290
                pollset->p->result_set[j] = fd;
309
                pollset->p->result_set[j] = fd;
291
                pollset->p->result_set[j].rtnevents =
310
                pollset->p->result_set[j].rtnevents =
292
                        get_kqueue_revent(pollset->p->ke_set[i].filter,
311
                        get_kqueue_revent(pollset->p->ke_set[i].filter,
293
                                          pollset->p->ke_set[i].flags);
312
                                          pollset->p->ke_set[i].flags,
313
                                          pollset->p->ke_set[i].fflags,
314
                                          pollset->p->ke_set[i].data);
294
                j++;
315
                j++;
295
            }
316
            }
296
        }
317
        }
Lines 471-477 Link Here
471
            apr_pollfd_t *pollfd = (apr_pollfd_t *)(pollcb->pollset.ke[i].udata);
492
            apr_pollfd_t *pollfd = (apr_pollfd_t *)(pollcb->pollset.ke[i].udata);
472
            
493
            
473
            pollfd->rtnevents = get_kqueue_revent(pollcb->pollset.ke[i].filter,
494
            pollfd->rtnevents = get_kqueue_revent(pollcb->pollset.ke[i].filter,
474
                                                  pollcb->pollset.ke[i].flags);
495
                                                  pollcb->pollset.ke[i].flags,
496
                                                  pollcb->pollset.ke[i].fflags,
497
                                                  pollcb->pollset.ke[i].data);
475
            
498
            
476
            rv = func(baton, pollfd);
499
            rv = func(baton, pollfd);
477
            
500
            

Return to bug 59914