1932 Commits

Author SHA1 Message Date
Nick Mathewson
5b7a370636 Fix warnings on mingw with gcc 4.5 2010-10-05 14:29:48 -04:00
Nick Mathewson
145f221e8f Define symbolic constants to use in place of SHUT_RD etc 2010-10-05 13:06:32 -04:00
Christopher Davis
e0fd87085d Send a shutdown(SHUT_WR) before closing an http connection
This avoids getting an ECONNRESET from the TCP stack.

Fixes bug 2928690
2010-10-05 13:01:54 -04:00
Nick Mathewson
0faaee0165 Fix a spurious-call bug on epoll.c
We were trying to check whether any events had really been
notified on an fd before calling evmap_io_active on it, but instead
we were checking for an event pointer, which was always true.

In practice, this patch shouldn't change much, since epoll_wait
shouldn't return an event unless there is actually an event going
on.

Spotted by an anonymous bug reporter on Sourceforge.  Closes bug
3078425.
2010-09-30 23:15:47 -04:00
Nick Mathewson
a8b7674cd5 Merge remote branch 'github/signed_compare' 2010-09-28 01:09:17 -04:00
Nick Mathewson
a78ac0facb Merge remote branch 'github/win_lib' 2010-09-27 16:05:20 -04:00
Nick Mathewson
d49b5e3326 Do not search outside of the system directory for windows DLLs
Hardens against some attacks.
2010-09-27 15:45:34 -04:00
Sebastian Hahn
b395392746 Fix compile in kqueue.c
Commit 38d09606 removed the evsigbase pointer, but forgot to remove
an assignment to it in kqueue.c.
2010-09-27 21:14:28 +02:00
Nick Mathewson
9c8db0f804 Fix all warnings in the main codebase flagged by -Wsigned-compare
Remember, the code
   int is_less_than(int a, unsigned b) {
      return a < b;
   }
is buggy, since the C integer promotion rules basically turn it into
   int is_less_than(int a, unsigned b) {
      return ((unsigned)a) < b;
   }
and we really want something closer to
   int is_less_than(int a, unsigned b) {
      return a < 0 || ((unsigned)a) < b;
   }
.

Suggested by an example from Ralph Castain
2010-09-23 22:45:55 -04:00
Nick Mathewson
045eef4cde Unit tests for listener error callbacks 2010-09-23 14:23:45 -04:00
Simon Perreault
c4be8d82b3 Add error callback to evconnlistener 2010-09-22 15:54:18 -04:00
Nick Mathewson
e1198997bc Make event.c debugging messages report fds 2010-09-21 22:44:39 -04:00
Nick Mathewson
ec2b05eddd Make debugging output for epoll backend more comprehensive 2010-09-21 22:23:32 -04:00
Nick Mathewson
90651b327a Put internal events at highest priority
(If we allow user events to starve internal events, then internal events
never actually happen, signals don't get acked, etc)
2010-09-17 00:24:50 -04:00
Nick Mathewson
38d09606ac Remove event_base.evsigbase; nothing used it. 2010-09-15 12:50:31 -04:00
Nick Mathewson
4858b7949c Remove the now-useless evsig_caught and evsig_process 2010-09-15 01:54:51 -04:00
Nick Mathewson
95a7d418ab Make default signal backend fully threadsafe
Jason Toffaletti discovered with helgrind that our signal handler was
messing with evsig_base, which can be set from lots of places in the
code.  Ordinarly, we'd just stick a lock on it, except that it is
illegal (and genuinely error-prone) to call pthread_mutex_acquire()
from inside a signal handler.

The solution is to only store the fd we write to in a static variable,
write the signal number to the fd, and put evsig_cb in charge of
activating signal events.

I have no idea how we'll cope if we want to enable this to handle
siginfo (where available) in the future.
2010-09-15 01:40:02 -04:00
Nick Mathewson
720bd933c8 Warn when using the error-prone EV_SIGNAL interface in an error-prone way. Also, fix a couple of race conditions in signal.c
When using the signal.c signal backend, Libevent currently only allows
one event_base to actually receive signals at a time.  (This has been
the behavior since at least 1.4 and probably much earlier.)  Now, we
detect and warn if you're likely to be racing about which signal goes
to which thread.

We also add a lock to control modifications of the evsig_base field,
to avoid race conditions like those found by Jason Toffaletti.

Also, more comments.  Comments are good.
2010-09-15 01:12:01 -04:00
Simon Perreault
040a019f52 Obey enabled status when unsuspending 2010-09-10 09:20:57 -04:00
Nick Mathewson
f0bd83ea88 Bump to the latest version of tinytest
This lets us do without libevent-specific code in tinytest.c, and
lets us add a feature to skip individual tests from the command
line.
2010-09-09 16:13:09 -04:00
Nick Mathewson
a5ce9ad4af Make SSL tests cover enabling/disabling EV_READ.
I want my 80% coverage.
2010-09-09 16:01:42 -04:00
Nick Mathewson
5811d74c6b Bump version to 2.0.7-rc-dev 2010-09-09 15:59:18 -04:00
Nick Mathewson
fe008ed656 Make all versioning changes for 2.0.7-rc, and add ChangeLog release-2.0.7-rc 2010-09-09 14:59:27 -04:00
Christopher Davis
d98511c027 Make event_base_virtual_del() notify the base if needed 2010-09-09 14:37:44 -04:00
Nick Mathewson
2756a10cd9 Add a missing time.h include to test/regress_thread.c 2010-09-09 13:43:31 -04:00
Nick Mathewson
fb36f9a7e5 Fix an uninitialized-variable warning on windows 2010-09-09 13:00:54 -04:00
Christopher Davis
71b6801421 Don't decrement virutal event count twice in connect_complete. 2010-09-08 20:33:21 -07:00
Christopher Davis
3ec65d6984 Fix a few Windows compile warnings. 2010-09-08 19:55:13 -07:00
Nick Mathewson
25b6a74be6 Merge branch 'tests' 2010-09-08 14:53:57 -04:00
Nick Mathewson
6f82171013 Merge remote branch 'github/win_notify' 2010-09-08 14:52:37 -04:00
Nick Mathewson
de412948a1 Add a missing header for regress_thread.c 2010-09-08 14:52:24 -04:00
Nick Mathewson
e7dc501ee5 Implement EVBASE_NEED_NOTIFY on win32 2010-09-08 14:46:47 -04:00
Sebastian Hahn
911e0db8f0 Fix a compile warning in regress_thread.c 2010-09-08 20:29:39 +02:00
Nick Mathewson
3658b1696d Merge remote branch 'chrisd/iocp-fixes4'
Conflicts:
	test/regress_thread.c
2010-09-08 14:12:12 -04:00
Nick Mathewson
9580e282d7 Merge branch 'th_notify_fd_reinit' 2010-09-08 14:00:45 -04:00
Nick Mathewson
ce85280beb Improve testing of when thread-notification occurs 2010-09-08 13:29:06 -04:00
Nick Mathewson
4632b78e01 Minimize calls to base_notify implementation functions, thereby avoiding needless syscalls
The trick here is that if we already told the base to wake up, and it
hasn't woken up yet, we don't need to tell it to wake up again.  This
should help lots with inherently multithreaded code like IOCP.
2010-09-08 13:22:55 -04:00
Nick Mathewson
c7a06bfaee Avoid needlessly calling evthread_notify_base() when the loop is not running
Also make sure that we always hold the base lock when calling evthread_notify_base.
2010-09-08 13:09:40 -04:00
Nick Mathewson
57d3413c55 Merge remote branch 'github/globals' 2010-09-08 11:39:24 -04:00
Christopher Davis
17a14f1af2 Only process up to MAX_DEFERRED deferred_cbs at a time.
If threads queue callbacks while event_process_deferred_callbacks is
running, the loop may spin long enough to significantly skew timers.
A unit test stressing this behavior is also in this commit.
2010-09-08 01:22:22 -07:00
Christopher Davis
2447fe8886 Add event_config_set_num_cpus_hint for tuning thread pools, etc. 2010-09-08 01:22:22 -07:00
Christopher Davis
499452f4c2 IOCP-related unit test tweaks 2010-09-08 01:22:22 -07:00
Christopher Davis
76f7e7ae74 Some IOCP bufferevent tweaks.
- Increment reference count of bufferevents before initiating overlapped
  operations to prevent the destructor from being called while operations
  are pending. The only portable way of canceling overlapped ops is to
  close the socket.

- Translate error codes to WSA* codes.

- Better handling of errors.

- Add an interface to add and del "virtual" events. Because IOCP
  bufferevents don't register any events with the base, the event loop
  has no way of knowing they exist. This causes the loop to terminate
  prematurely. event_base_{add,del}_virtual increment/decrement base's
  event count so the loop runs while there are any enabled IOCP
  bufferevents.
2010-09-08 01:22:22 -07:00
Christopher Davis
d844242f9b Stop IOCP when freeing the event_base. 2010-09-08 01:22:21 -07:00
Christopher Davis
03afa209de IOCP-related evbuffer fixes.
- Prevent evbuffer_{add,prepend}_buffer from moving read-pinned chains.
- Fix evbuffer_drain to handle read-pinned chains better.
- Raise the limit on WSABUFs from two to MAX_WSABUFS for overlapped reads.
2010-09-08 01:22:21 -07:00
Nick Mathewson
1115366e95 Fix a few memory leaks in the tests 2010-09-07 10:36:19 -04:00
Nick Mathewson
42090072c1 Move the "function to getsockname() on a listener" to regress_testutils
This reverts commit fab50488fcb741884ccdfa7b83643eac3e5c9cbf.

The function was, on reflection, not important enough to break the feature
freeze, since it's trivial to build on your own.
2010-09-06 15:52:48 -04:00
Nick Mathewson
c51826ff50 Merge remote branch 'github/sysqueue_include_order' 2010-09-06 15:40:13 -04:00
Shuo Chen
b0f284cb18 Fix event_del(0) instance in bench.c 2010-09-06 10:10:17 -04:00
Nick Mathewson
749128b2cf Merge remote branch 'github/win32_posix_underscore' 2010-09-04 22:02:32 -04:00