1948 Commits

Author SHA1 Message Date
Nick Mathewson
ac1931ac3d Remove event-config.h from .gitignore; it moved to include/event2 2010-10-26 11:07:26 -04:00
Nick Mathewson
e56ff65af1 Fix a minor syntax error that most compilers didn't care about 2010-10-26 11:01:58 -04:00
Nick Mathewson
a4063c06f9 Note that 2.0.9 will break the ABI, and make changes we were postponing.
We had to turn a couple of 32-bit size arguments into 64-bit arguments
or size_t arguments (since otherwise we would have had to do it post
2.0.x-stable, and that would be worse).
2010-10-26 10:38:30 -04:00
Nick Mathewson
2cbb1a161e Make rate-limits go up to SIZE_MAX/EV_SSIZE_MAX, not just INT32_MAX
Someday, when networks are far faster and people frequently want a
burst value greater than 2GB per tick, this will seem very forsightful
indeed.

For now, it breaks ABI, but not source.  Fixes bug 3092096.
2010-10-26 10:27:29 -04:00
Nick Mathewson
e4f34e8a0f Correct logic for realigning a chain in evbuffer_add
The old logic was both too eager to realign (it would move a whole
chain to save a byte) and too reluctant to realign (it would only
realign when data would fit into the misaligned portion, without
considering the space at the end of the chain).

The new logic matches that from evbuffer_expand_singlechain: it only
realigns a chain when not much data is to be moved, and there's a
bunch of space to be regained.

Spotted by Yan Lin.
2010-10-25 22:39:29 -04:00
Nick Mathewson
74c0e86298 Avoid missed-request bug when entire http request arrives before data is flushed
The trigger for starting to read the first line of a request used to
be, "When data has arrived and we're looking for the first line."
But that's not good enough: if the entire next request gets read
into our bufev->inbuf while we're still processing the current
request, we'll never see any more data arrive, and so will never
process it.

So the fix is to make sure that whenever we hit evhttp_send_done, we
call evhttp_read_cb.  We can't call it directly, though, since
evhttp_send_done is reachable from the user API, and evhttp_read_cb
can invoke user functions, and we don't want to force everyone to
have reentrant callbacks.  So, we use a deferred_cb.

Found by Ivan Andropov.  This is bug 3008344.
2010-10-25 21:53:15 -04:00
Nick Mathewson
8e342e5630 Correctly count req->body_size on http usage without Content-Length
There was a dumb bug where we would look at the length of the input
buffer immediately _after_ we drained it.
2010-10-25 16:09:11 -04:00
Nick Mathewson
58a1cc6bc8 Fix a bug where we would read too much data in HTTP bodies or requests.
We were using evbuffer_add_buffer, which moved the entire buffer
contents.  But if we had a valid content_length, we only wanted to
move up to the amount of data remaining in ntoread.  Our bug would
make us put our ntoread in the negative, which would in turn make us
read all data until the connection closed.

Found by Denis Bilenko.  Should fix bug 2963172.
2010-10-25 16:00:47 -04:00
Nick Mathewson
525da3e1eb Fix Content-Length when trying send more than 100GB of data (!) on an evhttp. 2010-10-25 15:50:54 -04:00
Nick Mathewson
f1250eb698 add a requested docstring for event_rpcgen.CommandLine.__init__ 2010-10-25 15:23:41 -04:00
Nick Mathewson
9c71a3413a Merge remote branch 'github/http_and_listener' 2010-10-25 15:13:32 -04:00
Nick Mathewson
ac7e52d84d Make evbuffer_add_file take ev_off_t, not off_t
This change has no effect on non-windows platforms, since those
either define off_t to 64-bits, or allow you to decide whether
it should be 64-bits yourself via some LARGEFILE-like macro.

On Windows, however, off_t is always 32-bit, so it's a bad choice
for "file size" or "file offset" values.  Instead, I'm adding
an ev_off_t type, and using it in the one place where we used
off_t to mean "the size of a file" or "an offset into a file" in the
API.

This breaks ABI compatibility on Windows.
2010-10-25 14:29:30 -04:00
Nick Mathewson
006efa7dbb Functions to actually use evhttp_bound_socket with/as evconnlistener. 2010-10-25 11:50:51 -04:00
Nick Mathewson
46ee061ca0 Add a function to change a listener's callback.
You can also now initialize listeners with no callbacks set; if so,
they won't get enabled until the callback is set to non-NULL.
2010-10-25 11:47:05 -04:00
Nick Mathewson
2c66983a6d Simplify the logic for choosing EPOLL_CTL_ADD vs EPOLL_CTL_MOD
Previously, we chose "ADD" whenever old_events==new_events, (since
we expected the add to fail with EEXIST), or whenever old_events
was==0, and MOD otherwise (i.e., when old_events was nonzero and not
equal to new_events).

But now that we retry failed MOD events as ADD *and* failed ADD
events as MOD, the important thing is now to try to guess right the
largest amount of the time, since guessing right means we do only
one syscall, but guessing wrong means we do two.

When old_events is 0, ADD is probably right (unless we're hitting
the dup bug, when we'll fall back).

And when old_events is set and != new_events, MOD is almost
certainly right for the same reasons as before.

But when old_events is equal to new events, then MOD will work fine
unless we closed and reopened the fd, in which case we'll have to
fall back to the ADD case.  (Redundant del/add pairs are more common
than closes for most use cases.)

This change lets us avoid calculating new_events, which ought to
save a little time in epoll.c
2010-10-24 11:51:14 -04:00
Nick Mathewson
c281aba30e Fix a nasty bug related to use of dup() with epoll on Linux
Current versions of the Linux kernel don't seem to remove the struct
epitem for a given (file,fd) combo when the fd is closed unless the
file itself is also completely closed.  This means that if you do:
   fd = dup(fd_orig);
   add(fd);
   close(fd);
   dup2(fd_orig, fd);
   add(fd);
you will get an EEXIST when you should have gotten a success.  This
could cause warnings and dropped events when using dup and epoll.

The solution is pretty simple: when we get an EEXIST from
EPOLL_CTL_ADD, we retry with EPOLL_CTL_MOD.

Unit test included to demonstrate the bug.

Found due to the patient efforts of Gilad Benjamini; diagnosed with
help from Nicholas Marriott.
2010-10-24 11:38:29 -04:00
Nick Mathewson
bf11e7ddf7 Merge branch 'http_uri_parse' 2010-10-21 15:33:13 -04:00
Nick Mathewson
bc98f5e6ba Unit tests for evhttp_uri_set* 2010-10-21 14:53:21 -04:00
Nick Mathewson
45f6869c75 Make evhttp_uri non-public, and give it accessor functions. 2010-10-21 14:52:52 -04:00
Nick Mathewson
70e1b607d6 Document that two bufferevent functions only work on socket bufferevents 2010-10-21 14:05:04 -04:00
Nick Mathewson
aab49b6069 Add a bufferevent_get_base function 2010-10-21 14:04:24 -04:00
Nick Mathewson
d9ffa899fa Update the HTTP regression tests to use Libevent2 apis for non-http stuff 2010-10-21 13:04:04 -04:00
Nick Mathewson
1f507d7541 Stop using Libevent-1 headers in regress_http 2010-10-21 12:27:16 -04:00
Nick Mathewson
2a3b5872fe Merge branch 'http_small_tweaks'
Conflicts:
	http-internal.h
2010-10-21 12:23:10 -04:00
Nick Mathewson
cd00079b22 Add evhttp_connection_get_base() to get the event_base from an http connection
Based on a patch by Mark Ellzey from 27 July 2010.

Closes ticket 3052406
2010-10-21 12:19:28 -04:00
Nick Mathewson
1213d3dd8b Fix a 100%-CPU bug where an SSL connection would sometimes never stop trying to write
If an SSL connection becamse disabled or suspended before became open,
it could (under the right circumstances) wind up without ever getting
its write callback disabled.

The most correct fix is probably more subtle, and involves checking
all caseswhen a write callback is enabled or disabled.  This fix is
more blunt, and explicitly checks whether the callback should have
been disabled at the end of the callback to prevent infinite looping.

Diagnosed with help from Sebastian Hahn
2010-10-20 13:41:02 -04:00
Nick Mathewson
2075fbcff0 Add evhttp_parse_query_str to be used with evhttp_uri_parse.
The old evhttp_parse_query() doesn't work well with struct
evhttp_uri.query, since it expects to get whole URIs, rather than
just the query portion.
2010-10-19 13:15:48 -04:00
Nick Mathewson
3a33462827 Document behavior of URI parsing more thoroughly.
Also, move evhttp_uri struct into http.h, since it is part of the API.
2010-10-19 13:02:18 -04:00
Nick Mathewson
a5a76e689c Add a huge pile of tests for the new URI functions, and make them pass. 2010-10-19 12:35:50 -04:00
Nick Mathewson
ad923a11f1 Improvements to tinytest_macros.h
First, handle cases where we have %s in a tt_want or tt_assert.

Second, add tt_want_*_op that do a tt_*_op test, but do not exit the
test on failure.

We should push these upstream to tinytest some time.
2010-10-19 12:33:50 -04:00
Nick Mathewson
eaa5f1d9ed Revise evhttp_uri_parse implementation to handle more of RFC3986 2010-10-19 11:26:59 -04:00
Nick Mathewson
fadbfd4e6e Clean up error handling in uri_parse a little 2010-10-18 14:43:54 -04:00
Nick Mathewson
7d45431e15 Do not silently truncate URIs in evhttp_uri_join. Also avoid evbuffer_pullup. 2010-10-18 14:38:48 -04:00
Nick Mathewson
86212341c5 Make evhttp_uri_parse and friends conform to memory management standards 2010-10-18 14:34:20 -04:00
Pavel Plesov
86dd720a66 Introduce absolute URI parsing helpers.
See evhttp_uri_parse(), evhttp_uri_free() and evhttp_uri_join() for details.
2010-10-18 14:30:29 -04:00
Nick Mathewson
f13e449b53 Merge branch 'http_parse' 2010-10-18 14:20:06 -04:00
Nick Mathewson
49f4bf7c57 Add evhttp_request_get_command so code can tell GET from POST without peeking at the struct. 2010-10-18 13:58:02 -04:00
Nick Mathewson
e5870690fc Modernize header usage in bench_http.c 2010-10-18 13:53:31 -04:00
Nick Mathewson
9dc5f44a19 Increment version in git to 2.0.8-rc-dev 2010-10-14 22:12:32 -04:00
Nick Mathewson
ef18c994c3 Increment the version to 2.0.8-rc
NOTE: This is not the official release until I tag it.  If you see
    this commit, and you decide that Libevent 2.0.8-rc is now
    finalized, you might get something besides 2.0.8-rc.
release-2.0.8-rc
2010-10-14 18:36:07 -04:00
Nick Mathewson
15be0493f6 Changelog and readme for 2.0.8-rc 2010-10-14 18:35:11 -04:00
Nick Mathewson
4ebf9509f7 Fixes for MSVC compilation 2010-10-14 14:40:40 -04:00
Nick Mathewson
d3b096c011 Make the --enable-gcc-warnings option include signed comparison warnings 2010-10-14 13:54:15 -04:00
Nick Mathewson
e06f514d4e Fix signed/unsigned warnings on win32 2010-10-14 13:51:24 -04:00
Nick Mathewson
6be589ae68 Fix signed/unsigned warnings on opensolaris, where iov_len is signed 2010-10-14 13:48:40 -04:00
Nick Mathewson
e5c214a423 Fix -Wsigned-compare warnings in test/* 2010-10-14 13:16:41 -04:00
Nick Mathewson
f2763fa864 add limits.h to event_tagging.c so opensolaris will build 2010-10-14 13:16:00 -04:00
Nick Mathewson
5e4bafbb89 fix a signed/unsigned warning in kqueue.c 2010-10-14 13:15:32 -04:00
Nick Mathewson
02f6259fc3 New unit test for ssl bufferevents starting with connected SSLs. 2010-10-14 12:17:28 -04:00
Nick Mathewson
93bb7d8e19 Fix a case where an ssl bufferevent with CLOSE_ON_FREE didn't close its fd
This could happen when we got an SSL with a BIO already set on it.
2010-10-14 12:17:24 -04:00