357 Commits

Author SHA1 Message Date
Niels Provos
8e8d94a3e0 Do not drop data from evbuffer when out of memory; reported by Jacek Masiulaniec
svn:r1436
2009-09-24 22:18:19 +00:00
Nick Mathewson
18fe400805 Forward-port: fix android compilation
svn:r1435
2009-09-23 23:51:26 +00:00
Nick Mathewson
c2ead9f173 Treat events with fd == -1 as addable.
This turns out to simplify a fair bit of logic, including the bufferevent
code, and should fix bug 2850656.

svn:r1431
2009-09-11 21:02:19 +00:00
Nick Mathewson
85255a6397 Make epoll use less RAM.
We do this by not allocating the maximum epoll_event array for the epoll
backend at startup.  Instead, we start out accepting 32 events at a time, and
double the array's size when it seems that the OS is generating events faster
than we're requesting them.  This saves up to 374K per epoll-based
event_base.  Resolves bug 2839240.

svn:r1428
2009-09-11 18:47:35 +00:00
Nick Mathewson
e3f89fa275 Add a trivial race-fix from Chromium: do not try to re-detect whether we have a monotonic clock every time we make a new event_base.
svn:r1427
2009-09-11 18:21:57 +00:00
Nick Mathewson
3b461a6d03 Treat a negative number of bytes to read as the kernel saying "I don't know."
svn:r1426
2009-09-11 18:21:37 +00:00
Nick Mathewson
f65b8b0964 On connect, call only one of BEV_EVENT_CONNECTED or writecb.
Previously, if we had a socket bufferevent in connect state, we'd send
both of these to indicate that the connection was done.  That was broken
since the point of adding BEV_EVENT_CONNECTED was so that we could
distinguish "we're connected" and "we wrote something".

Now, writecb is called only when
   A) the connection finished but the user never put the socket into a
      "connecting" state, or
   B) data was actually written.

svn:r1425
2009-08-19 20:55:25 +00:00
Nick Mathewson
2c1b0e4428 Fix build warnings and add changelog entry for evhttp patches.
svn:r1424
2009-08-16 19:22:15 +00:00
Nick Mathewson
22bd5b4287 Support sendfile on solaris: patch from Caitlin Mercer.
svn:r1419
2009-08-16 16:40:42 +00:00
Nick Mathewson
7a55c48d77 Add a few missing changelog entries
svn:r1412
2009-08-09 20:18:00 +00:00
Nick Mathewson
d41347722a Refactor evbuffer_readln() into a search-for-eol function and an extract-line function.
svn:r1404
2009-07-31 17:35:42 +00:00
Nick Mathewson
7c688dd9a2 New function to expose bufferevent.enabled
svn:r1401
2009-07-31 14:41:45 +00:00
Nick Mathewson
621aafd27a Export sockaddr comparison functionality.
svn:r1400
2009-07-30 22:11:23 +00:00
Nick Mathewson
d1a2254bf2 Fix some bugs in bufferevent_socket_connect
svn:r1398
2009-07-30 20:41:31 +00:00
Nick Mathewson
7c20a6ae52 Export an ev_socklen_t.
svn:r1391
2009-07-30 17:01:21 +00:00
Nick Mathewson
75fe762e03 Accessor function to get a listener's associated fd
svn:r1390
2009-07-30 17:00:56 +00:00
Nick Mathewson
3c99c79df9 Changelog entry for msvc fixes.
svn:r1388
2009-07-28 19:45:54 +00:00
Nick Mathewson
72ea534f8e Export evutil_str[n]casecmp as evutil_ascii_str[n]casecmp.
svn:r1387
2009-07-28 19:41:57 +00:00
Nick Mathewson
12199fa7a5 Fix segfault during failed allocatino of locked evdns base.
We need to comb the rest of the code to make sure that we don't blindly wrap
functions in LOCK(x), UNLOCK(x) when those functions might contain a FREE(x)
in the middle.

Rocco Carbone found and reported this bug.

svn:r1384
2009-07-28 17:11:03 +00:00
Nick Mathewson
f8b527e6a1 Fix a dumb bug where we would allocate too little memory in event_get_supported_methods().
svn:r1383
2009-07-28 05:09:06 +00:00
Nick Mathewson
709c21c48c Bufferevent support for openssl.
This code adds a new Bufferevent type that is only compiled when the
openssl library is present.  It supports using an SSL object and an
event alert mechanism, which can either be an fd or an underlying
bufferevent.

There is still more work to do: the unit tests are incomplete, and we
need to support flush and shutdown much better.  Sometimes events are
generated needlessly: this will hose performance.

There's a new encrypting proxy in sample/le-proxy.c.

This code has only been tested on OSX, and nowhere else.

svn:r1382
2009-07-28 04:03:57 +00:00
Nick Mathewson
e8400a43ca Rename encode_int(64) to avoid polluting the global namespace.
They're now called evtag_encode_int(64).  The old names are available
as macros in event2/tag_compat.h.

Also, add unit tests for encode/decode_int64.

svn:r1365
2009-07-20 14:55:35 +00:00
Nick Mathewson
9fcd84d196 Include disabled methods in event_get_supported_methods() output.
Previously, events that were disabled using EVENT_NO* were left out of
event_get_supported_methods().  This was wrong, broke unit tests
(under some circumstances) and left the user with no good way to tell
which methods were actually compiled in.

Fixes bug 2821015.

svn:r1344
2009-07-14 19:19:45 +00:00
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