334 Commits

Author SHA1 Message Date
Nick Mathewson
6b4b77a265 Make event_del(E) block while E is running in another thread.
This gives you the property that once you have called event_del(E),
you know that E is no longer running or pending or active at all, and
so it is safe to delete the resource used by E's callback.

svn:r1341
2009-07-14 16:54:48 +00:00
Nick Mathewson
d3a8ccb807 Change use of AC_CHECK_LIB to AC_SEARCH_LIBS.
Patch from Zack Weinberg.  His message:

  This one eliminates all use of AC_CHECK_LIB in the configure script.
  AC_CHECK_LIB has a serious flaw: if the library you mention *exists*
  but is not *necessary* for the function you want, it adds it to
  $(LIBS) anyway.  This was fine in the days of static libraries,
  because the linker would ignore an .a library that didn't contain
  anything you needed. However, ELF shared libraries are different
  (let's not get into why): the linker will by default record a
  DT_NEEDED entry for every shared object mentioned on the link
  command line. Thus, every use of AC_CHECK_LIB is a potential
  unnecessary DT_NEEDED, making extra work for the dynamic loader. The
  cure is simply to use AC_SEARCH_LIBS instead; it first tries to find
  the function you ask for in libc, and only if that doesn't work does
  it try to use the extra library you mention.

  For the same reasons, pkg-config .pc files should distinguish
  between the libraries to use for shared linkage (Libs:) and the
  additional libraries needed for static linkage (Libs.private:). I
  have also made that correction in this patch. I also took the
  opportunity to clean up the substitution variables a little and make
  absolutely sure that the core library does not get linked against
  zlib.

svn:r1338
2009-07-10 19:38:16 +00:00
Nick Mathewson
a501d6833b Add a lock/unlock pair inside the event callbacks in bufferevents.
This fixes part of bug 2800642, I believe, though there is still a
general race condition in multithreaded use of events that we need to
think about.

svn:r1337
2009-07-10 19:34:00 +00:00
Niels Provos
6469598e56 Allow C identifiers as struct names; allow multiple comments in .rpc files; from Zack Weinberg; plus a tiny tweak
svn:r1336
2009-07-03 17:43:26 +00:00
Niels Provos
fbb181d1aa Allow specifying the output filename for rpcgen; based on work by jmansion; patch from Zack Weinberg.
svn:r1335
2009-07-03 17:31:17 +00:00
Niels Provos
bbcc54ef9c fix preamble of rpcgen-generated files to rely on event2 includes; based on work by jmansion; patch from Zack Weinberg.
svn:r1334
2009-07-03 17:25:45 +00:00
Niels Provos
37d3e16ce9 Raise RpcGenError in event_rpcgen.py; from jmanison and Zack Weinberg
svn:r1333
2009-07-03 17:20:56 +00:00
Nick Mathewson
342ad3550b The truncated bit is in the 3rd byte of a dns reply, not the 4th. [fwd-port]
svn:r1332
2009-06-30 14:23:18 +00:00
Nick Mathewson
d1ffba1d7c Replace some read/write instances with send/recv to work properly on win32.
svn:r1324
2009-06-05 19:52:13 +00:00
Nick Mathewson
cdaca02c29 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:r1318
2009-05-27 15:35:00 +00:00
Nick Mathewson
8c66eb2e9b 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:r1303
2009-05-22 14:48:40 +00:00
Nick Mathewson
59cd49363c Do not free the event base lock until we are done removing all the events. Spotted by Joachim Bauch; fixes bug 2795402.
svn:r1302
2009-05-22 14:31:07 +00:00
Nick Mathewson
594842970e Fix a deadlock: there were some LOCKs that should have been UNLOCKs. Resolves bug 2794244
svn:r1298
2009-05-20 12:24:13 +00:00
Nick Mathewson
66df9dafe1 Add changelog for last commit
svn:r1297
2009-05-19 21:49:53 +00:00
Nick Mathewson
dc4c7b9570 Change the interface of evbuffer_add_reference: give the cleanup function more info.
svn:r1294
2009-05-15 22:44:18 +00:00
Nick Mathewson
bba69e03f8 New semantics for evbuffer_cb_set_flags().
Previously, set_flags() would replace all previous user-visible flags.
Now it just sets the flags, and there is a clear_flags() function to
clear other flags.

svn:r1293
2009-05-15 20:23:59 +00:00
Nick Mathewson
b4886ec80d Trim 22 bytes from struct event on 32 bit platforms, more on 64-bit platforms.
svn:r1292
2009-05-15 18:44:44 +00:00
Nick Mathewson
31d89f274b Add a "ctrl" mechanism to bufferevents for property access.
OpenSSL uses something like this to implement get/set access for
properties on its BIOs, so that it doesn't need to add a pair of
get/set functions to the vtable struct for every new abstract property
it provides an accessor for.

Doing this lets us make bufferevent_setfd abstract, and implement an
abstract bufferevent_getfd.

svn:r1284
2009-05-13 20:37:21 +00:00
Nick Mathewson
83f46e51d7 Do not use the "evbuffer_" prefix to denote parts of bufferevents.
This is a bit of an interface doozy, but it's really needed in order
to be able to document this stuff without apologizing it.  This patch
does the following renamings:

   evbuffercb -> bufferevent_data_cb
   everrorcb -> bufferevent_event_cb
   EVBUFFER_(READ,WRITE,...) -> BEV_EVENT_(...)
   EVBUFFER_(INPUT,OUTPUT) -> bufferevent_get_(input,output)

All the old names are available in event2/bufferevent_compat.h

svn:r1283
2009-05-13 20:36:56 +00:00
Nick Mathewson
f11dff2c7a Add and use locale-independent strcasecmp functions.
svn:r1280
2009-05-07 03:45:51 +00:00
Nick Mathewson
659d54d530 Add new code to make and accept connections.
This is stuff that it's easy to get wrong (as I noticed when writing
bench_http), and that takes up a fair amount of space (see http.c).
Also, it's something that we'll eventually want to abstract to use
IOCP, where available.

svn:r1272
2009-05-05 02:59:26 +00:00
Nick Mathewson
0fd70978c8 Add an event_get_base() function to remove one more reason to include event_struct.h
svn:r1271
2009-05-05 01:09:03 +00:00
Nick Mathewson
0e63e72a05 Nothing ever sets event_sigcb or event_gotsig any more: remove them.
svn:r1270
2009-05-03 18:56:08 +00:00
Nick Mathewson
d5ca076379 Move event_set() and friends to event2/event_compat.h.
These functions are deprecated in favor of event_assign().

svn:r1267
2009-05-02 16:23:29 +00:00
Nick Mathewson
a109d95c72 Add changelog entry for vc++ fixes
svn:r1264
2009-05-02 16:11:06 +00:00
Nick Mathewson
2ebfd3bafd Oops. We never actually defined event_config_set_flag().
svn:r1246
2009-04-28 19:08:17 +00:00
Niels Provos
b228ff91b8 remove vararg macros for accessing evrpc structs
svn:r1243
2009-04-25 00:15:31 +00:00
Niels Provos
5c4c13d8c2 make sendfile work on freebsd
svn:r1239
2009-04-24 03:24:22 +00:00
Nick Mathewson
a5897917da Changelog entry for r1237
svn:r1238
2009-04-23 21:43:44 +00:00
Nick Mathewson
faa756c7c1 Oops. event_config.flags was never initialized. Bugfix on 2.0.1-alpha. Found by Victor Goya.
svn:r1236
2009-04-23 21:34:37 +00:00
Nick Mathewson
9516df0e2e Fix c89 bugs reported by Cory Stup.
Others may remain.  I wasn't able to get gcc --std=c89 to build libevent
at all, so I don't know what compiler the original reporter is using here.

Note that this change requires us to disable the part of our rpc code
that uses variadic macros when using a non-gcc compiler.  This is a
problem if we want our rpc api to be portable.

svn:r1231
2009-04-23 05:40:06 +00:00
Nick Mathewson
df0617f289 Use signal.h, not sys/signal.h.
This is patch 2673214 from mmadia.  It is correct, since we unconditionally
include signal.h in many other places, and only sometimes include sys/signal.h.
It is necessary to compile on Haiku, I'm told.

svn:r1228
2009-04-23 00:21:23 +00:00
Nick Mathewson
8b7a3b3676 Fix min_heap_erase when we remove an element from the middle of the heap.
Previously, we could lose the heap property when we removed an item
whose parent was greater than the last element in the heap.  We would
replace the removed item with the last element, and consider shifting
it down, but we wouldn't consider shifting it up.

Patch from Marko Kreen.

svn:r1226
2009-04-23 00:01:24 +00:00
Nick Mathewson
253151c54c Detect and reject n_priorities less than 1.
svn:r1222
2009-04-22 20:28:30 +00:00
Nick Mathewson
01bda2b8fa Add forgotten changelog.
svn:r1221
2009-04-22 20:27:21 +00:00
Nick Mathewson
d3fbe7fa05 Do not free the signal index unless it was at some point allocated
svn:r1217
2009-04-21 18:47:53 +00:00
Nick Mathewson
b7907a7bfb Note dns work in changelog and whatsnew
svn:r1206
2009-04-19 01:59:25 +00:00
Nick Mathewson
a98a512bc1 Add a generic way for any bufferevent to make its callback deferred
svn:r1197
2009-04-17 23:12:34 +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
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
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
c7b2f8fdc9 New function to abstract SO_REUSEADDR.
svn:r1102
2009-02-10 19:38:05 +00:00
Niels Provos
fdf694933c sendfile/mmap and memory reference implementation for evbuffers
svn:r1057
2009-01-27 06:05:38 +00:00
Niels Provos
56ea4687a5 Change the semantics of timeouts in conjunction with EV_PERSIST; timeouts in that case will now repeat until deleted.
svn:r1032
2009-01-22 02:33:38 +00:00
Nick Mathewson
309fc7c4ad New functions to provide sane threading callbacks with pthreads and win32 threading implementations.
svn:r1031
2009-01-21 07:51:25 +00:00
Nick Mathewson
f6eb1f816c Change evbuffer_read implementation to split data across chunks, and use readv when available. This should make us use less space.
svn:r1024
2009-01-19 21:53:03 +00:00
Nick Mathewson
a5901991c7 Use eventfd for main-thread notification where available (i.e., linux).
svn:r1023
2009-01-19 20:37:24 +00:00
Nick Mathewson
99db0e7f72 Add a new evbuffer_write_atmost() functino to write no more than a given number of bytes to an fd.
svn:r993
2009-01-12 20:42:19 +00:00