]> granicus.if.org Git - libevent/log
libevent
13 years agoReworked AIX __ss_family workaround to use AC_STRUCT_MEMBER.
Kevin Bowling [Wed, 24 Nov 2010 02:09:08 +0000 (19:09 -0700)]
Reworked AIX __ss_family workaround to use AC_STRUCT_MEMBER.

13 years agoselect comes from <sys/select.h> according to POSIX.1-2001, or from a
Kevin Bowling [Tue, 23 Nov 2010 03:44:10 +0000 (20:44 -0700)]
select comes from <sys/select.h> according to POSIX.1-2001, or from a
variety of other standard headers on older systems, but not <select.h>.
AIX build fix.

13 years agoRemove _event_initialized(); make event_initialized() a function(); make it consisten...
Nick Mathewson [Tue, 23 Nov 2010 18:08:07 +0000 (13:08 -0500)]
Remove _event_initialized(); make event_initialized() a function(); make it consistent on windows and non-windows

13 years agoDocument event_get_assignment
Nick Mathewson [Tue, 23 Nov 2010 17:26:46 +0000 (12:26 -0500)]
Document event_get_assignment

13 years agoNote that reentrant calls to libevent from logging cbs may fail badly
Nick Mathewson [Tue, 23 Nov 2010 17:26:34 +0000 (12:26 -0500)]
Note that reentrant calls to libevent from logging cbs may fail badly

13 years agoFix some irix compilation warnings spotted by Kevin Bowling
Nick Mathewson [Tue, 23 Nov 2010 02:02:34 +0000 (21:02 -0500)]
Fix some irix compilation warnings spotted by Kevin Bowling

13 years agoMerge remote branch 'kev009/master'
Nick Mathewson [Tue, 23 Nov 2010 01:24:03 +0000 (20:24 -0500)]
Merge remote branch 'kev009/master'

13 years agoFix IRIX build. sa_family collides with a #define in sys/socket.h on IRIX.
Kevin Bowling [Mon, 22 Nov 2010 23:40:31 +0000 (16:40 -0700)]
Fix IRIX build.  sa_family collides with a #define in sys/socket.h on IRIX.

13 years agoMerge remote branch 'github/20_getaddrinfo_cancel_v2'
Nick Mathewson [Mon, 22 Nov 2010 21:24:52 +0000 (16:24 -0500)]
Merge remote branch 'github/20_getaddrinfo_cancel_v2'

13 years agoAdd a stress test for getaddrinfo_cancel
Nick Mathewson [Mon, 22 Nov 2010 21:24:09 +0000 (16:24 -0500)]
Add a stress test for getaddrinfo_cancel

13 years agoMerge remote branches 'github/20_epoll_nochangelist_v4', 'github/20_openssl_closeonfr...
Nick Mathewson [Mon, 22 Nov 2010 20:52:34 +0000 (15:52 -0500)]
Merge remote branches 'github/20_epoll_nochangelist_v4', 'github/20_openssl_closeonfree' and 'github/20_cloexec'

13 years agoReorder backends in test.sh to match preference order in event.c
Nick Mathewson [Mon, 22 Nov 2010 19:13:24 +0000 (14:13 -0500)]
Reorder backends in test.sh to match preference order in event.c

13 years agoMake unit tests for epoll-with-changelist pass
Nick Mathewson [Mon, 22 Nov 2010 19:10:01 +0000 (14:10 -0500)]
Make unit tests for epoll-with-changelist pass

The only changes needed were to handle the fact that the methodname
"epoll (with changelist)" matches the environment variable
EVENT_NOEPOLL rather than the imaginary "EVENT_EPOLL (WITH CHANGELIST)".

13 years agoDisable changelist for epoll by default because of Linux dup() bug; add an option...
Nick Mathewson [Sun, 14 Nov 2010 22:52:16 +0000 (17:52 -0500)]
Disable changelist for epoll by default because of Linux dup() bug; add an option and/or an envvar to reenable it for speed.

Rename option to control epoll changelist; make epoll changelist off by default

13 years agoMake sure the CLOEXEC flag is set on fds we open for base notification
Nick Mathewson [Sat, 20 Nov 2010 06:41:34 +0000 (01:41 -0500)]
Make sure the CLOEXEC flag is set on fds we open for base notification

13 years agoResolve an evport bug in the thread/forking test
Nick Mathewson [Fri, 19 Nov 2010 22:09:30 +0000 (17:09 -0500)]
Resolve an evport bug in the thread/forking test

13 years agoMake evdns_getaddrinfo_cancel threadsafe
Nick Mathewson [Fri, 19 Nov 2010 17:14:18 +0000 (12:14 -0500)]
Make evdns_getaddrinfo_cancel threadsafe

13 years agoFix some more cancel-related bugs in getaddrinfo_async
Nick Mathewson [Fri, 19 Nov 2010 17:01:05 +0000 (12:01 -0500)]
Fix some more cancel-related bugs in getaddrinfo_async

Also imposed a new rule to make this much much simpler: no freeing
the getaddrinfo request until both dns callbacks have been invoked.

13 years agoAvoid double-invocation of user callback with EVUTIL_EAI_CANCEL
Nick Mathewson [Fri, 19 Nov 2010 16:33:48 +0000 (11:33 -0500)]
Avoid double-invocation of user callback with EVUTIL_EAI_CANCEL

13 years agoUse the US-English "canceled", not the UK "cancelled".
Nick Mathewson [Tue, 16 Nov 2010 17:55:10 +0000 (12:55 -0500)]
Use the US-English "canceled", not the UK "cancelled".

13 years agoFix a memory leak in evhttp_uri_free.
Nick Mathewson [Wed, 17 Nov 2010 05:09:10 +0000 (00:09 -0500)]
Fix a memory leak in evhttp_uri_free.

13 years agoFix bug in bufferevent_connect on an openssl bufferevent that already had an fd
Nick Mathewson [Mon, 15 Nov 2010 00:52:18 +0000 (19:52 -0500)]
Fix bug in bufferevent_connect on an openssl bufferevent that already had an fd

The problem was that we were using openssl's BIO code's shutdown flag
whenever BEV_OPT_CLOSE_ON_FREE was set.  This made the BIO close the
socket when it was freed... but it would be freed whenever we did a
setfd on the bufferevent_openssl, even the no-op setfd in
bufferevent_connect.

So instead, we just set the shutdown flag to 0, and handle closing the
fd ourselves.

Spotted by Linus Nordberg

13 years agoOnly clear underlying callbacks when the user hasn't reset them.
Nick Mathewson [Tue, 9 Nov 2010 20:18:59 +0000 (15:18 -0500)]
Only clear underlying callbacks when the user hasn't reset them.

13 years agoWhen closing a filtering bufferevent, clear callbacks on the underlying bufferevent
Nick Mathewson [Tue, 9 Nov 2010 16:43:47 +0000 (11:43 -0500)]
When closing a filtering bufferevent, clear callbacks on the underlying bufferevent

Previously, if BEV_OPT_CLOSE_ON_FREE wasn't set on a
bufferevent_filter or a filtering bufferevent_openssl, when we went
to free the filtering bufferevent, we'd leave the underlying
bufferevent unchanged.  That's not so good, since the callbacks are
set to activate stuff in the filtering bufferevent that we're about
to free.  Instead, set all the callbacks to NULL.

13 years agoMerge remote branches 'github/20_evdns_cancel_segfault_v2', 'github/20_http_close_det...
Nick Mathewson [Tue, 9 Nov 2010 15:19:05 +0000 (10:19 -0500)]
Merge remote branches 'github/20_evdns_cancel_segfault_v2', 'github/20_http_close_detect', 'github/20_http_versions', 'github/20_more_http_methods', 'github/20_shutdown_iocp_listener' and 'github/20_win64_fixes'

13 years agoRefactor http version parsing into a single function
Nick Mathewson [Tue, 9 Nov 2010 15:14:32 +0000 (10:14 -0500)]
Refactor http version parsing into a single function

Based on a suggestion by Chris Davis to make
evhttp_parse_response_line tolerate odd versions too.

13 years agoRemove some debugging puts() calls from allow_methods test
Nick Mathewson [Tue, 9 Nov 2010 15:03:00 +0000 (10:03 -0500)]
Remove some debugging puts() calls from allow_methods test

13 years agoSet SO_UPDATE_ACCEPT_CONTEXT on sockets from AcceptEx so that shutdown() can work
Nick Mathewson [Thu, 4 Nov 2010 20:40:44 +0000 (15:40 -0500)]
Set SO_UPDATE_ACCEPT_CONTEXT on sockets from AcceptEx so that shutdown() can work

Based on patch (and lots of debugging work) by Kelly Brock.

13 years agoFix a mistake in http documentation found by Julien Blache
Nick Mathewson [Thu, 4 Nov 2010 20:04:28 +0000 (16:04 -0400)]
Fix a mistake in http documentation found by Julien Blache

13 years agoNever call evhttp_readcb while writing.
Nick Mathewson [Thu, 4 Nov 2010 18:05:08 +0000 (14:05 -0400)]
Never call evhttp_readcb while writing.

13 years agoDon't disable reading from the HTTP connection after sending the request to be notifi...
Felix Nawothnig [Tue, 1 Jun 2010 02:45:55 +0000 (04:45 +0200)]
Don't disable reading from the HTTP connection after sending the request to be notified of connection-close in time

13 years agoUnits test for unexpected evhttp methods.
Nick Mathewson [Thu, 4 Nov 2010 16:41:13 +0000 (12:41 -0400)]
Units test for unexpected evhttp methods.

13 years agoevhttp: Return 501 when we get an unrecognized method, not 400.
Nick Mathewson [Thu, 4 Nov 2010 16:39:41 +0000 (12:39 -0400)]
evhttp: Return 501 when we get an unrecognized method, not 400.

13 years agoTweak interface for allowed methods
Nick Mathewson [Thu, 4 Nov 2010 15:53:34 +0000 (11:53 -0400)]
Tweak interface for allowed methods

13 years agoDefine enumerators for all HTTP methods, including PATCH from RFC5789
Felix Nawothnig [Thu, 4 Nov 2010 15:25:35 +0000 (11:25 -0400)]
Define enumerators for all HTTP methods, including PATCH from RFC5789

This patch defines enumerators for all HTTP methods that exist
(including PATCH introduced in RFC 5789).

It also makes them bit-masky (that's not a word, is it?), breaking
binary- but not source-code compatibility.

evhttp now stores a bitmask specifying for which methods requests to
dispatch and which ones to reject with "405 Method Not Allowed".

By default that's the ones we currently have (GET, POST, HEAD, PUT,
DELETE), thereby keeping functional compatibility (besides the minor
change that one of the other methods will now cause 405 instead of
400. But I believe that could even be considered a bug-fix).

evhttp is extended by evhttp_set_allowed_methods() with which the
user can change that bitmask.

no regressions here and my test-app still works. Haven't yet
actually tested any of the new methods.

What's obviously missing here is the special logic for the methods:

OPTIONS: We should be fine here - I believe our current dispatch
logic should work fine. Some convenience functions would be fine
though.

TRACE: I'm pretty certain we should never dispatch this to the
callbacks and simply implement the necessary functionality built-in.

CONNECT: Pretty straight-forward to implement (and considering the
framework in which we implement it very efficient too). Should
probably go built-in.

PATCH: Except for checking the RFC against our pre-dispatch logic
(there just might be some "MUST not have Some-Header" lurking
somewhere) there is nothing to be done here, this is completely up
to the user. Nothing to do.

13 years agoDon't free evdns_request handles until after the callback is invoked
Nick Mathewson [Wed, 3 Nov 2010 16:37:37 +0000 (12:37 -0400)]
Don't free evdns_request handles until after the callback is invoked

Previously, once the callback was scheduled, it was unsafe to cancel
a request, but there was no way to tell that.  Now it is safe to
cancel a request until the callback is invoked, at which point it
isn't.

Found and diagnosed by Denis Bilenko.

13 years agoFix more wn64 warnings.
Christopher Davis [Wed, 3 Nov 2010 21:38:45 +0000 (14:38 -0700)]
Fix more wn64 warnings.

13 years agoMerge branch 'http_nolegacy_v2'
Nick Mathewson [Wed, 3 Nov 2010 19:18:34 +0000 (15:18 -0400)]
Merge branch 'http_nolegacy_v2'

13 years agoRemove need for http_compat.h in http tests
Nick Mathewson [Wed, 3 Nov 2010 19:17:57 +0000 (15:17 -0400)]
Remove need for http_compat.h in http tests

13 years agoStop accessing http request struct directly from in the unit tests.
Nick Mathewson [Wed, 3 Nov 2010 19:14:29 +0000 (15:14 -0400)]
Stop accessing http request struct directly from in the unit tests.

13 years agoAdd evhttp_response_code to remove one more reason to include http_struct.h
Nick Mathewson [Wed, 3 Nov 2010 19:12:08 +0000 (15:12 -0400)]
Add evhttp_response_code to remove one more reason to include http_struct.h

13 years agoStop using event_compat.h in regress_http
Nick Mathewson [Wed, 3 Nov 2010 19:04:44 +0000 (15:04 -0400)]
Stop using event_compat.h in regress_http

13 years agoConvert the rest of the http tests to be non-legacy unit tests.
Nick Mathewson [Wed, 3 Nov 2010 18:31:23 +0000 (14:31 -0400)]
Convert the rest of the http tests to be non-legacy unit tests.

13 years agoRename the confusing "base" static variable in regress_http.c
Nick Mathewson [Wed, 3 Nov 2010 18:13:20 +0000 (14:13 -0400)]
Rename the confusing "base" static variable in regress_http.c

13 years agoStart porting http tests to not use legacy interfaces
Nick Mathewson [Wed, 3 Nov 2010 17:55:20 +0000 (13:55 -0400)]
Start porting http tests to not use legacy interfaces

13 years agoReplace exact-version checks for HTTP/1.1 with >= or < checks
Nick Mathewson [Tue, 2 Nov 2010 19:19:12 +0000 (15:19 -0400)]
Replace exact-version checks for HTTP/1.1 with >= or < checks

13 years agoreset "chunked" flag when sending non-chunked reply
Joachim Bauch [Tue, 2 Nov 2010 17:50:57 +0000 (13:50 -0400)]
reset "chunked" flag when sending non-chunked reply

13 years agoUse the label_len local variable in evdns instead of recalculating it over and over
Nick Mathewson [Tue, 2 Nov 2010 16:42:35 +0000 (12:42 -0400)]
Use the label_len local variable in evdns instead of recalculating it over and over

13 years agoFix win32 build in response to fixes from win64 build.
Nick Mathewson [Mon, 1 Nov 2010 18:23:33 +0000 (14:23 -0400)]
Fix win32 build in response to fixes from win64 build.

13 years agofix signed/unsigned warnings in http.c
Nick Mathewson [Mon, 1 Nov 2010 18:16:39 +0000 (14:16 -0400)]
fix signed/unsigned warnings in http.c

13 years agoFix a typo in 7484df61c981fc33db2~
Nick Mathewson [Mon, 1 Nov 2010 18:15:34 +0000 (14:15 -0400)]
Fix a typo in 7484df61c981fc33db2~

13 years agoFix even more win64 warnings: buffer, event_tagging, http, evdns, evrpc
Nick Mathewson [Mon, 1 Nov 2010 17:59:04 +0000 (13:59 -0400)]
Fix even more win64 warnings: buffer, event_tagging, http, evdns, evrpc

13 years agoFix even more win64 warnings
Nick Mathewson [Mon, 1 Nov 2010 17:43:43 +0000 (13:43 -0400)]
Fix even more win64 warnings

13 years agoRename "size" variables in win32select that were really fd counts.
Nick Mathewson [Mon, 1 Nov 2010 15:48:57 +0000 (11:48 -0400)]
Rename "size" variables in win32select that were really fd counts.

13 years agoIncrease the skew tolerance to 2 seconds in thread/deferred_cb_skew
Christopher Davis [Thu, 28 Oct 2010 17:11:25 +0000 (10:11 -0700)]
Increase the skew tolerance to 2 seconds in thread/deferred_cb_skew

This is to make the test not fail on Sebastian Hahn's Win7 box.

13 years agoMake sure IOCP evconnlistener uses virtual events.
Christopher Davis [Thu, 28 Oct 2010 17:08:17 +0000 (10:08 -0700)]
Make sure IOCP evconnlistener uses virtual events.

13 years agoTry to clear up more size_t vs int/long issues.
Nick Mathewson [Thu, 28 Oct 2010 02:57:53 +0000 (22:57 -0400)]
Try to clear up more size_t vs int/long issues.

13 years agoFix signal handler types for win64.
Nick Mathewson [Wed, 27 Oct 2010 21:37:32 +0000 (17:37 -0400)]
Fix signal handler types for win64.

13 years agoSet _EVENT_SIZEOF_VOID_P correctly on win32 and win64
Dimitre Piskyulev [Wed, 27 Oct 2010 21:32:41 +0000 (17:32 -0400)]
Set _EVENT_SIZEOF_VOID_P correctly on win32 and win64

13 years agoFix some ints to evutil_socket_t; make tests pass on win64.
Dimitre Piskyulev [Wed, 27 Oct 2010 21:31:52 +0000 (17:31 -0400)]
Fix some ints to evutil_socket_t; make tests pass on win64.

13 years agoFix som event_warns that should have been event_warnx
Nick Mathewson [Wed, 27 Oct 2010 14:36:08 +0000 (10:36 -0400)]
Fix som event_warns that should have been event_warnx

13 years agoMerge remote branch 'trondn/master'
Nick Mathewson [Wed, 27 Oct 2010 14:27:04 +0000 (10:27 -0400)]
Merge remote branch 'trondn/master'

13 years agoCheck return value for ioctlsocket on win32
Trond Norbye [Wed, 27 Oct 2010 10:47:07 +0000 (12:47 +0200)]
Check return value for ioctlsocket on win32

13 years agoFix some uses of int for socket in regress
Nick Mathewson [Wed, 27 Oct 2010 02:27:57 +0000 (22:27 -0400)]
Fix some uses of int for socket in regress

13 years agoMerge remote branch 'github/20_http_read_after_write'
Nick Mathewson [Wed, 27 Oct 2010 01:33:22 +0000 (21:33 -0400)]
Merge remote branch 'github/20_http_read_after_write'

13 years agoMerge remote branch 'github/20_abi_breaks'
Nick Mathewson [Wed, 27 Oct 2010 01:33:13 +0000 (21:33 -0400)]
Merge remote branch 'github/20_abi_breaks'

13 years agoMerge remote branch 'github/20_ratelim_size'
Nick Mathewson [Wed, 27 Oct 2010 01:33:05 +0000 (21:33 -0400)]
Merge remote branch 'github/20_ratelim_size'

13 years agoMerge remote branch 'github/20_chain_realign'
Nick Mathewson [Wed, 27 Oct 2010 01:32:53 +0000 (21:32 -0400)]
Merge remote branch 'github/20_chain_realign'

13 years agoFix bugs in posix thread-id calculation when sizeof(pthread_t) != sizeof(long)
Nick Mathewson [Tue, 26 Oct 2010 16:09:20 +0000 (12:09 -0400)]
Fix bugs in posix thread-id calculation when sizeof(pthread_t) != sizeof(long)

When pthread_t was smaller, our calculated thread IDs would include
uninitialized RAM, and so our unit tests would fail because thread_ids
would never match one another.

When pthread_t was larger and alignment was big-endian, our calculated
thread IDs would only have the most significant bytes of the
pthread_t, when in practice all the entropy is in the low-order bytes.

Found with help from Dagobert Michelsen.

13 years agoRemove event-config.h from .gitignore; it moved to include/event2
Nick Mathewson [Tue, 26 Oct 2010 15:07:26 +0000 (11:07 -0400)]
Remove event-config.h from .gitignore; it moved to include/event2

13 years agoFix a minor syntax error that most compilers didn't care about
Nick Mathewson [Tue, 26 Oct 2010 15:01:58 +0000 (11:01 -0400)]
Fix a minor syntax error that most compilers didn't care about

13 years agoNote that 2.0.9 will break the ABI, and make changes we were postponing.
Nick Mathewson [Tue, 26 Oct 2010 14:38:30 +0000 (10:38 -0400)]
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).

13 years agoMake rate-limits go up to SIZE_MAX/EV_SSIZE_MAX, not just INT32_MAX
Nick Mathewson [Tue, 26 Oct 2010 14:27:29 +0000 (10:27 -0400)]
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.

13 years agoCorrect logic for realigning a chain in evbuffer_add
Nick Mathewson [Tue, 26 Oct 2010 02:36:23 +0000 (22:36 -0400)]
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.

13 years agoAvoid missed-request bug when entire http request arrives before data is flushed
Nick Mathewson [Tue, 26 Oct 2010 01:53:15 +0000 (21:53 -0400)]
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.

13 years agoCorrectly count req->body_size on http usage without Content-Length
Nick Mathewson [Mon, 25 Oct 2010 20:09:11 +0000 (16:09 -0400)]
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.

13 years agoFix a bug where we would read too much data in HTTP bodies or requests.
Nick Mathewson [Mon, 25 Oct 2010 20:00:47 +0000 (16:00 -0400)]
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.

13 years agoFix Content-Length when trying send more than 100GB of data (!) on an evhttp.
Nick Mathewson [Mon, 25 Oct 2010 19:49:42 +0000 (15:49 -0400)]
Fix Content-Length when trying send more than 100GB of data (!) on an evhttp.

13 years agoadd a requested docstring for event_rpcgen.CommandLine.__init__
Nick Mathewson [Mon, 25 Oct 2010 19:23:41 +0000 (15:23 -0400)]
add a requested docstring for event_rpcgen.CommandLine.__init__

13 years agoMerge remote branch 'github/http_and_listener'
Nick Mathewson [Mon, 25 Oct 2010 19:13:32 +0000 (15:13 -0400)]
Merge remote branch 'github/http_and_listener'

13 years agoMake evbuffer_add_file take ev_off_t, not off_t
Nick Mathewson [Mon, 25 Oct 2010 18:29:30 +0000 (14:29 -0400)]
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.

13 years agoFunctions to actually use evhttp_bound_socket with/as evconnlistener.
Nick Mathewson [Mon, 25 Oct 2010 15:50:51 +0000 (11:50 -0400)]
Functions to actually use evhttp_bound_socket with/as evconnlistener.

13 years agoAdd a function to change a listener's callback.
Nick Mathewson [Mon, 25 Oct 2010 15:47:05 +0000 (11:47 -0400)]
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.

14 years agoSimplify the logic for choosing EPOLL_CTL_ADD vs EPOLL_CTL_MOD
Nick Mathewson [Sun, 24 Oct 2010 15:51:14 +0000 (11:51 -0400)]
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

14 years agoFix a nasty bug related to use of dup() with epoll on Linux
Nick Mathewson [Sun, 24 Oct 2010 15:38:29 +0000 (11:38 -0400)]
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.

14 years agoMerge branch 'http_uri_parse'
Nick Mathewson [Thu, 21 Oct 2010 19:33:13 +0000 (15:33 -0400)]
Merge branch 'http_uri_parse'

14 years agoUnit tests for evhttp_uri_set*
Nick Mathewson [Thu, 21 Oct 2010 18:53:21 +0000 (14:53 -0400)]
Unit tests for evhttp_uri_set*

14 years agoMake evhttp_uri non-public, and give it accessor functions.
Nick Mathewson [Thu, 21 Oct 2010 18:41:12 +0000 (14:41 -0400)]
Make evhttp_uri non-public, and give it accessor functions.

14 years agoDocument that two bufferevent functions only work on socket bufferevents
Nick Mathewson [Thu, 21 Oct 2010 18:05:04 +0000 (14:05 -0400)]
Document that two bufferevent functions only work on socket bufferevents

14 years agoAdd a bufferevent_get_base function
Nick Mathewson [Thu, 21 Oct 2010 18:04:24 +0000 (14:04 -0400)]
Add a bufferevent_get_base function

14 years agoUpdate the HTTP regression tests to use Libevent2 apis for non-http stuff
Nick Mathewson [Thu, 21 Oct 2010 16:48:13 +0000 (12:48 -0400)]
Update the HTTP regression tests to use Libevent2 apis for non-http stuff

14 years agoStop using Libevent-1 headers in regress_http
Nick Mathewson [Thu, 21 Oct 2010 16:27:16 +0000 (12:27 -0400)]
Stop using Libevent-1 headers in regress_http

14 years agoMerge branch 'http_small_tweaks'
Nick Mathewson [Thu, 21 Oct 2010 16:23:10 +0000 (12:23 -0400)]
Merge branch 'http_small_tweaks'

Conflicts:
http-internal.h

14 years agoAdd evhttp_connection_get_base() to get the event_base from an http connection
Nick Mathewson [Thu, 21 Oct 2010 16:19:28 +0000 (12:19 -0400)]
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

14 years agoFix a 100%-CPU bug where an SSL connection would sometimes never stop trying to write
Nick Mathewson [Wed, 20 Oct 2010 17:41:02 +0000 (13:41 -0400)]
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

14 years agoAdd evhttp_parse_query_str to be used with evhttp_uri_parse.
Nick Mathewson [Tue, 19 Oct 2010 17:15:48 +0000 (13:15 -0400)]
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.

14 years agoDocument behavior of URI parsing more thoroughly.
Nick Mathewson [Tue, 19 Oct 2010 17:02:18 +0000 (13:02 -0400)]
Document behavior of URI parsing more thoroughly.

Also, move evhttp_uri struct into http.h, since it is part of the API.

14 years agoAdd a huge pile of tests for the new URI functions, and make them pass.
Nick Mathewson [Tue, 19 Oct 2010 16:35:50 +0000 (12:35 -0400)]
Add a huge pile of tests for the new URI functions, and make them pass.

14 years agoImprovements to tinytest_macros.h
Nick Mathewson [Tue, 19 Oct 2010 16:33:50 +0000 (12:33 -0400)]
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.

14 years agoRevise evhttp_uri_parse implementation to handle more of RFC3986
Nick Mathewson [Tue, 19 Oct 2010 15:26:59 +0000 (11:26 -0400)]
Revise evhttp_uri_parse implementation to handle more of RFC3986