1632 Commits

Author SHA1 Message Date
Christopher Davis
de1f5d6d87 Remember to initialize timeout events for bufferevent_async
Fixes segfaults in unit tests.
2010-08-06 09:51:47 -04:00
Nick Mathewson
170ffd2b1d Increase the tolerance in our unit tests for sloppy clocks.
(Apparently openbsd in virtualbox just doesn't keep very accurate time.)
2010-08-05 15:57:30 -04:00
Nick Mathewson
e996b3d411 Make tests quieter on local dns resolver failure 2010-08-05 15:51:16 -04:00
Nick Mathewson
4558ce2322 Merge branch 'openssl_ratelim' 2010-08-04 17:31:28 -04:00
Nick Mathewson
b2c6202d65 Fix an assertion bug in test-ratelim
If the rate limit was low enough, then the echo_conns wouldn't finish
inside the 300 msec we allowed for them to close.  Instead, count the
number of connections we have, and keep waiting until they are all
closed.
2010-08-04 15:52:32 -04:00
Nick Mathewson
42f6b62414 Add option to test-ratelim to test min_share 2010-08-04 15:51:14 -04:00
Nick Mathewson
6ae53d6762 Add an interface to expose min_share in ratelimiting groups 2010-08-04 15:44:08 -04:00
Nick Mathewson
009f300532 Fix rate-limit calculation on openssl bufferevents.
When you're doing rate limiting on an openssl connection, you nearly
always want to limit the number of bytes sent and received over the
wire, not the number of bytes read or written over the secure
transport.
2010-08-04 14:54:38 -04:00
Trond Norbye
13b912e4ac Fixed compilation of sample/le-proxy.c on win32 2010-08-01 21:39:48 +02:00
Nick Mathewson
42a8c71112 Build more cleanly with NetBSDs that dislike toupper(char)
To be fair, when char can be signed, if toupper doesn't take negative
characters, toupper(char) is a very bad idea.  So let's just use the
nice safe EVUTIL_TOUPPER instead.  (It explicitly only upcases ASCII,
but we only use it for identifiers that we know to be ASCII anyway).
2010-07-31 17:10:04 -04:00
Joachim Bauch
840a72fbd5 Fix badly-behaved subtest of dns/bufferevent_connect_hostname
The bufferevent_connect_hostname test was specifying AF_INET, but the
gethostbyname test we were using to see what error to expect was using
PF_UNSPEC, leading to possible divergence of results.
2010-07-29 20:32:40 -04:00
Nick Mathewson
9e725f72e7 Improve error message for failed epoll to make debugging easier. 2010-07-29 18:12:04 -04:00
Nick Mathewson
cc2379d264 Constify a couple of arguments to evdns_server_request_add_*_reply 2010-07-26 14:48:32 -04:00
Nick Mathewson
e1c1167cbe Replace (unused,always 0) is_tcp argument to evdns_add_server_port*() with flags
Since we weren't using it for anything, and we always failed if it was
set, we're allowed to change the future semantics of setting it.
2010-07-22 14:44:24 +02:00
Nick Mathewson
7e87a599bb Stop asserting when asked for a (unsupported) TCP dns port. Just return NULL. 2010-07-21 14:33:42 +02:00
Mike Smellie
c991317409 Change bufferevent_openssl::do_write so it doesn't call SSL_write with a 0 length buffer
I was running into a problem when using bufferevent_openssl with a
very simple echo server.  My server simply bufferevent_read_buffer 'd
data into an evbuffer and then passed that evbuffer straight to
bufferevent_write_buffer.

The problem was every now and again the write would fail for no
apparent reason. I tracked it down to SSL_write being called with the
amount of data to send being 0.

This patch alters do_write in bufferevent_openssl so that it skips
io_vecs with 0 length.
2010-07-19 15:28:03 +02:00
Nick Mathewson
7c926916b2 Make test/test.sh call test-changelist
Eventually test-changelist should expand to try more cases, maybe
query the status of the actual changelist somehow, and integrate it
with the rest of the unit tests.

Also, add test-changelist to gitignore.
2010-07-19 15:16:29 +02:00
Nick Mathewson
cb927a5173 Fix whitespace. 2010-07-19 15:03:43 +02:00
Nick Mathewson
b00d4c0452 Remove unused variables in test/test-changelist.c 2010-07-19 14:58:08 +02:00
Mike Smellie
cf249e7d99 Possible fix to 100% cpu usage with epoll and openssl
I'm running a fairly simple bit of test code using libevent2 with epoll and
openssl bufferevents and I've run into a 100% cpu usage problem.

Looking into it 100% usage was caused by epoll_wait constantly
returning write events on the openssl socket when it shouldn't really have
been looking for write events at all (N_ACTIVE_CALLBACKS() was returning 0
also).

Looking a bit deeper eventbuffer_openssl socket seems to be requesting
that the EV_WRITE event be removed when it should, but the event isn't
actually being removed from epoll.

Continuing to follow this I think I've found a bug in
event_changelist_del.

For evpoll event_del calls event_changelist_del which caches the change
which is then actioned later when evpoll_dispatch is called.

In event_changlist_del there is a check so that if the currently changed
action is an add then the cached action is changed to a no-op rather than a
delete (which makes sense). The problem arises if there are more than
two add or delete operations between calls to dispatch, in this case it's
possible that the delete is turned into a no-op when it shouldn't have
been.

For example starting with the event on, a delete followed by an add and
then another delete results in a no-op when it should have been a delete (I
added a fair bit of debug output that seems to confirm this behaviour).

I've applied a small change that checks the original old_event stored with
the change and only converts the delete to a no-op if the event isn't on in
old_event. This seems to have fixed my problem.
2010-07-19 14:55:15 +02:00
Nick Mathewson
928b7d4960 Merge branch 'pncalls_fix' 2010-07-16 12:38:23 -04:00
niks
65abdc2011 Fix wrong sie calculation of iovec buffers when exact=1
The old code had a bug where the 'exact' flag to 1 in
_evbuffer_read_setup_vecs would never actually make the iov_len field
of the last iovec get truncated.  This patch fixes that.
2010-07-16 09:11:09 -04:00
Nick Mathewson
7c2dea1615 Pass flags to fcntl(F_SETFL) and fcntl(F_SETFD) as int, not long
Everybody but Linux documents this as taking an int, and Linux is
very tolerant of getting an int instead.  If it weren't, everybody
doing fcntl(fd,F_SETFL,O_NONBLOCK) would break, since the glibc
headers define O_NONBLOCK as an int literal.
2010-07-13 11:09:47 -04:00
Nick Mathewson
e73cbde15f Suppress a spurious EPERM warning in epoll.c
It's okay for us to get an EPERM when doing an EPOLL_DEL on an fd; it
just means that before we got a chance to the EPOLL_DEL, we closed the
fd and reopened a new non-socket that wound up having the same fd.

Partial fix for Bug 3019973.
2010-07-08 14:41:02 -04:00
Nick Mathewson
fc5e0a2344 Don't race when calling event_active/event_add on a running signal event
There was previously no lock protecting the signal event's
ev_ncalls/ev_pncalls fields, which were accessed by all of
event_signal_closure, event_add_internal, event_del_internal, and
event_active_nolock.  This patch fixes this race by using the
current_event_lock in the same way it's used to prevent
event_del_internal from touching an event that's currently running.
2010-07-05 14:39:39 -04:00
Nick Mathewson
61e1eeec6f Tidy up the code in evthread_make_base_notifiable a little
Previously, we had a few conditional statements with the "if (...)"
inside an #ifdef and the body outside.  That kind of thing is hard to
read.
2010-07-05 13:24:45 -04:00
Nick Mathewson
a5bc15b2e1 Drain th_notify_fd[0] more bytes at a time. 2010-07-05 13:24:12 -04:00
Nick Mathewson
17522d2af8 Fix a deadlock related to event-base notification. Diagnosed by Zhou Li, Avi Bab, and Scott Lamb.
The problem was that the thread doing the notification could block on
write in evthread_notify_base_default while holding the th_base_lock.
The main thread would never drain th_notify_fd[0], since it would need
th_base_lock to actually trigger events.
2010-07-05 13:17:47 -04:00
Nick Mathewson
d89fdba424 Make sample/hello_world work on windows
We forgot to include the WSAStartup call in main().

Patch from an anonymous user on Sourceforge.

Fixes bug 3025354.
2010-07-05 12:28:22 -04:00
Nick Mathewson
085987093f never let bufferevent_rlim functions return negative 2010-07-05 12:26:21 -04:00
Sebastian Hahn
142500317e Really only add libevent_core.la to LIBADD on mingw
Commit fdc629736e1 tried to do this, but added it for mingw and
for everything else. Fixes a segfault in bufferevent unittests.
2010-06-23 01:15:15 +02:00
Nick Mathewson
215e629cd4 Add bufferevent_lock()/bufferevent_unlock()
Although bufferevent operations are threadsafe, sometimes you need
to make sure that a few operations on a single bufferevent will all
be executed with nothing intervening.  That's what these functions
are for.
2010-06-21 12:26:21 -04:00
Nick Mathewson
7b259b6796 Fix sentence fragment in docs for event_get_struct_event_size() 2010-06-21 12:24:49 -04:00
Nick Mathewson
7510aac3b9 Unit test for event_get_struct_event_size() 2010-06-21 12:23:32 -04:00
Nick Mathewson
9659eced03 Add a comment to describe our plan for library versioning 2010-06-19 18:23:16 -04:00
Nick Mathewson
b2d7440a91 Set library version for libevent_pthreads correctly 2010-06-19 18:22:48 -04:00
Nick Mathewson
e21f5d15eb Document a change in the semantics of event_get_struct_event_size() 2010-06-19 18:21:40 -04:00
Nick Mathewson
8a44062308 Have autogen.sh pass --force-missing to automake
Previously, our autogen.sh script wouldn't tell automake to update
older versions of its copied-in scripts, which would cause problems if
they got sufficiently out-of-date.
2010-06-17 10:33:06 -04:00
Nick Mathewson
9b14911654 Remove some automake-generated files from version control. 2010-06-17 10:32:56 -04:00
Nick Mathewson
276e7ee97e Fix a pedantic gcc 4.4 warning in event2/event.h 2010-06-11 11:57:13 -04:00
Felix Nawothnig
29b2e233a7 Fix possible nullptr dereference in evhttp_send_reply_end()
(The existing implementation had sanity-checking code for the case where
 its argument was NULL, but it erroneously dereferenced it before actually
 doing the sanity-check. --nickm)
2010-06-07 13:25:58 -04:00
Nick Mathewson
17a8e2d72b Add a function to retrieve the other side of a bufferevent pair 2010-06-07 12:06:43 -04:00
Nick Mathewson
44d57eee93 Add test for behavior on remote socket close
On all the backends on this little mac laptop, that behavior is to
report a remote socket close as both EV_READ and EV_WRITE.
Historically, we had problem for some of these behaviors on some
backends, so let's make sure that such behaviors don't come back.
2010-06-03 11:25:54 -04:00
Nick Mathewson
3467f2fa3b Fix logic in correcting high values from FIONREAD
The old logic made sense back when buffer.c was an enormous linear
buffer, but it doesn't make any sense for the chain-based
implementation.

This patch also refactors the ioctl{socket}? call into its own function.
2010-05-28 15:05:32 -04:00
Pierre Phaneuf
0798dd1247 Close the file in evutil_read_file whether there's an error or not.
evutil_read_file would close the file if there was an error, but not if things went normally.
2010-05-27 22:37:09 -04:00
Nick Mathewson
c21c663161 Add the libtool-generated /m4/* stuff to .gitignore 2010-05-27 01:32:11 -04:00
Nick Mathewson
39906698ca Let evhttp_send_error infer the right error reasons 2010-05-26 13:43:01 -04:00
Felix Nawothnig
06bd05634d Fix the default HTTP error template
The current template...

<HTML><HEAD><TITLE>%s</TITLE>
</HEAD><BODY>
<H1>Method Not Implemented</H1>
Invalid method in request<P>
</BODY></HTML>

is highly confusing. The given title is easily overlooked and the
hard-coded content is just plain wrong in most cases (I really read
this as "the server did not understand the requested HTTP method)

This patch changes the template to include the error reason in the
body as well as in the header, and to infer the proper reason from
the status code whenever the reason argument is NULL.

This patch also removes a redundant evhttp_add_header from
evhttp_send_error; evhttp_send_page already adds a "Connection:
close" header.
2010-05-26 13:43:01 -04:00
Nick Mathewson
3689bd2d49 Have the unit tests report errors from test.sh
The default behavior of test.sh was to suppress all output from
test/regress, and say nothing but OKAY or FAILED.  This wasn't so good
for getting bugs reported, since lots of people didn't know to set
TEST_OUTPUT_FILE, or re-run ./test/regress on its own.

Now, when you don't specify an output file for test.sh, it runs
regress with the --quiet option.  This option makes the unit tests
only print output on failure, which is what we probably wanted.
2010-05-26 13:43:01 -04:00
Nick Mathewson
faf2a04fa5 Make test.sh exit with nonzero status if tests fail
This behavior makes "make verify" actually fail when the tests fail,
which is what it's supposed to do.
2010-05-26 13:43:01 -04:00