2100 Commits

Author SHA1 Message Date
Nick Mathewson
ea0d019b71 Use AM_CONDITIONAL, not AC_SUBST, to tell automake to build regress
For some reason, this makes mingw much happier about building
regress.exe by default.  No, I'm afraid I don't know why.
2011-04-23 02:35:17 -04:00
Nick Mathewson
7739c86da0 Fix msvc build: it needed to know about _EVENT_HAVE_STRUCT_SOCKADDR_STORAGE 2011-04-23 02:31:04 -04:00
Nick Mathewson
53d1e450f4 Try to fix up CHECK_REGRESS hack to not break on win32 2011-04-23 01:48:11 -04:00
Nick Mathewson
dd68cce439 Add missing header for regress_http compilation on win32 2011-04-23 01:47:43 -04:00
Nick Mathewson
99f147d9f6 Merge branch '20_iocp_conn_sockopt' into patches-2.0 2011-04-23 01:47:11 -04:00
Nick Mathewson
52f9baeee2 call setsockopt correctly on connecting() IOCP-bufferevents so shutdown() will work 2011-04-23 01:46:39 -04:00
Sebastian Hahn
646f9feb26 Zero a struct sockaddr_in before using it
Found by Dave Heart
2011-04-23 02:22:08 +02:00
Sebastian Hahn
744c7456c7 Remote some dead code from dns-example.c
Found by Dave Heart
2011-04-23 02:20:59 +02:00
Sebastian Hahn
93a1abb374 Check return value of evbuffer_add_cb in tests
Caught by clang's static analyzer
2011-04-23 02:04:58 +02:00
Sebastian Hahn
4bac793e3e Be nice and "handle" error return values in sample code
Caught by clang's static analyzer
2011-04-23 02:04:58 +02:00
Sebastian Hahn
48c44a6dda Refactor test_getaddrinfo_async_cancel_stress()
Turns out it didn't need an event base set up.

Spotted by clang's static anaylzer
2011-04-23 02:04:58 +02:00
Sebastian Hahn
65707d7c3c add some (void) casts for unused variables
All these places already have an XXX marker, so we know we need to fix
them later. Let's not clutter the static analysis results with them.
2011-04-23 02:04:58 +02:00
Sebastian Hahn
b693c324ca Actually send NULL request in http_bad_request_test
Issue caught by clang's static analyzer
2011-04-23 02:04:58 +02:00
Sebastian Hahn
3819b62cea Add a forgotten return value check in the unit tests
Spotted by clang's static analyzer
2011-04-23 02:04:58 +02:00
Sebastian Hahn
b0ff7eb5ce Add an assert to appease clang's static analyzer
It got confused because in EVLOCK_ASSERT_LOCKED(lock) there is an if
(lock) check.
2011-04-23 02:04:58 +02:00
Sebastian Hahn
5208544edc Fix possible NULL-deref in evdns_cancel_request
The clang static analyzer complained that base might be dereferenced
without being set, but this patch should fix another dereference issue.
2011-04-23 02:04:58 +02:00
Sebastian Hahn
12311ff46e Add a forgotten NULL check to evhttp_parse_headers
Issue detected by the clang static analyzer
2011-04-23 02:04:58 +02:00
Sebastian Hahn
ad9ff5834a Fix compilation under LLVM/clang with --enable-gcc-warnings
When compiling using clang (2.9 or lower) do not enable
-Wnormalized=id or -Woverride-init when --enable-gcc-warnings
or --enable-gcc-warnings-advisory is set as these options
are unsupported.

This commit is based on a patch for Tor
(git commit 56bdc844ba68ac0911efc7ad3398f1eafeaaac76 by Steven
Murdoch), Copyright (c) 2007-2011, The Tor Project, Inc.
2011-04-23 02:03:48 +02:00
Nick Mathewson
cb6ecee7f6 Complain if the caller tries to change threading cbs after setting them
We never supported this; it was always fraught with errors; and I
don't believe there is a good reason to _want_ it to work.
2011-04-22 14:06:57 -04:00
Nick Mathewson
b683cae3cb Avoid race-condition when initializing global locks
Previously, we did stuff like
   if (!lock)
      EVTHREAD_ALLOC_LOCK(lock,0);
for the evsig base global lock, the arc4random lock, and the debug_map
lock.  But that's potentially racy!  Instead, we move the
responisiblity for global lock initialization to the functions where
we set up the lock callbacks.

(Rationale: We already require that you set up the locking callbacks
before you create any event_base, and that you do so exatly once.)
2011-04-22 14:06:33 -04:00
Nick Mathewson
b4f89f00c6 Fix a memory leak on win32 socket->event map.
This would lose some memory every time an event_base was freed on win32.

Found by Dimitre Piskyulev.
2011-04-21 17:33:13 -04:00
Nick Mathewson
364291e9a9 Handle calloc failure in evdns. (Found by Dave Hart) 2011-04-21 17:11:41 -04:00
Nick Mathewson
dde3b73963 Merge branch '20_evdns_circular_list_patch' into patches-2.0 2011-04-21 13:30:22 -04:00
Nick Mathewson
00e91b3c8d Fix a crash bug in evdns server circular list code
Really, this should use a circleq.  That's a change for 2.1, though.
2011-04-20 13:27:31 -04:00
Nick Mathewson
2e9f665548 Fix a couple of memory leaks in samples/http-server.c. Found by Dave Hart. 2011-04-14 14:17:58 -04:00
Nick Mathewson
3417f6808d Avoid a free(NULL) if out-of-memory in evdns_getaddrinfo. Found by Dave Hart 2011-04-13 11:20:30 -04:00
Nick Mathewson
1a21d7b840 Fix the check for multicast or broadcast addresses in evutil_check_interfaces
First of all, it is totally okay to have an address end with .255,
depending on what your netmask is, so we shouldn't reject a local
address if it ends with .255.

Second, our check for ending with .255 was broken.  So was our check
for class-d addresses.

Found by Dave Hart.
2011-04-05 17:21:14 -04:00
Nick Mathewson
fc7f34bd4d Merge branch '20_socktype_protocol_nomem' into patches-2.0 2011-04-05 17:17:51 -04:00
Nick Mathewson
637d17a1b9 Check for allocation failures in apply_socktype_protocol_hack 2011-04-05 16:32:39 -04:00
Tomash Brechko
0d6622e26a Fix the case when failed evhttp_make_request() leaved request in the queue. 2011-04-04 14:45:53 -04:00
Tomash Brechko
218cf19743 Fix subtle recursion in evhttp_connection_cb_cleanup(). 2011-04-04 14:44:34 -04:00
Tomash Brechko
272823f8b0 Reset outgoing connection when read data in idle state.
Imagine server side is buggy and miscalculates Content-Length: in the
reply.  Data arriving in idle state shouldn't make us crash, instead we
can just reset the connection.
2011-04-04 14:41:45 -04:00
Nick Mathewson
c621359122 Add comment to configure.in to explain gc-sections test logic
(Basically, we need access to conftest.err for the test to work properly.)
2011-03-23 16:32:42 -04:00
Dave Hart
6bb23e4bb1 Fix for --gc-sections on NetBSD
This patch fixes http://bugs.ntp.org/1844, works around
http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=40401, by
improving the test for support of --gc-sections to run a program which
reads a file using stdio built with --gc-sections, instead of simply
link the binary.  This catches the buggy linker as the garbage
collection removes a tag NetBSD uses to distinguish its own elf
binaries from Linux ones, causing it to treat conftest as a Linux
binary and run it with the wrong syscall table.
2011-03-23 16:23:59 -04:00
Dave Hart
b5a1f9f74b Fix make distcheck & installation of libevent 1 headers
libevent/Makefile.am corrects a typo (thanks to Harlan for spotting it
once we realized make distcheck was broken when building the libevent
tearoff).  The result was the include/ev*.h were not distributed nor
installed whether or not --disable-libevent-install was used.  This
was introduced with the final round (3/3) of
--disable-libevent-install patch from me.
2011-03-23 16:22:24 -04:00
Christophe Fillot
4b8f02f147 Fix incorrect assertions and possible use-after-free in evrpc_free()
Original description:

  The following patch fixes incorrect assertions in evrpc_free():
  evrpc_unregister_rpc() and evrpc_remove_hook() return 0 for success.

  Also, in evrpc_unregister_rpc(), it is better to free RPC structure
  at the end: evrpc_free() uses rpc->uri as "name" parameter when
  calling evrpc_unregister_rpc(), then rpc->uri is freed, but we have
  "registered_uri = evrpc_construct_uri(name)". So at this time "name"
  is invalid.
2011-03-12 12:08:19 -05:00
Nick Mathewson
5209fadfd0 Disable lazy gettimeofday/clock_gettime comparison for now 2011-03-07 22:59:19 -05:00
Nick Mathewson
9193dc4ecd Merge branch '20_timescale' into patches-2.0 2011-03-07 22:45:10 -05:00
Nick Mathewson
c8baac9023 Followup for Tomash Brechko's http patch
This patch makes bufferevent_disable_hard() non-public, and
adds a comment about what it's for and why it's used.
2011-03-07 21:58:16 -05:00
Tomash Brechko
5dc566284d Workaround libevent bug
https://sourceforge.net/tracker/index.php?func=detail&aid=3078187&group_id=50884&atid=461324

The problem is that bufferevent_disable() doesn't disable EV_WRITE
when 'connecting' flag is set.  However from evhttp_connection_reset()
we want to disable EV_WRITE for sure (we are closing the socket next).
So we add bufferevent_disable_hard(), which acts like
bufferevent_disable(), but resets 'connecting' flag before the call to
the actual handler.

TODO: bufferevent_disable_hard() shouldn't be public, remove it from
event2/bufferevent.h.
2011-03-07 21:41:45 -05:00
Nick Mathewson
a459ef70ec Have event_base_gettimeofday_cached() always return wall-clock time
Based on code by Dave Hart
2011-03-03 15:48:26 -05:00
Dave Hart
ab008c7d05 Make --no-libevent-install apply to event1 headers too 2011-03-03 12:57:17 -05:00
Dave Hart
b5ab955531 Make --no-libevent-install apply to headers too 2011-02-25 10:35:12 -05:00
Sebastian Hahn
3f79a3a01a Continue AM_CFLAGS to AM_CPPFLAGS correction
9c469db300e1b270a93c6b04c1709ac0f7751136 had started with the conversion
but left out another instance of incorrectly used AM_CFLAGS.

Dave Hart provided the suggestion for this fix.
2011-02-23 12:17:08 +01:00
Nick Mathewson
5dc200b7c8 Merge branch '20_uri_nonconformant' into patches-2.0 2011-02-22 18:53:55 -05:00
Nick Mathewson
2fba21d867 Make -ffunction-sections off-by-default in 2.0.x
I don't see how this can burn anybody, but I don't want to take
chances: new build options are something that should be done in an
alpha.  To turn -ffunction-sections on, pass
--enable-function-sections to configure.
2011-02-22 16:20:42 -05:00
Nick Mathewson
7d913f4c8e Remove nonfunctional enable_libevent_(install|regress)_def variables 2011-02-22 16:14:16 -05:00
Nick Mathewson
15b2408c9b Use $(), not @@, for LIBEVENT_GC_SECTIONS 2011-02-22 16:13:49 -05:00
Nick Mathewson
f95bafb608 Be explicit about how long event loops run in event.h documentation 2011-02-22 00:34:49 -05:00
Nick Mathewson
039b9bd0e3 Use %s with printf in test.sh 2011-02-22 00:31:56 -05:00