382 Commits

Author SHA1 Message Date
Nick Mathewson
9a772148f2 Compilation and correctness fixes for IOCP listener code.
svn:r1489
2009-11-02 19:31:29 +00:00
Nick Mathewson
8283b2f0dc Fix a major parenthesis bug in EVUTIL_UPCAST.
Fortunately, this didn't hurt anything previously, since we had no actual users of the macro where the offset of the base type wasn't 0.

svn:r1488
2009-11-02 19:30:25 +00:00
Nick Mathewson
5f1d6e640f Add more IOCP tests. They might not pass yet.
svn:r1487
2009-11-02 17:42:16 +00:00
Nick Mathewson
96c6956e02 Add a "many events" regression test.
This is a glass-box test to get more coverage on the event loop
backends.  We've run into bugs here before with fencepost errors, and
it turns out that none of our unit tests had enough events to
exercise the resize code.

Most of the backends have some kind of logic that resizes an array
when:
    - The highest fd is too high
    - The number of events added since the last iteration of the loop
      is too high
    - The number of active events is too high.

This test hits all 3 cases, and increases coverage in select.c by 7%,
in poll by 1%, and in kqueue by 9%.

svn:r1482
2009-10-30 22:43:30 +00:00
Nick Mathewson
9976f1e74c reformat weird indentation in dns tests
svn:r1478
2009-10-29 17:11:12 +00:00
Nick Mathewson
3c2198cb48 Unit test for reverse ipv6 lookup
svn:r1477
2009-10-29 17:10:36 +00:00
Nick Mathewson
5b3fb5bfa5 More documentation and unit tests for event_tagging.
svn:r1476
2009-10-29 16:35:20 +00:00
Nick Mathewson
c70c25937e Unit test for strlcpy
svn:r1474
2009-10-29 16:35:09 +00:00
Nick Mathewson
e9098203f7 Fix from Chris Davis: get error-logging to be happy on win32.
svn:r1473
2009-10-27 18:25:19 +00:00
Nick Mathewson
904b5721cb Avoid calling exit() during event_base_new*()
Previously, each of the three make-an-event-base functions would exit
under different, weird circumstances, but return NULL on others.
  - All three would exit on OOM sometimes.
  - event_base_new() and event_init() would die	if all backends	were
    disabled.
  - None of them would die if the socketpair() call failed.

Now, only event_init() exits on failure, and it exits on every kind of
failure.  event_base_new() and event_base_new_with_config() never do.

svn:r1472
2009-10-27 06:47:25 +00:00
Nick Mathewson
e9ee1057e6 Give event_assign a return value, and make it less inclined to exit().
We also refactor event_assign so that it is the core function, and
event_set() is only the wrapper.

svn:r1469
2009-10-27 04:25:45 +00:00
Nick Mathewson
ed0e91e02a New test flag to suppress logging for one test.
svn:r1466
2009-10-27 04:03:50 +00:00
Nick Mathewson
a8267663de API to replace all calls to exit() with a user-supplied fatal-error handler.
Also, add unit tests for logging.

svn:r1462
2009-10-26 19:59:51 +00:00
Nick Mathewson
38aec9ec7c Tweaks to IOCP interface.
svn:r1461
2009-10-23 22:38:35 +00:00
Nick Mathewson
7b10724901 Fix my fix for the bufferevent_connect_fail() test.
svn:r1460
2009-10-23 22:07:05 +00:00
Nick Mathewson
879420a711 Expose a narrow window to the IOCP code.
svn:r1459
2009-10-23 22:00:29 +00:00
Nick Mathewson
fdd11c00bb Make the bufferevent_connect_fail test faster on OSX.
It seems that connecting to a listener that is bound but not accepting
or listening doesn't give a 'connection refused' error on OSX, but
rather makes the connect() time out after 75 seconds.  I couldn't find
any way to make the timout shorter.  Fortunately, closing the listener
after a second or so makes the desired error occur after another
second or so.

svn:r1457
2009-10-21 19:21:05 +00:00
Nick Mathewson
4fbac2a5ae Test failing case of bufferevent_connect().
Code by Chris Davis.

svn:r1455
2009-10-21 07:00:19 +00:00
Nick Mathewson
5082546682 Fix windows compilation warnings.
svn:r1449
2009-10-21 02:14:16 +00:00
Nick Mathewson
ba8a17714e Do not notify the main thread more than needed.
Basically, we suppress the notification when an event is added or deleted
and:
  - The event has no fd, or there is no change in whether we are
    reading/writing on the event's fd.
  - The event has no timeout, or adding the event did not make the earliest
    timeout become earlier.

This should be a big efficiency win in applications with multiple threads and
lots of timeouts.

svn:r1439
2009-10-02 03:03:58 +00:00
Niels Provos
8e8d94a3e0 Do not drop data from evbuffer when out of memory; reported by Jacek Masiulaniec
svn:r1436
2009-09-24 22:18:19 +00:00
Nick Mathewson
d17c720c05 Remove an extraneous puts().
svn:r1415
2009-08-14 20:07:01 +00:00
Nick Mathewson
8a99083f01 Add an evbuffer_search_range() to search a bounded range of a buffer
This can be handy when you have	one search to find the end of a	header
section, and then you want to find a substring within the header
section without looking at the body.

svn:r1410
2009-08-07 17:16:52 +00:00
Nick Mathewson
0c09fe5ada Add a couple more evdns tests. Libevent is now, for me, at 80.02% coverage.
svn:r1409
2009-08-03 20:50:56 +00:00
Nick Mathewson
94e8f9b901 Another DNS unit tests, to handle reissues.
The evdns module is now up to ~72% coverage; Libevent is up to nearly 80%.

svn:r1408
2009-08-03 20:15:45 +00:00
Nick Mathewson
dc1f5b1ee0 why say fprintf(stdout, X) when you can say printf?
svn:r1407
2009-08-03 20:15:39 +00:00
Nick Mathewson
213dc2a2ef Fix an annoying evdns crash bug, and add more unit tests for evdns.
svn:r1406
2009-08-03 20:15:32 +00:00
Nick Mathewson
a5006d80cd Unit tests for DNS search.
svn:r1405
2009-08-03 16:15:57 +00:00
Nick Mathewson
6dc488bd7e Improved coverage for evbuffer_readln()
svn:r1402
2009-07-31 17:34:18 +00:00
Nick Mathewson
7c688dd9a2 New function to expose bufferevent.enabled
svn:r1401
2009-07-31 14:41:45 +00:00
Nick Mathewson
cf54d74a65 More unit tests for Openssl, including initializing with no socket. Up to 75% coverage.
svn:r1399
2009-07-30 20:41:41 +00:00
Nick Mathewson
7a2a51a3a1 Add unit tests for SSL session renegotiation.
This tickles the write-blocked-on-read code, and in this case turned
up a bug in it.

svn:r1397
2009-07-30 20:41:21 +00:00
Nick Mathewson
eecefc50e7 Add a function to extract the SSL object from a bufferevent_openssl.
svn:r1395
2009-07-30 20:41:00 +00:00
Nick Mathewson
8a3007efb9 More evconnlistener unit tests: bump its coverage from 71% to 83%.
svn:r1392
2009-07-30 17:01:38 +00:00
Nick Mathewson
625116295a Add unit test for parsing addresses with bad ports.
svn:r1389
2009-07-30 17:00:46 +00:00
Nick Mathewson
72ea534f8e Export evutil_str[n]casecmp as evutil_ascii_str[n]casecmp.
svn:r1387
2009-07-28 19:41:57 +00:00
Nick Mathewson
a826a75800 Some tweaks to Brodie Thesfield's MSVC patch.
svn:r1386
2009-07-28 19:41:48 +00:00
Nick Mathewson
5b5b880be7 Various MSVC cleanups from Brodie Thiesfield.
svn:r1385
2009-07-28 19:41:39 +00:00
Nick Mathewson
709c21c48c Bufferevent support for openssl.
This code adds a new Bufferevent type that is only compiled when the
openssl library is present.  It supports using an SSL object and an
event alert mechanism, which can either be an fd or an underlying
bufferevent.

There is still more work to do: the unit tests are incomplete, and we
need to support flush and shutdown much better.  Sometimes events are
generated needlessly: this will hose performance.

There's a new encrypting proxy in sample/le-proxy.c.

This code has only been tested on OSX, and nowhere else.

svn:r1382
2009-07-28 04:03:57 +00:00
Nick Mathewson
8cc6883524 Fix the main/methods unit test to pass from "make verify".
The problem was introduced when we changed the semantics of
get_supported_methods() to reflect all the methods that exist.
Previously, it had not returned methods disabled from the environment,
but the test didn't know that.

svn:r1379
2009-07-25 03:35:32 +00:00
Nick Mathewson
49de08ef35 Push coverage of event.c a little higher
svn:r1373
2009-07-21 19:20:44 +00:00
Nick Mathewson
f4775918cd Refactor evtag tests into their own suite.
svn:r1366
2009-07-20 14:55:51 +00:00
Nick Mathewson
e8400a43ca Rename encode_int(64) to avoid polluting the global namespace.
They're now called evtag_encode_int(64).  The old names are available
as macros in event2/tag_compat.h.

Also, add unit tests for encode/decode_int64.

svn:r1365
2009-07-20 14:55:35 +00:00
Nick Mathewson
dc031990e0 Add strcasecmp tests to improve evutil coverage a bit
svn:r1364
2009-07-20 14:55:07 +00:00
Nick Mathewson
9cf4ee7e17 Fix a simple warning
svn:r1362
2009-07-17 21:47:35 +00:00
Nick Mathewson
c02b305ae5 Trivial tests to exercise deferred and locking bufferevent code.
These are done as variations of test_bufferevent_connect, since that
one exercises event callbacks as well as read/write callbacks.

The coverage for bufferevent.c is now up to about 87%, from about 70%.

svn:r1358
2009-07-17 20:23:12 +00:00
Nick Mathewson
61f2a45de1 Add a tinytest flag to initialize threading.
svn:r1357
2009-07-17 20:23:05 +00:00
Nick Mathewson
4ba6eda48f Make evthread_use_pthreads() actually return 0 on success.
svn:r1356
2009-07-17 20:22:56 +00:00
Nick Mathewson
9c2ecba7f8 Oops. -1 is an integer, not a pointer.
svn:r1352
2009-07-17 18:42:12 +00:00
Nick Mathewson
d6f2e19924 Unit tests for bufferevent_get(fd|_underlying)
svn:r1351
2009-07-17 18:38:46 +00:00