mirror of
https://github.com/cuberite/libevent.git
synced 2025-08-03 17:26:24 -04:00
Merge remote-tracking branch 'origin/patches-2.0'
Conflict in buffer.c: the new file-segment logic conflicted with the solaris sendfile fix.
This commit is contained in:
commit
ec670c15a7
1
.gitignore
vendored
1
.gitignore
vendored
@ -87,6 +87,7 @@ libevent_openssl.pc
|
||||
/test/regress
|
||||
/test/regress.gen.c
|
||||
/test/regress.gen.h
|
||||
/test/rpcgen-attempted
|
||||
/test/test-eof
|
||||
/test/test-init
|
||||
/test/test-ratelim
|
||||
|
16
buffer.c
16
buffer.c
@ -2218,12 +2218,18 @@ evbuffer_write_sendfile(struct evbuffer *buffer, evutil_socket_t dest_fd,
|
||||
}
|
||||
return (res);
|
||||
#elif defined(SENDFILE_IS_SOLARIS)
|
||||
res = sendfile(dest_fd, source_fd, &offset, chain->off);
|
||||
if (res == -1 && EVUTIL_ERR_RW_RETRIABLE(errno)) {
|
||||
/* if this is EAGAIN or EINTR return 0; otherwise, -1 */
|
||||
return (0);
|
||||
{
|
||||
const off_t offset_orig = offset;
|
||||
res = sendfile(dest_fd, source_fd, &offset, chain->off);
|
||||
if (res == -1 && EVUTIL_ERR_RW_RETRIABLE(errno)) {
|
||||
if (offset - offset_orig)
|
||||
return offset - offset_orig;
|
||||
/* if this is EAGAIN or EINTR and no bytes were
|
||||
* written, return 0 */
|
||||
return (0);
|
||||
}
|
||||
return (res);
|
||||
}
|
||||
return (res);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
@ -99,6 +99,8 @@ struct bufferevent_rate_limit_group {
|
||||
/** The smallest number of bytes that any member of the group should
|
||||
* be limited to read or write at a time. */
|
||||
ev_ssize_t min_share;
|
||||
ev_ssize_t configured_min_share;
|
||||
|
||||
/** Timeout event that goes off once a tick, when the bucket is ready
|
||||
* to refill. */
|
||||
struct event master_refill_event;
|
||||
|
@ -637,13 +637,15 @@ bufferevent_rate_limit_group_new(struct event_base *base,
|
||||
|
||||
ev_token_bucket_init(&g->rate_limit, cfg, tick, 0);
|
||||
|
||||
g->min_share = 64;
|
||||
event_assign(&g->master_refill_event, base, -1, EV_PERSIST,
|
||||
_bev_group_refill_callback, g);
|
||||
/*XXXX handle event_add failure */
|
||||
event_add(&g->master_refill_event, &cfg->tick_timeout);
|
||||
|
||||
EVTHREAD_ALLOC_LOCK(g->lock, EVTHREAD_LOCKTYPE_RECURSIVE);
|
||||
|
||||
bufferevent_rate_limit_group_set_min_share(g, 64);
|
||||
|
||||
return g;
|
||||
}
|
||||
|
||||
@ -671,6 +673,9 @@ bufferevent_rate_limit_group_set_cfg(
|
||||
event_add(&g->master_refill_event, &cfg->tick_timeout);
|
||||
}
|
||||
|
||||
/* The new limits might force us to adjust min_share differently. */
|
||||
bufferevent_rate_limit_group_set_min_share(g, g->configured_min_share);
|
||||
|
||||
UNLOCK_GROUP(g);
|
||||
return 0;
|
||||
}
|
||||
@ -683,6 +688,15 @@ bufferevent_rate_limit_group_set_min_share(
|
||||
if (share > EV_SSIZE_MAX)
|
||||
return -1;
|
||||
|
||||
g->configured_min_share = share;
|
||||
|
||||
/* Can't set share to less than the one-tick maximum. IOW, at steady
|
||||
* state, at least one connection can go per tick. */
|
||||
if (share > g->rate_limit_cfg.read_rate)
|
||||
share = g->rate_limit_cfg.read_rate;
|
||||
if (share > g->rate_limit_cfg.write_rate)
|
||||
share = g->rate_limit_cfg.write_rate;
|
||||
|
||||
g->min_share = share;
|
||||
return 0;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ AUTOMAKE_OPTIONS = foreign
|
||||
|
||||
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/compat -I$(top_srcdir)/include -I../include -DTINYTEST_LOCAL
|
||||
|
||||
EXTRA_DIST = regress.rpc regress.gen.h regress.gen.c test.sh
|
||||
EXTRA_DIST = regress.rpc regress.gen.h regress.gen.c rpcgen_wrapper.sh test.sh
|
||||
|
||||
noinst_PROGRAMS = test-init test-eof test-weof test-time \
|
||||
bench bench_cascade bench_http bench_httpclient test-ratelim \
|
||||
@ -71,15 +71,20 @@ bench_http_LDADD = $(LIBEVENT_GC_SECTIONS) ../libevent.la
|
||||
bench_httpclient_SOURCES = bench_httpclient.c
|
||||
bench_httpclient_LDADD = $(LIBEVENT_GC_SECTIONS) ../libevent_core.la
|
||||
|
||||
regress.gen.c regress.gen.h: regress.rpc $(top_srcdir)/event_rpcgen.py
|
||||
if $(top_srcdir)/event_rpcgen.py $(srcdir)/regress.rpc ; then \
|
||||
echo "HI"; \
|
||||
regress.gen.c regress.gen.h: rpcgen-attempted
|
||||
|
||||
rpcgen-attempted: $(srcdir)/regress.rpc $(srcdir)/../event_rpcgen.py $(srcdir)/rpcgen_wrapper.sh
|
||||
date -u > $@
|
||||
if $(srcdir)/rpcgen_wrapper.sh $(srcdir); then \
|
||||
echo "rpcgen okay"; \
|
||||
else \
|
||||
echo "No Python installed; can't test RPC."; \
|
||||
echo "No Python installed; stubbing out RPC test." >&2; \
|
||||
echo " "> regress.gen.c; \
|
||||
echo "#define NO_PYTHON_EXISTS" > regress.gen.h; \
|
||||
fi
|
||||
|
||||
CLEANFILES = rpcgen-attempted
|
||||
|
||||
DISTCLEANFILES = *~
|
||||
|
||||
verify: check
|
||||
|
41
test/rpcgen_wrapper.sh
Executable file
41
test/rpcgen_wrapper.sh
Executable file
@ -0,0 +1,41 @@
|
||||
#!/bin/sh
|
||||
# libevent rpcgen_wrapper.sh
|
||||
# Transforms event_rpcgen.py failure into success for make, only if
|
||||
# regress.gen.c and regress.gen.h already exist in $srcdir. This
|
||||
# is needed for "make distcheck" to pass the read-only $srcdir build,
|
||||
# as with read-only sources fresh from tarball, regress.gen.[ch] will
|
||||
# be correct in $srcdir but unwritable. This previously triggered
|
||||
# Makefile.am to create stub regress.gen.c and regress.gen.h in the
|
||||
# distcheck _build directory, which were then detected as leftover
|
||||
# files in the build tree after distclean, breaking distcheck.
|
||||
# Note that regress.gen.[ch] are not in fresh git clones, making
|
||||
# working Python a requirement for make distcheck of a git tree.
|
||||
|
||||
exit_updated() {
|
||||
echo "Updated ${srcdir}\regress.gen.c and ${srcdir}\regress.gen.h"
|
||||
exit 0
|
||||
}
|
||||
|
||||
exit_reuse() {
|
||||
echo "event_rpcgen.py failed, ${srcdir}\regress.gen.\[ch\] will be reused." >&2
|
||||
exit 0
|
||||
}
|
||||
|
||||
exit_failed() {
|
||||
echo "Could not generate regress.gen.\[ch\] using event_rpcgen.sh" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
srcdir=$1
|
||||
srcdir=${srcdir:-.}
|
||||
${srcdir}/../event_rpcgen.py ${srcdir}/regress.rpc
|
||||
case "$?" in
|
||||
0)
|
||||
exit_updated
|
||||
;;
|
||||
*)
|
||||
test -r ${srcdir}/regress.gen.c -a -r ${srcdir}/regress.gen.h && \
|
||||
exit_reuse
|
||||
exit_failed
|
||||
;;
|
||||
esac
|
Loading…
x
Reference in New Issue
Block a user