This is code by Chris Davis, with changes to get the unit tests failing less aggressively.
The unit tests for this code do not completely pass yet; Chris is looking into that. If they aren't passing by the next release, I'll turn off this code.
svn:r1499
This function, bufferevent_socket_connect_hostname() can either use
evdns to do the resolve, or use a new function (evutil_resolve) that
uses getaddrinfo or gethostbyname, like http.c does now.
This function is meant to eventually replace the hostname resolution mess in
http.c.
svn:r1496
I've gone through everything that it declared to see where it was used,
and it seems that we probably don't need it anywhere.
Here's what it declared, and why I think we're okay dropping it.
o struct timeval {}
(Used all over, and we can't really get away with declaring it ourselves;
we need the same definition the system uses. If we can't find struct
timeval, we're pretty much sunk.)
o struct timespec {}
(Used in event.c, evdns.c, kqueue.c, evport.c. Of these,
kqueue.c and event.c include sys/_time.h. event.c conditions its use on
_EVENT_HAVE_CLOCK_GETTIME, and kqueue() only works if timespec is defined.)
o TIMEVAL_TO_TIMESPEC
(Used in kqueue.c, but every place with kqueue has sys/time.h)
o struct timezone {}
(event2/util.h has a forward declaration; only evutil.c references it and
doesn't look at its contents.)
o timerclear, timerisset, timercmp, timeradd, timersub
(Everything now uses the evutil_timer* variants.)
o ITIMER_REAL, ITIMER_VIRTUAL, ITIMER_PROF, struct itemerval
(These are only used in test/regress.c, which does not include _time.h)
o CLOCK_REALTIME
(Only used in evdns.c, which does not include _time.h)
o TIMESPEC_TO_TIMEVAL
o DST_*
o timespecclear, timespecisset, timespeccmp, timespecadd, timespecsub
o struct clockinfo {}
o CLOCK_VIRTUAL, CLOCK_PROF
o TIMER_RELTIME, TIMER_ABSTIME
(unused)
svn:r1494
Chris Davis points out that GetQueuedCompletionStatus
sometimes returns false not to report "No events for
you!" but instead to report "An overlapped operation
failed." Add a way to tell an event_overlapped that
its operation failed.
svn:r1490
My usual strategy of grep '[^_]ssize_t' had apparently failed me,
since this ssize_t was in the first column.
Resolves bug 2890434; spotted by Mihai Draghicioiu.
svn:r1484
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
OpenSSL has a per-thread error stack, and really doesn't like you
leaving errors on the stack. Rather than discard the errors or force
the user to handle them, this patch pulls them off the openssl stack
and puts them on a stack associated with the bufferevent_openssl. If
the user leaves them on the stack then, it won't affect any other
connections.
This bug was found by Roman Puls. Thanks!
svn:r1481
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
The big difference here is that EVUTIL_ASSERT() passes its message on
via event_errx() before aborting, so that the application has a prayer
of noticing and recording it.
svn:r1463
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
This makes our interfaces usable from C++, which doesn't believe
you can say "bufferevent_socket_nase(base, -1,
BEV_OPT_CLOSE_ON_FREE|BEV_OPT_DEFER_CALLBACKS)" but which instead
would demand "static_cast<bufferevent_options>(BEV_OPT_CLOSE_ON_FREE|
BEV_OPT_DEFER_CALLBACKS))" for the last argument.
Diagnosis and patch from Chris Davis.
svn:r1456