1608 Commits

Author SHA1 Message Date
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
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
Nick Mathewson
8bc1e3d6d1 Remove all non-error prints from test/regress.c
Now, running ./test/regress --quiet will indeed only inform you
about errors.  Previously, it would also spew extra output.
2010-05-26 13:43:00 -04:00
Nick Mathewson
e73f1d792a Remove the now-obsolete setup_test() and cleanup_test() functions 2010-05-26 13:43:00 -04:00
Nick Mathewson
899b0a39ab Use generic win32 interfaces, not ASCII-only ones, where possible. 2010-05-24 15:24:03 -04:00
Nick Mathewson
4ff247b293 Merge branch 'evdns_no_empty_handles' 2010-05-19 10:49:49 -04:00
Nick Mathewson
47c5dfbea9 Remove some dead assignments 2010-05-18 17:28:51 -04:00
Nick Mathewson
b14f151b42 If no evdns request can be launched, return NULL, not a handle
Some of our evdns code was willing to return an evdns_request with
handle->current_req set to NULL.  Really, those cases should just
return NULL.
2010-05-18 17:27:06 -04:00
Nick Mathewson
d14bb926b4 Use -Wlogical-op on gcc 4.5 or higher
It exposed one bug for us (see 8c3452bcb294e07888), and might
prevent more.
2010-05-18 14:05:01 -04:00
Nick Mathewson
8c3452bcb2 Correctly recognize .255 addresses as link-local when looking for interfaces 2010-05-18 13:55:32 -04:00
Nick Mathewson
bda21e7ff9 Avoid close of uninitialized socket in evbuffer unit test
Attempts to fix a crash bug found by Brodie Thiesfield.
2010-05-17 11:58:07 -04:00
Nick Mathewson
caca2f451c Replace (safe) use of strcpy with memcpy to appease OpenBSD
If Libevent uses strcpy, even safely, it seems OpenBSD's linker will
complain every time a library links Libevent.  It's easier just not to
use the old thing, even when it's safe to do so.
2010-05-14 14:36:49 -04:00
Nick Mathewson
75701e897b Add some missing includes to fix Linux build again 2010-05-14 14:30:09 -04:00
Nick Mathewson
b5bfc44d6b Make test-ratelim clean up after itself better. 2010-05-13 15:40:43 -04:00
Nick Mathewson
6d195109eb Avoid event_del on uninitialized event in event_base_free
This was mostly harmless, since the event was cleared with calloc, but
still it's not a correct thing to do.
2010-05-13 15:40:43 -04:00
Nick Mathewson
2b44dccaaf Add options to test-ratelim.c to check its results
The new options let you specify a maximum deviation of bandwidth used
from expected bandwidth used, and make test-ratelim.c exit with a
nonzero status when those deviations are violated.

This patch also adds a test-ratelim.sh script to run test-ratelim with
a few sensible options for testing.
2010-05-13 15:40:43 -04:00
Nick Mathewson
218a3c372c Do not check that event_base is set in EVBASE_ACQUIRE_LOCK
In every place that we call EVBASE_ACQUIRE_LOCK, the base is either
set, or must be set, so the test is redundant.
2010-05-13 15:40:43 -04:00
Nick Mathewson
fdfc3fc502 Remove the now-unusable EVTHREAD_LOCK/UNLOCK constants 2010-05-13 15:40:43 -04:00
Nick Mathewson
33bbbed9dd Mark the event_err() functions as __attribute__((noreturn))
This attribute tells gcc (and anything else that understands gcc
attributes) that the functions will never return control, and helps
the optimizer a little.  With luck, it will also tell
less-than-full-program dataflow analysis tools that they don't need to
worry about any code path that involves calling one of these functions
and then returning.

This patch also forces event_exit() to always exit, no matter what the
user-supplied fatal_callback does.  This means that the old unit tests
for the event_err* functions don't work any more, since they assume it
is safe to call event_err* if you've given it a bogus fatal_callback
that doesn't exit.  Instead, we have to make the unit tests fork
before calling event_err(), and have the main unit test process wait
for the event_err() test to exit with a sane exit code.  On unix,
that's trivial.  On windows, let's not bother and just assume that
event_err* works.
2010-05-13 15:39:02 -04:00
Nick Mathewson
dfb75ab207 Test the unlocked-deferred callback case of bufferevents 2010-05-12 15:38:28 -04:00
Nick Mathewson
c5bab56002 Remove the obsolete evthread interfaces
These were added in 2.0.1, and deprecated in 2.0.4 and 2.0.5; we've
promised that they would be removed, and warned whenever they were
invoked.  Users should call evthread_set_lock_callbacks instead...  or
ideally just call evthread_use_windows_threads or
evthread_use_pthreads.
2010-05-11 11:44:07 -04:00
Nick Mathewson
9cb5bc86a9 Bump version to 2.0.5-beta-dev 2010-05-10 14:51:32 -04:00
Nick Mathewson
ad9b7f153d Increment version numbers for 2.0.5-beta release-2.0.5-beta 2010-05-09 00:22:08 -04:00
Nick Mathewson
f6aaf176d2 Add a changelog for 2.0.5-beta 2010-05-09 00:16:35 -04:00
Nick Mathewson
7c519dfd4f Fix some autoconf issues on OpenBSD
Issue 1: autoconf gets accept when a header works properly with cpp
but not with cc.  This was true of the sys/sysctl.h header on
openbsd.  The fix: include sys/param.h (if present) when testing for
sys/sysctl.h

Issue 2: Somehow, autoconf's macro generation code is messed up on
some versions of openbsd (including mine, and other people's too) so
that instead of SIZEOF_VOID_P, it makes SIZEOF_VOID__.
evutil/util.h now works around that.
2010-05-08 23:31:35 -04:00
Nick Mathewson
c1cd32a156 Define _REENTRANT as needed on Solaris, elsewhere
It turns out that _REENTRANT isn't only needed to make certain
functions visible; we also need it to make pthreads work properly
some places (like Solaris, where forgetting _REENTRANT basically
means that all threads are sharing the same errno).  Fortunately,
our ACX_PTHREAD() configure macro already gives us a PTHREAD_CFLAG
variable, so all we have to do is use it.
2010-05-08 22:21:52 -04:00