diff -Paur --no-dereference -- libevent.upstream/bufferevent_sock.c libevent/bufferevent_sock.c --- libevent.upstream/bufferevent_sock.c +++ libevent/bufferevent_sock.c @@ -64,6 +64,7 @@ #include "event2/util.h" #include "event2/bufferevent.h" #include "event2/buffer.h" +#include "event2/buffer_compat.h" #include "event2/bufferevent_struct.h" #include "event2/bufferevent_compat.h" #include "event2/event.h" @@ -76,6 +77,7 @@ #endif /* prototypes */ +void bufferevent_read_pressure_cb(struct evbuffer *, size_t, size_t, void *); static int be_socket_enable(struct bufferevent *, short); static int be_socket_disable(struct bufferevent *, short); static void be_socket_destruct(struct bufferevent *); @@ -145,6 +147,40 @@ } } +static int +bufferevent_add(struct event *ev, struct timeval timeout) +{ + struct timeval *ptv = NULL; + + if (timeout.tv_sec || timeout.tv_usec) { + ptv = &timeout; + } + + return (event_add(ev, ptv)); +} + +/* + * This callback is executed when the size of the input buffer changes. + * We use it to apply back pressure on the reading side. + */ + +/* This API was needed to port OpenBSD's httpd to Sortix. */ +void +bufferevent_read_pressure_cb(struct evbuffer *buf, size_t old, size_t now, + void *arg) { + struct bufferevent *bufev = arg; + /* + * If we are below the watermark then reschedule reading if it's + * still enabled. + */ + if (bufev->wm_read.high == 0 || now < bufev->wm_read.high) { + evbuffer_setcb(buf, NULL, NULL); + + if (bufev->enabled & EV_READ) + bufferevent_add(&bufev->ev_read, bufev->timeout_read); + } +} + static void bufferevent_readcb(evutil_socket_t fd, short event, void *arg) { diff -Paur --no-dereference -- libevent.upstream/configure libevent/configure --- libevent.upstream/configure +++ libevent/configure @@ -15961,7 +15961,7 @@ # which indicates that we try without any flags at all, and "pthread-config" # which is a program returning the flags for the Pth emulation library. -acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" +acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt" # The ordering *is* (sometimes) important. Some notes on the # individual items follow: @@ -16085,8 +16085,8 @@ main () { pthread_t th; pthread_join(th, 0); - pthread_attr_init(0); pthread_cleanup_push(0, 0); - pthread_create(0,0,0,0); pthread_cleanup_pop(0); + pthread_attr_init(0); + pthread_create(0,0,0,0); ; return 0; } diff -Paur --no-dereference -- libevent.upstream/evutil.c libevent/evutil.c --- libevent.upstream/evutil.c +++ libevent/evutil.c @@ -76,8 +76,10 @@ #include #include #ifndef _WIN32 +#if __has_include() #include #endif +#endif #ifdef EVENT__HAVE_IFADDRS_H #include #endif @@ -2007,7 +2009,12 @@ if (cp == NULL) return evutil_inet_pton(af, src, dst); +#if __has_include() if_index = if_nametoindex(cp + 1); +#else + if_index = 0; + errno = ENODEV; +#endif if (if_index == 0) { /* Could be numeric */ if_index = strtoul(cp + 1, &check, 10); diff -Paur --no-dereference -- libevent.upstream/evutil_rand.c libevent/evutil_rand.c --- libevent.upstream/evutil_rand.c +++ libevent/evutil_rand.c @@ -194,8 +194,8 @@ void evutil_secure_rng_add_bytes(const char *buf, size_t n) { - arc4random_addrandom((unsigned char*)buf, - n>(size_t)INT_MAX ? INT_MAX : (int)n); + (void) buf; + (void) n; } #endif diff -Paur --no-dereference -- libevent.upstream/Makefile.in libevent/Makefile.in --- libevent.upstream/Makefile.in +++ libevent/Makefile.in @@ -200,7 +200,7 @@ test/test-ratelim$(EXEEXT) test/test-time$(EXEEXT) \ test/test-weof$(EXEEXT) test/regress$(EXEEXT) @BUILD_REGRESS_TRUE@am__EXEEXT_6 = $(am__EXEEXT_5) -PROGRAMS = $(noinst_PROGRAMS) +PROGRAMS = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ @@ -2847,6 +2847,7 @@ clean-noinstLTLIBRARIES clean-noinstPROGRAMS mostlyclean-am distclean: distclean-am + rm -rf sample/.deps -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -f $(DEPDIR)/epoll_sub.Plo -rm -f ./$(DEPDIR)/buffer.Plo diff -Paur --no-dereference -- libevent.upstream/openssl-compat.h libevent/openssl-compat.h --- libevent.upstream/openssl-compat.h +++ libevent/openssl-compat.h @@ -40,7 +40,8 @@ #endif /* (OPENSSL_VERSION_NUMBER < 0x10100000L) || \ (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L) */ -#if defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER >= 0x20700000L +#if defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER >= 0x20700000L && \ + LIBRESSL_VERSION_NUMBER < 0x30500000L #define BIO_get_init(b) (b)->init #endif