1632 Commits

Author SHA1 Message Date
Nick Mathewson
94131e92b8 Fix test.sh on shells without echo -n
Some systems have a version of /bin/sh whose builtin echo doesn't
support the -n option used in test/test.sh.  /bin/echo, however,
usually does.  This patch makes us use /bin/echo for echo -n whenever
it is present.

Also, our use of echo -n really only made sense when suppressing all
test output.  Since test output isn't suppressed when logging to a
file, this pach makes us stop using echo -n when logging to a file.
2010-01-12 15:58:36 -05:00
Nick Mathewson
b9f43b231f Add a comment on evthread_enable_lock_debuging. 2010-01-11 20:47:45 -05:00
Pavel Plesov
6cc79c6b40 Add unit-test for bad_request bug fixed in 1.4 recently.
This is a partial forward-port from 4fd2dd9d83a000b6.  There's no need
to forward-port the bugfix, since the test passes with http.c as-is.
I believe we fixed this while we were porting evhttp to bufferevent.
--nickm
2010-01-11 19:04:11 -05:00
Jardel Weyrich
510ab6bce0 Comestic changes in evconnlistener_new(), new_accepting_socket(), accepted_socket_invoke_user_cb() and iocp_listener_enable(). 2010-01-08 23:28:54 -05:00
Jardel Weyrich
fec66f9685 Improved error handling in evconnlistener_new_async(). Also keeping the fd open because it is not opened by this function, so the caller is responsible for closing it. Additionally, since evconnlistener_new_bind() creates a socket and passes it to the function above, it required error checking to close the same socket. 2010-01-08 23:28:23 -05:00
Jardel Weyrich
4367a33a20 Fixed a fd leak in start_accepting(), plus cosmetic changes 2010-01-08 23:27:26 -05:00
Jardel Weyrich
2f33e00af3 Fixed a memory leak on windows threads implementation. The CRITICAL_SECTION was not being free'd in evthread_win32_lock_free(). 2010-01-08 23:26:01 -05:00
Nick Mathewson
66c02c7826 Look at the proper /etc/hosts file on windows.
This is harder than it might initially seem, since the proper filename
depends on what the admin has decided to call the windows system directory,
which for all we know might be Q:\tralfamidore\slartibartfast.  And of course,
this being windows, there are twelve ways to do it, where you can pick a
nice one or a portable one, but not a really nice portable one.
2010-01-08 19:36:38 -05:00
Nick Mathewson
72dd666777 evdns_getaddrinfo() now supports the /etc/hosts file.
The regular blocking evutil_getaddrinfo() already supported /etc/hosts
by falling back to getaddrinfo() or gethostbyname().  But
evdns_getaddrinfo() had no such facility.  Now it does.

The data structure here isn't very clever.  I guess people with huge
/etc/hosts files will either need to get out of the 1980s, or submit a
patch to this code so that it uses a hashtable instead of a linked
list.

Includes basic unit tests.
2010-01-08 19:36:37 -05:00
Nick Mathewson
0f7144fd8b Refactor code from evdns into a new internal "read a file" function. 2010-01-08 19:36:35 -05:00
Nick Mathewson
eaaf27f1f7 Enable branch-prediction hints with EVUTIL_UNLIKELY.
This had been accidentally disabled.  Since it seems to work with GCC, I'm
turning it back on when GCC is present.
2010-01-06 18:50:19 -05:00
Nick Mathewson
29151e65b7 Fix byte counts when mixing deferred and non-deferred evbuffer callbacks.
This patch finishes 390e0561, which was somehow committed in a half-finished
state.  It solves a failing unit test on windows.
2010-01-06 18:42:59 -05:00
Nick Mathewson
ba2945f931 Merge branch 'ratelimit'
Conflicts:
	bufferevent_async.c
2010-01-06 17:59:44 -05:00
Jardel Weyrich
0546ce11e8 Eradicated the last free() call. Let mm_free() take care of deallocation. 2009-12-30 17:28:05 -05:00
Nick Mathewson
165d30e31a Fix compilation of rate-limiting code on win32. 2009-12-30 14:29:56 -05:00
Nick Mathewson
885b42734c Fix test-ratelim compilation on Linux.
I'd forgotten to include time.h, and to link against libm.
2009-12-30 13:50:52 -05:00
Nick Mathewson
78ed097267 Never believe that we have pthreads on win32, even if gcc thinks we do.
Apparently some newer versions of mingw provide a fake pthreads api to
let applications work even if they don't know about windows threading.
That's nice, but we aren't one of those.
2009-12-30 13:30:20 -05:00
Nick Mathewson
2e8eeea3e8 Fix crash bugs when a bufferevent's eventcb is not set.
In many places throughout the code, we called _bufferevent_run_eventcb
without checking whether the eventcb was actually set.  This would
work fine when the bufferevent's callbacks were deferred, but
otherwise the code would segfault.  Strangely, we always remembered to
check before calling the _bufferevent_run_{read,write}cb functions.

To prevent similar errors in the future, all of
_buferevent_run_{read,write,event}cb now check to make sure the
callback is actually set before invoking or deferring the callback.
This patch also removes the now-redundant checks for {read,write}cb.
2009-12-29 19:50:03 -05:00
Nick Mathewson
0b151a9fa1 Whitespace fixes in test.sh 2009-12-29 18:11:52 -05:00
Nick Mathewson
7dfbe94aa3 Allow test.sh to be run as ./test/test.sh 2009-12-29 18:07:51 -05:00
Nick Mathewson
c382de6421 Allow the user to redirect the verbose output of test/test.sh to a file
By default, the test.sh script still suppresses the output of all the
tests it invokes.  Now, however, you can have that output written to
a file specified in the TEST_OUTPUT_FILE shell variable.
2009-12-29 17:59:55 -05:00
Nick Mathewson
1e56a32d08 Make the initial nameserver probe timeout configurable.
When we decide that a nameserver is down, we stop sending queries to
it, except to periodically probe it to see if it has come back up.
Our previous probe sechedule was an ad-hoc and hard-wired "10 seconds,
one minute, 5 minues, 15 minutes, 1 hour, 1 hour, 1 hour...".  There
was nothing wrong with having it be ad-hoc, but making it hard-wired
served no good purpose.

Now the user can set the initial timeout via a new
"initial-probe-timeout:" option; future timeouts back off by a factor
of 3 on every failure to a maximum of 1 hour.

As a side-benefit, this lets us cut the runtime of the dns/retry test
from about 40 seconds to about 3 seconds.  Faster unit tests are
always a good thing.
2009-12-29 16:04:16 -05:00
Nick Mathewson
ee4953f89e Fix the code that allowed DNS options to not end with :
We tried to fix this in 0.2.0.3-alpha, but our fix was buggy.
2009-12-29 16:03:30 -05:00
Jardel Weyrich
d0939d2b97 Introduced evutil_make_socket_closeonexec() to preserve fd flags for F_SETFD.
Use this to eliminate the various macros that called F_SETFD throughout
the code.
2009-12-29 15:12:56 -05:00
Jardel Weyrich
4df7dbcbdf Adjusted fcntl() retval comparison on evutil_make_socket_nonblocking().
Apparently, a successful return value on F_SETFL is "anything but
-1".
2009-12-29 15:11:52 -05:00
Nick Mathewson
8111fac065 Add missing thread imports so that evport.c will build
When I made the changes to release the base lock around the call to
port_getn(), I didn't add evthread-internal.h to the includes in
evport.c would build, and I didn't catch it since I haven't got a
Solaris host to build on.  Tao Feng just reported this on
Libevent-users.
2009-12-29 14:38:35 -05:00
Nick Mathewson
82743794d3 Do not make bufferevent_setfd implicitly disable EV_READ and EV_WRITE.
This obviates the need for BEV_SUSPEND_CONNECTING, and good riddance.
2009-12-28 16:59:07 -05:00
Nick Mathewson
f0c0124e60 Testing code for bufferevent rate-limiting.
This is not part of the regression tests, since running it necessarily
takes a while.  There is a new test-ratelim test; run it with '-h'
for an argument to see its options.
2009-12-28 16:58:22 -05:00
Nick Mathewson
737c9cd87b Rate-limiting for bufferevents; group and individual limits are supported.
The fairness algorithms are not the best, not every bufferevent type
is supported, and some of the locking tricks here are simply absurd.
Still, this code should be a good first step.
2009-12-28 16:11:18 -05:00
Nick Mathewson
47854a802a Expose our cached gettimeofday value with a new interface
I've got a two use case that wants this for a fairly sensible purpose:
one external and on internal.
2009-12-28 16:11:18 -05:00
Jardel Weyrich
5a43df82b8 Improve readability of evutil_unparse_protoname() 2009-12-28 16:03:47 -05:00
Jardel Weyrich
0d64051f5b Fix a bogus free in evutil_new_addrinfo() 2009-12-28 16:01:59 -05:00
Jardel Weyrich
24fb502f70 Fix an fd leak in evconnlistener_new_bind(). 2009-12-28 16:01:12 -05:00
Jardel Weyrich
4c8b7cdc64 Make evutil_make_socket_nonblocking() leave any other flags alone.
Fixes bug 2922121
2009-12-28 16:00:05 -05:00
Dagobert Michelsen
fee2c77919 Fix compilation of devpoll.c by adding missing thread includes.
(Bug 2922156)
2009-12-28 15:53:01 -05:00
Nick Mathewson
a47d88d7c2 Replace some cases of uint32_t with ev_uint32_t.
Spotted by Roman Puls.
2009-12-23 07:53:19 -05:00
Nick Mathewson
4a5b53432b Do not ignore bufferevent_enable(EV_READ) before bufferevent_connect().
Previously, we weren't remembering that we wanted to re-add the read
event once the connect was finished.  Now we are.
2009-12-23 07:48:43 -05:00
Nick Mathewson
390e056152 Fix up behavior of never-defered callbacks a little 2009-12-22 15:52:12 -05:00
Nick Mathewson
5846bf6cdd Simplify the read high-watermark checking. 2009-12-22 15:52:12 -05:00
Nick Mathewson
c69d5a5d3c Remove the contents of WIN32-Prj as unmaintained.
Makefile.nmake is now the preferred way	to build with MSVC; the
project files haven't worked properly in ages.
2009-12-22 15:52:12 -05:00
Nick Mathewson
292467c02e Use evutil_socket_t, not int, when logging socket errors. 2009-12-22 00:58:52 -05:00
unknown
c51bb3c342 Fix a few locking issues on windows. 2009-12-21 16:36:40 -05:00
Nick Mathewson
5a112d3c07 Set all instances of the version number correctly.
Note that we've made two subtle mistakes: we are supposed to suffix
any non-released version with "-dev", and we're supposed to use the
last byte of the numeric version to indicate whether we have done this.

For example, when 2.0.4-alpha is released, its numeric versin will be
0x 02 00 04 00.  As soon as we tag it, we will change the version in
the git repository to 2.0.4-alpha-dev, whose numeric version will be
0x 02 00 04 01 or something.
2009-12-18 23:37:50 -05:00
Nick Mathewson
67995270ff Drop install-sh from our git repo: a mismatched version could break "make dist" 2009-12-18 17:04:37 -05:00
Joachim Bauch
a773df54ce Fix a segfault when freeing SSL bufferevents in an unusual order
Have container bufferevents hold a reference to their underlying bufferevents.

(Commit message and minor revisions by nickm.)
2009-12-18 16:26:40 -05:00
Joachim Bauch
a6adeca72c Fix a segfault when writing a very fragmented evbuffer onto an SSL
Fixes bug 2916328.
2009-12-17 12:38:46 -05:00
Evan Jones
f6430ac1e3 Update sample/signal-test.c to use newer APIs and not leak. 2009-12-08 17:05:30 -05:00
Joachim Bauch
ea6b1df288 Only define _GNU_SOURCE if it is not already defined. 2009-12-08 15:38:34 -05:00
Sebastian Hahn
70cdfe49fa Fix compile on Snow Leopard with gcc warnings enabled 2009-12-06 02:59:19 +01:00
Nick Mathewson
7ae94450fd Fix a snow leopard compile warning in the unit tests.
Reported by Sebastian Hahn.
2009-12-04 16:37:47 -05:00