209 Commits

Author SHA1 Message Date
Nick Mathewson
bd03d0682c Re-add event_siglcb; some old code _was_ still using it. :(
Such code really needs to migrate to use signal events instead.

This reverts commit 072ae5887e8064da500adbd2d24050bb96fbe75d.
2010-01-14 18:44:35 -05:00
Pavel Plesov
4fd2dd9d83 Do not send an HTTP error when we've already closed or responded.
Previously, we'd issue an HTTP/1.1 400 Bad Request" response on every
connection close, event if sever sent response already.

This patch changes the behavior, so we only issue the response on
close when the connection state is not DISCONNECTED, and so we set
the state to DISCONNECTED when the connection closes.

Includes a regression test; fixes sourceforge bug 2909909.
2010-01-11 18:54:23 -05:00
Nick Mathewson
8771d5b646 Merge branch 'readln-backport' into patches-1.4 2010-01-07 02:25:48 -05:00
Nick Mathewson
35df59e9e1 Correct a debug message in evhttp_parse_request_line
The old message reported that evhttp_decode_uri had failed; in fact,
strdup had failed.

Found by Michael Lenaghan.
2010-01-04 01:01:54 -05:00
Jardel Weyrich
5f2e250753 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:17:46 -05:00
Jardel Weyrich
81c26ba43b Make evutil_make_socket_nonblocking() leave any other flags alone.
Fixes bug 2922121
2009-12-28 16:07:41 -05:00
Nick Mathewson
ac0d213c4a Correct all versions in 1.4 branch 2009-12-18 23:50:42 -05:00
Evan Jones
891765cd8e Update sample/signal-test.c to use newer APIs and not leak. 2009-12-08 17:02:24 -05:00
Nick Mathewson
01f3775b37 Fix memory-leak of signal handler array with kqueue. [backport]
It turns out that kqueue_dealloc wasn't calling evsig_dealloc()
(because it doesn't use the main signal handler logic) so the sh_old
array was leaking.

This patch also introduces a fix in evsig_dealloc() where we set
the sh_old array to NULL when we free it, so that main/fork can pass.
2009-12-08 16:55:46 -05:00
Yasuoka Masahiko
5b10d008e9 Fix a crash when reading badly formatted resolve.conf
Based on patch from Yasuoka Masahiko, backported to 1.4.
2009-12-04 14:08:14 -05:00
William Ahern
5713d5dd33 Valgrind fix: Clear struct kevent before checking for OSX bug.
William's original commit message:

   Valgrind complains on startup because kq_init passes to kevent only
   a partially initialized structure. The code doesn't expect kevent
   to look at .fflags, .udata, or .data, I suppose, because it merely
   tickles the kernel looking for an error response. But perhaps
   that's unwarranted chuminess (notwithstanding that it's checking
   for an OS X bug), and needless noise nonetheless.
2009-11-29 10:23:39 -05:00
Nick Mathewson
c545485407 Make the evbuffer_readln backport follow the current API 2009-11-23 13:22:15 -05:00
Nicholas Marriott
b04cc60f13 Backport evbuffer_readln().
This is necessary because it is not actually possible to use
evbuffer_readline() safely: it will treat "A\r\n" as 'A' EOL if it
reads it all at once, and as 'A' EOL EOL if there is a delay between
reading the \r and the \n.

Nicholas Marriott's comments on this patch:

   Gilles is too busy so I've had a go at this, please see the diff
   below.  Rather than try to backport directly from 2.0 where the
   evbuffer code is quite different, I've backported the _readln
   function from when it was initially added in buffer.c r550. I can't
   see any relevant bug fixes after this point so the function is
   pretty much just copied in directly from that revision.
2009-11-23 12:55:50 -05:00
Nick Mathewson
d014edb2c0 Add a .gitignore file for the 1.4 branch. 2009-11-20 12:20:49 -05:00
Niels Provos
06d26fc843 call it 1.4.13-stable
svn:r1544
2009-11-18 04:11:22 +00:00
Nick Mathewson
f76b599d28 Fix 1.4 compilation on msvc, and add a couple of minimal (not-quite-right) nmakefiles.
svn:r1534
release-1.4.13-stable
2009-11-16 19:21:25 +00:00
Nick Mathewson
25da0672f7 Partial backport of event_rpcgen portability fixes.
svn:r1533
2009-11-16 18:46:10 +00:00
Nick Mathewson
3487906f9d Add a missing include to make win32 compile.
svn:r1532
2009-11-16 18:04:13 +00:00
Nick Mathewson
eb1fa9f78e When running set[ug]id, don't check the environment.
Idea from OpenBSD, but made a bit more generic to handle uncivilized lands
that do not define issetugid.

svn:r1529
2009-11-15 18:59:55 +00:00
Nick Mathewson
b4183c732e Stop too many bytes for activequeues.
We were saying calloc(N,N*sizeof(struct event_list*)) when we should have
been saying calloc(N,sizeof(struct event_list*)).  This wasted N*(N-1) words
of memory, where N was the number of priorities.  This wouldn't be a big deal
for any sane number of priorities, but it's a bug nonetheless.

svn:r1526
2009-11-09 19:55:40 +00:00
Nick Mathewson
e32d055b5e Backport GNU/kfreebsd kqueue fix
svn:r1515
2009-11-06 21:23:52 +00:00
Nick Mathewson
6ce14fd01c Rename compat/sys/_time.h to compat/sys/_libevent_time.h
On some systems (notably HPUX), there is already a
/usr/include/sys/_time.h, which our sys/_time.h shadows.  Found and
diagnosed by Kathryn Hogg.

This is a quick fix for 1.4 only; for 2.0, I want to eliminate
compat/sys/_time.h entirely, and have util-internal subsume it.



svn:r1493
2009-11-03 19:15:27 +00:00
Nick Mathewson
756c4cd394 Declare struct timezone in evutil.h so that borken mingw versions do not complain
svn:r1442
2009-10-12 21:09:14 +00:00
Niels Provos
c5a0f56c9a from trunk: Do not drop data from evbuffer when out of memory; reported by Jacek Masiulaniec
svn:r1437
2009-09-24 22:21:09 +00:00
Nick Mathewson
03a9da175a Fix compilation on Android: define fd_mask when it's missing.
svn:r1434
2009-09-23 23:50:43 +00:00
Nick Mathewson
072ae5887e Remove unused event_gotsig code from 1.4 to appease some automated code checkers
svn:r1433
2009-09-23 22:19:00 +00:00
Nick Mathewson
1bf18e5a06 Backport epoll memory fix for bug 2839240
svn:r1430
2009-09-11 18:55:12 +00:00
Nick Mathewson
81765181c6 Backport: do not believe negative result from FIONREAD.
svn:r1429
2009-09-11 18:55:06 +00:00
Niels Provos
8c6282ec39 call it 1.4.12-stable
svn:r1376
2009-07-25 02:21:05 +00:00
Nick Mathewson
9e652610da A more hackish (but more backported) fix for the intptr vs uintptr fix from trunk.
svn:r1374
release-1.4.12-stable
2009-07-23 00:24:28 +00:00
Nick Mathewson
8155ed0cba #ifdef out some callbacks in regress.c that windows doesn't use.
svn:r1371
2009-07-21 19:01:07 +00:00
Nick Mathewson
4c36411174 Fix compilation of 1.4 branch on win32
svn:r1370
2009-07-21 18:57:38 +00:00
Nick Mathewson
267472dcd3 Do a quick-and-dirty hack to fix a gcc warning on 1.4 with a 64-bit arch
svn:r1368
2009-07-21 17:57:31 +00:00
Nick Mathewson
9af9aba62f Add -fno-strict-aliasing to let 1.4 build happily on GCC 4.4
svn:r1367
2009-07-21 17:57:25 +00:00
Nick Mathewson
f5408f1d4d Checking for MS_WINDOWS rather than WIN32 is a Tor-ism. Fix that! {Backport}
svn:r1359
2009-07-17 20:27:54 +00:00
Nick Mathewson
0ae1851767 Backport: Update event_tv when time jumps backwards, so that we only note each jump once. Not strictly needed in 1.4, but good for correctness.
svn:r1354
2009-07-17 19:00:22 +00:00
Nick Mathewson
2bdf307794 [Backport] Do not define _FORTIFY_SOURCE if the platform GCC already defined it for us.
svn:r1345
2009-07-14 19:31:11 +00:00
Nick Mathewson
a763e7416c The truncated bit is in the 3rd byte of a dns reply, not the 4th.
svn:r1331
2009-06-30 14:20:44 +00:00
Nick Mathewson
763391947c Let evdns keep working when our IP changes. Fix by Christopher Davis; backported by nickm.
svn:r1328
2009-06-24 22:39:12 +00:00
Nick Mathewson
b99254ac22 Activate fd events in a pseudorandom order on older backends.
New backends like poll and kqueue and so on add fds to the queue in
the order that they are triggered.  But the select backend currently
activates low-numbered fds first, whereas the poll and win32 backends
currently favor whatever fds have been on for the longest.  This is no
good for fairness.

svn:r1327
2009-06-24 22:39:03 +00:00
Nick Mathewson
b0d88e680b Fix epoll fencepost error. Patch most recently from Adam Langley, though I think I have seen others post this before.
svn:r1323
2009-06-04 05:29:04 +00:00
Nick Mathewson
0ec290be04 When __GNUC__ is not defined, use __VA_ARGS__.
svn:r1312
2009-05-25 18:15:44 +00:00
Nick Mathewson
9d0f6eb4e2 Fix a potentially very annoying evdns bug that we found in Tor.
Generally speaking, it way better to event_assign() an event when you
allocate it than to assign it before every time you event_add it: if
it is already event_add()ed, the assign will mess it up so that it
doesn't _look_ added, and event_add() will insert a second copy.
Later, event_del() will only delete the second copy.  Eventually, the
event_base will have a dangling pointer to freed memory.  Ouch!

svn:r1308
2009-05-22 18:32:09 +00:00
Nick Mathewson
6bd85f9d71 Fix compilation warning on win32 with verbose GCC warnings.
svn:r1305
2009-05-22 16:51:10 +00:00
Nick Mathewson
499d0039ad Try to contain the failure when we are running without socketpair().
Some win32 systems (mostly those using Kaspersky, it would seem)
prevent us from faking socketpair().  This makes our signal
notification code just not work.  Our response since 1.4 has been to
assert.  For users who would rather work without signals than not work
at all, this has been a regression from 1.3e.

This patch makes adding signal events fail in this case; there's no
reason to kill the whole process.

svn:r1304
2009-05-22 15:09:43 +00:00
Niels Provos
0f62db5ee3 call it 1.4.11-stable
svn:r1290
2009-05-15 06:22:54 +00:00
Nick Mathewson
9b45a4e7c0 We were distributing the wrong event-config.h with our source distributions. Fix that.
svn:r1288
release-1.4.11-stable
2009-05-15 01:36:31 +00:00
Nick Mathewson
5d639d6c20 Fix win32 compilation warnings in 1.4.
svn:r1287
2009-05-15 01:14:08 +00:00
Nick Mathewson
5e0563ba9a Fix dangling pointer in epoll after epoll_recalc().
This is based on patch 2790759 from Kevin Springborn.  His comments on
sourceforge:

  Problem:
  The failure case is as follows: Event is added using epoll_add (a
  direct pointer is stored in the user_data section), epoll_recalc is
  called and the fds array is moved (invalidating the user_data
  pointer stored in epoll).  epoll_dispatch is called for the added
  event and accesses evepoll based on the invalid pointer (set before
  the fds array was relocated).

  Solution:
  Dispatch has access to the epollop structure, so given the fd we can
  find the corresponding evepoll struct. Use data.fd instead of
  data.ptr and store the fd corresponding to the event. This way when
  epoll_recalc moves the fds array (and updates the fds array pointer
  in epollop), the evepoll calculation in dispatch still finds the
  valid evepoll struct.

svn:r1282
2009-05-12 18:27:45 +00:00
Nick Mathewson
a276fa5155 Fix warnings in compilation of regress.c.
svn:r1281
2009-05-12 18:27:34 +00:00