903 Commits

Author SHA1 Message Date
Nick Mathewson
4868f4d217 Initial support for a lightweight 'deferred callbacks'.
A 'deferred callback' is just a function that we've queued in the
event base.  This ability is needed for some mt stuff, and for complex
callback chains.  For internal use only.

svn:r1150
2009-04-10 14:22:33 +00:00
Nick Mathewson
e3d82497c9 Don't allow internal events to starve lower-priority events.
This is exceptionally important with multithreaded stuff, where we use
an event to notify the base that other events have been made active.
If the activated events have a prioirty number greater than that of the
notification event, it will starve them, and that's no good.

svn:r1149
2009-04-10 14:21:53 +00:00
Niels Provos
ce146eb1cb Fix parsing of queries where the encoded queries contained \r, \n or +
svn:r1148
2009-04-10 05:43:45 +00:00
Niels Provos
6dece3e980 revert last commit; git user error
svn:r1147
2009-04-10 05:22:15 +00:00
Niels Provos
f43f1d14c5 initial version of query decoding patch
svn:r1146
2009-04-10 05:18:18 +00:00
Nick Mathewson
f98385a407 add a missing "static" to timeout_process.
svn:r1145
2009-04-08 16:57:38 +00:00
Nick Mathewson
72b6ffe869 Prevent unsupported modifications to bufferevent_sock buffers.
In particular, we don't allow adding any data to end front of inbuf
(we do that when we read), or removing it from the front of outbuf (we
drain data only when we write).

svn:r1144
2009-04-08 03:05:42 +00:00
Nick Mathewson
747331d164 Add freeze support to evbuffers.
From the documentation:
   Prevent calls that modify an evbuffer from succeeding. A buffer may
   frozen at the front, at the back, or at both the front and the back.

   If the front of a buffer is frozen, operations that drain data from
   the front of the buffer, or that prepend data to the buffer, will
   fail until it is unfrozen.   If the back a buffer is frozen, operations
   that append data from the buffer will fail until it is unfrozen.

We'll use this to ensure correctness on an evbuffer when we're waiting
for an overlapped IO call to finish.

svn:r1143
2009-04-08 03:04:39 +00:00
Nick Mathewson
d9086fc007 Add a new facility to "pin" the memory in an evbuffer chain.
For overlapped IO (and possibly other stuff) we need to be able to
label an evbuffer_chain as "pinned", meaning that every byte in it
must remain at the same address as it is now until it unpinned. This
differs from being "immutable": it is okay to add data to the end
of a pinned chain, so long as existing data is not moved.

svn:r1142
2009-04-08 03:03:59 +00:00
Nick Mathewson
68d0139f19 Refactor the zlib and pthreads tests to appear in the regular tinytest tree structure.
svn:r1141
2009-04-07 04:49:25 +00:00
Nick Mathewson
684c022a21 Avoid a double event_del() in evdns.c.
The bug could occur when a nameserver was marked as up, but then an
outstanding probe sent to the nameserver failed.  Now, evdns_up() cancels
any outstanding probe.

svn:r1140
2009-04-06 20:38:42 +00:00
Nick Mathewson
d2e9caa6fc Fix evdns_cancel to alert callback and free associated RAM.
Also, we add a test to make sure evdns_cancel is working properly.

svn:r1139
2009-04-06 20:38:19 +00:00
Nick Mathewson
0f3c0983c0 Fix a double-delete on the request timeout event. Port from Tor.
svn:r1138
2009-04-05 17:50:18 +00:00
Nick Mathewson
28255a2635 Finally, get unit tests to pass with threading turned off again.
svn:r1137
2009-04-05 04:26:46 +00:00
Nick Mathewson
6a18f4b005 Munge the read_suspended flag before re-enabling reads on the underlying bufferevent. This makes it so the enabled thing has some idea whether reads are supposed to be suspended or not.
svn:r1136
2009-04-05 04:15:01 +00:00
Nick Mathewson
661b5eea09 Actually, move EVUTIL_NIL_STMT to util-internal.h
svn:r1135
2009-04-05 04:10:05 +00:00
Nick Mathewson
60e0d59b33 Add locking to evbuffers.
svn:r1134
2009-04-05 02:44:17 +00:00
Nick Mathewson
d13b59ce37 Fix build with thread support disabled, and make no-op macros a little more no-oppy.
svn:r1133
2009-04-05 02:44:04 +00:00
Nick Mathewson
70ee390fc9 Add some more utility macros to evthread-internal.h
svn:r1132
2009-04-05 02:43:55 +00:00
Nick Mathewson
f1b1bad415 Make the new evbuffer callbacks use a new struct-based interface.
The old interface would fail pretty hard when we had to batch up
multiple adds and drains in a single call.

svn:r1131
2009-04-03 14:27:03 +00:00
Nick Mathewson
f90500a5df Add a new improved search function.
The old evbuffer_find didn't allow iterative searching, and forced us
to repack the buffer completely every time we searched in it.  The
new evbuffer_search addresses both of these.  As a side-effect, the
evbuffer_find implementation is now a little more efficient.

svn:r1130
2009-04-03 01:21:36 +00:00
Nick Mathewson
0afb1f7ffb Glibc mkstemp requires exactly 6 Xs.
svn:r1129
2009-04-01 16:08:34 +00:00
Niels Provos
994e85781c correct evbuffer_drain documentation from John Khvatov
svn:r1127
2009-03-30 17:36:22 +00:00
Niels Provos
23655dfb87 include Doxyfile in tar ball; from Jeff Garzik
svn:r1125
2009-03-12 17:43:43 +00:00
Nick Mathewson
73094d5952 Make tmpfile code compile without warnings
svn:r1123
2009-02-13 13:43:35 +00:00
Niels Provos
79b7799bd1 a simple test for evbuffer_add_file
svn:r1122
2009-02-13 01:42:59 +00:00
Nick Mathewson
ec35eb5520 Make threading functions global, like the mm_ functions. Use the libevent_pthread.la library in regress_pthread.
svn:r1121
2009-02-12 22:19:54 +00:00
Nick Mathewson
d0a9c90e93 Fix some of the crazier indentation and tabbing choices in evdns.c
svn:r1120
2009-02-11 17:29:17 +00:00
Nick Mathewson
77c80b8dcf New bind-to option to allow DNS clients to bind to arbitrary ports for their outgoing addresses.
svn:r1119
2009-02-11 17:24:11 +00:00
Nick Mathewson
acaf65c359 Make evutil_parse_sockaddr_port give a useful socket-length output.
svn:r1118
2009-02-11 17:23:32 +00:00
Nick Mathewson
f2a24d6e58 Better comments for some confusing-to-me code.
svn:r1117
2009-02-11 17:22:40 +00:00
Nick Mathewson
c6f4dc987c Port some evdns changes over from Tor.
svn:r1116
2009-02-11 17:21:48 +00:00
Nick Mathewson
ac36f4047e oops; coding too quickly on nil-filter patch. Caught by niels.
svn:r1115
2009-02-11 05:17:27 +00:00
Nick Mathewson
cd731b77d7 Do not use ctypes functions in cases when we need the "net" locale.
This patch adds a new set of EVUTIL_IS* functions to replace use of
the ctypes is* functions in all cases where we care about characters'
interpretations in net ascii rather than in the locale.  For example,
when we're working with DNS hostnames, we don't want to do the 0x20
hack on non-ascii characters, even if the host thinks they should be
isalpha.

svn:r1114
2009-02-10 21:40:12 +00:00
Nick Mathewson
1ed27048e4 Stop rolling our own offsetof twice.
svn:r1113
2009-02-10 21:39:56 +00:00
Nick Mathewson
f04b90e5b3 Make a couple of newer evdns functions more bulletproof.
svn:r1112
2009-02-10 19:43:19 +00:00
Nick Mathewson
da49d6a3b0 Stop using platform inet_aton/inet_addr; they can behave strangely on certain misformed addresses.
svn:r1111
2009-02-10 19:43:11 +00:00
Nick Mathewson
01456265c3 Explode less badly in the case where we're told to prepend/append/remove a buffer to itself. Note some API/implementation deficiencies.
svn:r1110
2009-02-10 19:39:22 +00:00
Nick Mathewson
20f809ce8c Make default (nil) filter use evbuffer_remove_buffer to respect the high-water mark of the target buffer.
svn:r1109
2009-02-10 19:39:12 +00:00
Nick Mathewson
e7fd1034cf Test some formerly untested prepend cases of evbuffer. Now evbuffer coverage is over 80 percent.
svn:r1108
2009-02-10 19:39:03 +00:00
Nick Mathewson
9e3e7b360d More unit tests for evbuffer_add_reference to make sure that certain interleaved data patterns work; that free invokes callback; that callbacks are not invoked too early or later; etc.
svn:r1107
2009-02-10 19:38:54 +00:00
Nick Mathewson
98b7046b97 A few more comments on evbuffer-internal structures.
svn:r1106
2009-02-10 19:38:43 +00:00
Nick Mathewson
edfdb698e3 Add an assertion to evbuffer_chain_align so we can't reuse it in the future.
svn:r1105
2009-02-10 19:38:34 +00:00
Nick Mathewson
71604d85be Remove some needless includes
svn:r1104
2009-02-10 19:38:25 +00:00
Nick Mathewson
deb2a1210b use new evutil_make_listen_socket_reuseable() in http.c
svn:r1103
2009-02-10 19:38:14 +00:00
Nick Mathewson
c7b2f8fdc9 New function to abstract SO_REUSEADDR.
svn:r1102
2009-02-10 19:38:05 +00:00
Nick Mathewson
f9e4e0f98e Move bufferevent tests to regress_bufferevent.c file.
svn:r1101
2009-02-03 18:28:53 +00:00
Nick Mathewson
cc049bfc30 Enable (and debug) WSARecv for evbuffer iovec-like reads.
The two things we were missing: the flags parameter is not optional, and an error can actually indicate a close.

svn:r1100
2009-02-03 05:22:57 +00:00
Nick Mathewson
ea11f8195f Compile http_connection_retry_test, but mark it skipped on win32.
svn:r1099
2009-02-02 22:17:32 +00:00
Nick Mathewson
722885fba9 Some mingws have AF_UNIX, which may have prevented our socketpair from working at all on them. Fix that.
svn:r1098
2009-02-02 21:59:53 +00:00