diff --no-dereference -Naur -- libevent.normalized/buffer.c libevent.srctix/buffer.c --- libevent.normalized/buffer.c 2015-01-05 15:30:02.000000000 +0100 +++ libevent.srctix/buffer.c 2016-12-31 12:49:17.405955975 +0100 @@ -183,7 +183,7 @@ /* this way we can manipulate the buffer to different addresses, * which is required for mmap for example. */ - chain->buffer = EVBUFFER_CHAIN_EXTRA(u_char, chain); + chain->buffer = EVBUFFER_CHAIN_EXTRA(unsigned char, chain); return (chain); } @@ -2749,7 +2749,7 @@ if (!chain) return (-1); chain->flags |= EVBUFFER_REFERENCE | EVBUFFER_IMMUTABLE; - chain->buffer = (u_char *)data; + chain->buffer = (unsigned char *)data; chain->buffer_len = datlen; chain->off = datlen; diff --no-dereference -Naur -- libevent.normalized/bufferevent_sock.c libevent.srctix/bufferevent_sock.c --- libevent.normalized/bufferevent_sock.c 2013-02-05 21:00:56.000000000 +0100 +++ libevent.srctix/bufferevent_sock.c 2017-05-14 23:05:59.639226283 +0200 @@ -63,6 +63,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" @@ -75,6 +76,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 *); @@ -119,6 +121,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 --no-dereference -Naur -- libevent.normalized/config.sub libevent.srctix/config.sub --- libevent.normalized/config.sub 2013-05-29 19:28:15.000000000 +0200 +++ libevent.srctix/config.sub 2016-12-31 12:40:43.971001342 +0100 @@ -1348,7 +1348,7 @@ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* | -aros* \ + | -aos* | -aros* | -sortix* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ diff --no-dereference -Naur -- libevent.normalized/configure libevent.srctix/configure --- libevent.normalized/configure 2015-01-05 15:31:15.000000000 +0100 +++ libevent.srctix/configure 2017-05-14 23:13:21.220252464 +0200 @@ -14602,7 +14602,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: @@ -14726,8 +14726,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 --no-dereference -Naur -- libevent.normalized/evutil.c libevent.srctix/evutil.c --- libevent.normalized/evutil.c 2013-11-01 19:18:57.000000000 +0100 +++ libevent.srctix/evutil.c 2016-12-31 12:51:06.163306533 +0100 @@ -2102,11 +2102,7 @@ long _evutil_weakrand(void) { -#ifdef WIN32 - return rand(); -#else - return random(); -#endif + return arc4random() & 0x7FFFFFFF; } /** diff --no-dereference -Naur -- libevent.normalized/evutil_rand.c libevent.srctix/evutil_rand.c --- libevent.normalized/evutil_rand.c 2013-11-01 19:18:57.000000000 +0100 +++ libevent.srctix/evutil_rand.c 2016-12-31 12:54:09.450769213 +0100 @@ -174,7 +174,7 @@ 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; } diff --no-dereference -Naur -- libevent.normalized/http-internal.h libevent.srctix/http-internal.h --- libevent.normalized/http-internal.h 2012-02-10 23:17:14.000000000 +0100 +++ libevent.srctix/http-internal.h 2016-12-31 13:02:48.737574847 +0100 @@ -70,10 +70,10 @@ struct event retry_ev; /* for retrying connects */ char *bind_address; /* address to use for binding the src */ - u_short bind_port; /* local port for binding the src */ + unsigned short bind_port; /* local port for binding the src */ char *address; /* address to connect to */ - u_short port; + unsigned short port; size_t max_headers_size; ev_uint64_t max_body_size; diff --no-dereference -Naur -- libevent.normalized/Makefile.in libevent.srctix/Makefile.in --- libevent.normalized/Makefile.in 2015-01-05 15:31:14.000000000 +0100 +++ libevent.srctix/Makefile.in 2017-05-14 23:19:25.959188264 +0200 @@ -537,7 +537,7 @@ @INSTALL_LIBEVENT_TRUE@lib_LTLIBRARIES = $(LIBEVENT_LIBS_LA) @INSTALL_LIBEVENT_TRUE@pkgconfig_DATA = $(LIBEVENT_PKGCONFIG) @INSTALL_LIBEVENT_FALSE@noinst_LTLIBRARIES = $(LIBEVENT_LIBS_LA) -SUBDIRS = . include sample test +SUBDIRS = . include @BUILD_WIN32_FALSE@SYS_LIBS = @BUILD_WIN32_TRUE@SYS_LIBS = -lws2_32 -lshell32 -ladvapi32 @BUILD_WIN32_FALSE@SYS_SRC = $(am__append_5) $(am__append_6) \ @@ -1219,6 +1219,9 @@ clean-noinstLTLIBRARIES mostlyclean-am distclean: distclean-recursive + rm -f sample/Makefile + rm -rf test/.deps + rm -r test/Makefile -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(DEPDIR) ./$(DEPDIR) -rm -f Makefile diff --no-dereference -Naur -- libevent.normalized/poll.c libevent.srctix/poll.c --- libevent.normalized/poll.c 2012-02-10 23:17:14.000000000 +0100 +++ libevent.srctix/poll.c 2016-12-31 13:01:40.943313857 +0100 @@ -180,7 +180,7 @@ if (res == 0 || nfds == 0) return (0); - i = random() % nfds; + i = arc4random_uniform(nfds); for (j = 0; j < nfds; j++) { int what; if (++i == nfds) diff --no-dereference -Naur -- libevent.normalized/select.c libevent.srctix/select.c --- libevent.normalized/select.c 2012-02-10 23:17:14.000000000 +0100 +++ libevent.srctix/select.c 2016-12-31 12:55:06.669301485 +0100 @@ -177,7 +177,7 @@ event_debug(("%s: select reports %d", __func__, res)); check_selectop(sop); - i = random() % nfds; + i = arc4random_uniform(nfds); for (j = 0; j < nfds; ++j) { if (++i >= nfds) i = 0; diff --no-dereference -Naur -- libevent.normalized/tixbuildinfo libevent.srctix/tixbuildinfo --- libevent.normalized/tixbuildinfo 1970-01-01 01:00:00.000000000 +0100 +++ libevent.srctix/tixbuildinfo 2017-05-14 23:14:49.958047223 +0200 @@ -0,0 +1,7 @@ +tix.version=1 +tix.class=srctix +pkg.name=libevent +pkg.build-libraries=libz? libssl? +pkg.build-system=configure +pkg.configure.args=--disable-malloc-replacement +pkg.post-install.cmd=tix-eradicate-libtool-la diff --no-dereference -Naur -- libevent.normalized/util-internal.h libevent.srctix/util-internal.h --- libevent.normalized/util-internal.h 2013-11-01 19:18:57.000000000 +0100 +++ libevent.srctix/util-internal.h 2017-05-13 22:53:00.073707830 +0200 @@ -75,7 +75,7 @@ /* True iff e is an error that means a read/write operation can be retried. */ #define EVUTIL_ERR_RW_RETRIABLE(e) \ - ((e) == EINTR || (e) == EAGAIN) + ((e) == EINTR || (e) == EAGAIN || (e) == EWOULDBLOCK) /* True iff e is an error that means an connect can be retried. */ #define EVUTIL_ERR_CONNECT_RETRIABLE(e) \ ((e) == EINTR || (e) == EINPROGRESS)