Skip to content

Instantly share code, notes, and snippets.

@azat
Created October 21, 2018 21:49
Show Gist options
  • Save azat/b72773dfe7549fed865d439e03de05c1 to your computer and use it in GitHub Desktop.
Save azat/b72773dfe7549fed865d439e03de05c1 to your computer and use it in GitHub Desktop.
commit 65b5c8ad803118573bd7777a067be197470f336f
Merge: 3e6553a1 ebe89149
Author: Azat Khuzhin <[email protected]>
Date: Mon Oct 22 00:32:57 2018 +0300
On master: bufferevent/bufferevent_timeout: ignores write cb timeout
Notes:
1|azat:.../.cmake-debug (master) [1]$ ninja && regress --no-fork --verbose bufferevent/bufferevent_timeout
[34/34] Linking C executable bin/bench_http
bufferevent/bufferevent_timeout:
OK ../test/regress_bufferevent.c:970: assert(bev1)
OK ../test/regress_bufferevent.c:971: assert(bev2)
OK ../test/regress_bufferevent.c:1034: want(res1.n_read_timeouts)
FAIL ../test/regress_bufferevent.c:1035: want(res1.n_write_timeouts)
OK ../test/regress_bufferevent.c:1036: want(res1.n_read_timeouts == 1)
FAIL ../test/regress_bufferevent.c:1037: want(res1.n_write_timeouts == 1)
OK ../test/regress_bufferevent.c:1039: assert(labs(timeval_msec_diff(((&started_at)), ((&res1.read_timeout_at))) - (150)) <= 50): 33 vs 50
FAIL ../test/regress_bufferevent.c:1040: assert(labs(timeval_msec_diff(((&started_at)), ((&res1.write_timeout_at))) - (100)) <= 50): 1540155888478 vs 50
[bufferevent_timeout FAILED]
1/1 TESTS FAILED. (0 skipped)
diff --cc buffer.c
index 8e88fdf5,8e88fdf5..314a67b8
--- a/buffer.c
+++ b/buffer.c
@@@ -2404,7 -2404,7 +2404,7 @@@ static inline in
evbuffer_write_iovec(struct evbuffer *buffer, evutil_socket_t fd,
ev_ssize_t howmuch)
{
-- IOV_TYPE iov[NUM_WRITE_IOVEC];
++ IOV_TYPE iov[1];
struct evbuffer_chain *chain = buffer->first;
int n, i = 0;
@@@ -2415,7 -2415,7 +2415,7 @@@
/* XXX make this top out at some maximal data length? if the
* buffer has (say) 1MB in it, split over 128 chains, there's
* no way it all gets written in one go. */
-- while (chain != NULL && i < NUM_WRITE_IOVEC && howmuch) {
++ while (chain != NULL && i < 1 && howmuch) {
#ifdef USE_SENDFILE
/* we cannot write the file info via writev */
if (chain->flags & EVBUFFER_SENDFILE)
@@@ -2446,6 -2446,6 +2446,12 @@@
}
#else
n = writev(fd, iov, i);
++ static int __read;
++ if (!__read) {
++ ++__read;
++ } else {
++ usleep(__read * 3e4);
++ }
#endif
return (n);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment