ports/devel/apr1/files/patch-apr-1.7.0_poll_unix_kqueue.c
Jochen Neumeister cc867e3fa0 Update to 1.7.0
*) apr_dir_read: [Unix] Dropped the preference of the dirread_r() flavor
   for dirread(), because the former is both deprecated and unneeded.
   [Yann Ylavic, William Rowe]

*) apr_file_info: [Win32 only] Treat only "name surrogate" reparse points
   as symlinks, and not other reparse tag types. PR47630
   [Oleg Liatte <olegliatte gmail.com>]

*) Test %ld vs. %lld to avoid compiler emits using APR_OFF_T_FMT, in the
   case of apparently equivilant long and long long types. [William Rowe]

*) Recognize APPLE predefined macros as equivilant to DARWIN. [Jim Jagielski]

*) Signals: Allow handling of SIGUSR2 in apr_signal_thread. [Yann Ylavic]

*) Atomics: Support for 64bit ints. [Jim Jagielski]

*) Add the apr_encode_* API that implements RFC4648 and RFC7515
   compliant BASE64, BASE64URL, BASE32, BASE32HEX and BASE16
   encode/decode functions. [Graham Leggett]

*) rand: Use arc4random_buf() on BSD platforms and getrandom() on Linux,
   when available. [Christian Weisgerber <naddy openbsd.org, Yann Ylavic]

*) Add apr_sockaddr_zone_set, apr_sockaddr_zone_set to set and retrieve
   the zone for link-local IPv6 addresses.  [Joe Orton]

*) apr_sockaddr_equal: Compare link-local IPv6 addresses with different
   zones as not equal.  [Joe Orton]

*) apr_sockaddr_ip_getbuf, apr_sockaddr_ip_get: Append "%zone" for
   IPv6 link-local addresses.  [Joe Orton]

*) Locks: add a --disable-timedlocks config option in case users
   encounter more platforms where it fails [Nick Kew].

*) apr_allocator, apr_pools: Add apr_allocator_page_size() and
   apr_allocator_min_order_set() to respectively get the (system's) page size
   in use and set the minimum allocation size for an allocator (expressed in
   2^order pages).  [Yann Ylavic]

*) locks: provide portable implementations of timedlock()s for
   posix-sems, sysv-sems and pthreads for those platforms that
   lack native versions (eg: OSX/macOS). [Jim Jagielski]

*) locks: Introduce apr_{thread,proc,global}_mutex_timedlock().
   [Yann Ylavic]

- Add PORTVERSION (with svn mv) to relevant patches to make it easier for maintaining

PR:		239382
Sponsored by:	Netzkommune GmbH
Differential Revision:	https://reviews.freebsd.org/D21073
2019-08-06 08:58:16 +00:00

77 lines
3.1 KiB
C

# upstram PR: https://bz.apache.org/bugzilla/show_bug.cgi?id=59914
# FreeBSD PR: 211430
========================================================================
--- apr-1.7.0/poll/unix/kqueue.c.orig 2015-03-20 01:34:07 UTC
+++ apr-1.7.0/poll/unix/kqueue.c
@@ -25,21 +25,40 @@
#ifdef HAVE_KQUEUE
-static apr_int16_t get_kqueue_revent(apr_int16_t event, apr_int16_t flags)
+static apr_int16_t get_kqueue_revent(apr_int16_t event, apr_int16_t flags,
+ int fflags, intptr_t data)
{
apr_int16_t rv = 0;
- if (event == EVFILT_READ)
- rv |= APR_POLLIN;
- else if (event == EVFILT_WRITE)
- rv |= APR_POLLOUT;
- if (flags & EV_EOF)
- rv |= APR_POLLHUP;
- /* APR_POLLPRI, APR_POLLERR, and APR_POLLNVAL are not handled by this
- * implementation.
+ /* APR_POLLPRI and APR_POLLNVAL are not handled by this implementation.
* TODO: See if EV_ERROR + certain system errors in the returned data field
* should map to APR_POLLNVAL.
*/
+ if (event == EVFILT_READ) {
+ if (data > 0 || fflags == 0)
+ rv |= APR_POLLIN;
+ else
+ rv |= APR_POLLERR;
+ /*
+ * Don't return POLLHUP if connect fails. Apparently Linux
+ * does not, and this is expected by serf in order for IPv6 to
+ * IPv4 or multihomed host fallback to work.
+ *
+ * ETIMEDOUT is ambiguous here since we don't know if a
+ * connection was established. We don't want to return
+ * POLLHUP here if the connection attempt timed out, but
+ * we do if the connection was successful but later dropped.
+ * For now, favor the latter.
+ */
+ if ((flags & EV_EOF) != 0 && fflags != ECONNREFUSED &&
+ fflags != ENETUNREACH && fflags != EHOSTUNREACH)
+ rv |= APR_POLLHUP;
+ } else if (event == EVFILT_WRITE) {
+ if (data > 0 || fflags == 0)
+ rv |= APR_POLLOUT;
+ else
+ rv |= APR_POLLERR;
+ }
return rv;
}
@@ -290,7 +309,9 @@ static apr_status_t impl_pollset_poll(ap
pollset->p->result_set[j] = fd;
pollset->p->result_set[j].rtnevents =
get_kqueue_revent(pollset->p->ke_set[i].filter,
- pollset->p->ke_set[i].flags);
+ pollset->p->ke_set[i].flags,
+ pollset->p->ke_set[i].fflags,
+ pollset->p->ke_set[i].data);
j++;
}
}
@@ -471,7 +492,9 @@ static apr_status_t impl_pollcb_poll(apr
apr_pollfd_t *pollfd = (apr_pollfd_t *)(pollcb->pollset.ke[i].udata);
pollfd->rtnevents = get_kqueue_revent(pollcb->pollset.ke[i].filter,
- pollcb->pollset.ke[i].flags);
+ pollcb->pollset.ke[i].flags,
+ pollcb->pollset.ke[i].fflags,
+ pollcb->pollset.ke[i].data);
rv = func(baton, pollfd);