Changes in 2.0.3-alpha: o Add a new code to support SSL/TLS on bufferevents, using the OpenSSL library (where available). o Fix a bug where we didn't allocate enough memory in event_get_supported_methods(). o Avoid segfault during failed allocation of locked evdns_base. (Found by Rocco Carbone.) o Export new evutil_ascii_* functions to perform locale-independent character type operations. o Try to compile better with MSVC: patches from Brodie Thiesfield o New evconnlistener_get_fd function to expose a listener's associated socket. o Expose an ev_socklen_t type for consistent use across platforms. o Make bufferevent_socket_connect() work when the original fd was -1. o Fix a bug in bufferevent_socket_connect() when the connection succeeds too quickly. o Export an evutil_sockaddr_cmp() to compare to sockaddr objects for equality. o Add a bufferevent_get_enabled() to tell what a bufferevent has been configured to do. o Add an evbuffer_search_eol() function to locate the end of a line nondestructively. o Add an evbuffer_search_range() function to search a bounded range of a buffer. o Fix a rare crash bug in evdns. o Have bufferevent_socket_connect() with no arguments put a bufferevent into connecting mode. o Support sendfile on Solaris: patch from Caitlin Mercer. o New functions to explicitly reference a socket used by an evhttp object. Patches from David Reiss. o When we send a BEV_EVENT_CONNECTED to indicate connected status, we no longer invoke the write callback as well unless we actually wrote data too. o If the kernel tells us that there are a negative number of bytes to read from a socket, do not believe it. Fixes bug 2841177; found by Alexander Pronchenkov. o Do not detect whether we have monotonic clock support every time a new event base is created: instead do it only once. Patch taken from Chromium. o Do not allocate the maximum event queue for the epoll backend at startup. Instead, start out accepting 32 events at a time, and double the queue's size when it seems that the OS is generating events faster than we're requesting them. Saves up to 374K per epoll-based event_base. Resolves bug 2839240. o Treat an event with a negative fd as valid but untriggerable by Libevent. This is useful for applications that want to manually activate events. o Fix compilation on Android, which forgot to define fd_mask in its sys/select.h o Do not drop data from evbuffer when out of memory; reported by Jacek Masiulaniec o New event_base_got_exit() and event_base_got_break() functions to tell whether an event loop exited because of an event_base_loopexit() or an event_base_loopbreak(). Patch from Ka-Hing Cheung. o When adding or deleting an event from a non-main thread, only wake up the main thread when its behavior actually needs to change. o Fix some bugs when using the old evdns interfaces to initialize the evdns module. o Detect errors during bufferevent_connect(). Patch from Christopher Davis. o Fix compilation for listener.h for C++ - missing extern "C". Patch from Ferenc Szalai. o Make the event_base_loop() family of functions respect thread-safety better. This should clear up a few hard-to-debug race conditions. o Fix a bug when using a specialized memory allocator on win32. o Have the win32 select() backend label TCP-socket-connected events as EV_WRITE, not EV_READ. This should bring it in line with the other backends, and improve portability. Patch from Christopher Davis. o Stop using enums as arguments or return values when what we mean is a bitfield of enum values. C++ doesn't believe that you can OR two enum values together and get another enum, and C++ takes its typing seriously. Patch from Christopher Davis. o Add an API to replace all fatal calls to exit() with a user-provided panic function. o Replace all assert() calls with a variant that is aware of the user-provided logging and panic functions. o Add a return value to event_assign so that it can fail rather than asserting when the user gives it bad input. event_set still dies on bad input. o The event_base_new() and event_base_new_with_config() functions now never call exit() on failure. For backward "compatibility", event_init() still does, but more consistently. o Remove compat/sys/_time.h. It interfered with system headers on HPUX, and its functionality has been subsumed by event2/util.h and util-internal.h. o Add a new bufferevent_socket_connect_hostname() to encapsulate the resolve-then-connect operation. o Build kqueue.c correctly on GNU/kFreeBSD platforms. Patch pulled upstream from Debian. o Alternative queue-based timeout algorithm for programs that use a large number of timeouts with the same value. o New event_base_config option to disable the timeval cache entirely. o Make EV_PERSIST timeouts more accurate: schedule the next event based on the scheduled time of the previous event, not based on the current time. o Allow http.c to handle cases where getaddrinfo returns an IPv6 address. Patch from Ryan Phillips. o Fix a problem with excessive memory allocation when using multiple event priorities. o Default to using arc4random for DNS transaction IDs on systems that have it; from OpenBSD. o Never check the environment when we're running setuid or setgid; from OpenBSD. o Options passed to evdns_set_option() no longer need to end with a colon. o Add an evutil_getaddrinfo() function to clone getaddrinfo on platforms that don't have it. o Add an evdns_getaddrinfo() function to provide a nonblocking getaddrinfo using evdns, so programs can perform useful hostname lookup. o Finally expose the IOCP-based bufferevent backend. It passes its unit tests, but probably still has some bugs remaining. Code by Nick Mathewson and Christopher Davis. o Numerous other bugfixes. o On FreeBSD and other OSes, connect can return ECONREFUSED immediately; instead of failing the function call, pretend with faileld in the callback. o Fix a race condition in the pthreads test case; found by Nick Mathewson o Remove most calls to event_err() in http and deal with memory errors instead Changes in 2.0.2-alpha: o Add a new flag to bufferevents to make all callbacks automatically deferred. o Make evdns functionality locked, and automatically defer dns callbacks. o Fix a possible free(NULL) when freeing an event_base with no signals. o Add a flag to disable checking environment varibles when making an event_base o Disallow setting less than 1 priority. o Fix a bug when removing a timeout from the heap. [Patch from Marko Kreen] o Use signal.h, not sys/signal.h. [Patch from mmadia] o Try harder to build with certain older c99 compilers. o Make sure that an event_config's flags field is always initialized to 0. [Bug report from Victor Goya] o Avoid data corruption when reading data entirely into the second-to-last chain of an evbuffer. [Bug report from Victor Goya] o Make sendfile work on FreeBSD o Do not use vararg macros for accessing evrpc structures; this is not backwards compatible, but we did not promise any backwards compatibility for the rpc code. o Actually define the event_config_set_flag() function. o Try harder to compile with Visual C++. o Move event_set() and its allies to event2/event_compat.h where they belong. o Remove the event_gotsig code, which has long been deprecated and unused. o Add an event_get_base() function to return the base assigned to an event. o New function to automate connecting on a socket-based bufferevent. o New functions to automate listening for incoming TCP connections. o Do case-insensitive checks with a locale-independent comparison function. o Rename the evbuffercb and everrorcb callbacks to bufferevent_data_cb and bufferevent_event_cb respectively. The old names are available in bufferevent_compat.h. o Rename the EVBUFFER_* codes used by bufferevent event callbacks to BEV_EVENT_*, to avoid namespace collision with evbuffer flags. The old names are available in bufferevent_compat.h. o Move the EVBUFFER_INPUT and EVBUFFER_OUTPUT macros to bufferevent_compat.h o Add a bufferevent_getfd() function to mirror bufferevent_setfd() o Make bufferevent_setfd() return an error code if the operation is not successful. o Shave 22 bytes off struct event on 32-bit platforms by shrinking and re-ordering fields. The savings on 64-bit platforms is likely higher. o Cap the maximum number of priorities at 256. o Change the semantics of evbuffer_cb_set_flags() to be set-flag only; add a new evbuffer_cb_clear_flags() to remove set flags. o Change the interface of evbuffer_add_reference so that the cleanup callback gets more information o Revise the new evbuffer_reserve_space/evbuffer_commit_space() interfaces so that you can use them without causing extraneous copies or leaving gaps in the evbuffer. o Add a new evbuffer_peek() interface to inspect data in an evbuffer without removing it. o Fix a deadlock when suspending reads in a bufferevent due to a full buffer. (Spotted by Joachim Bauch.) o Fix a memory error when freeing a thread-enabled event base with registered events. (Spotted by Joachim Bauch.) o Try to contain degree of failure when running on a win32 version so heavily firewalled that we can't fake a socketpair. o Activate fd events in a pseudorandom order with O(N) backends, so that we don't systematically favor low fds (select) or earlier-added fds (poll, win32). o Replace some read()/write() instances with send()/recv() to work properly on win32. o Set truncated flag correctly in evdns server replies. o Raise RpcGenError in event_rpcgen.py; from jmanison and Zack Weinberg o Fix preamble of rpcgen-generated files to rely on event2 includes; based on work by jmansion; patch from Zack Weinberg. o Allow specifying the output filename for rpcgen; based on work by jmansion; patch from Zack Weinberg. o Allow C identifiers as struct names; allow multiple comments in .rpc files; from Zack Weinberg o Mitigate a race condition when using socket bufferevents in multiple threads. o Use AC_SEARCH_LIBS, not AC_CHECK_LIB to avoid needless library use. o Do not allow event_del(ev) to return while that event's callback is executing in another thread. This fixes a nasty race condition. o event_get_supported_methods() now lists methods that have been disabled with the EVENT_NO* environment options. o Rename encode_int[64] to evtag_encode_int[64] to avoid polluting the global namespace. The old method names are still available as macros in event2/tag_compat.h. Changes in 2.0.1-alpha: o free minheap on event_base_free(); from Christopher Layne o debug cleanups in signal.c; from Christopher Layne o provide event_base_new() that does not set the current_base global o bufferevent_write now uses a const source argument; report from Charles Kerr o improve documentation on event_base_loopexit; patch from Scott Lamb o New function, event_{base_}loopbreak. Like event_loopexit, it makes an event loop stop executing and return. Unlike event_loopexit, it keeps subsequent pending events from getting executed. Patch from Scott Lamb o Check return value of event_add in signal.c o provide event_reinit() to reintialize an event_base after fork o New function event_set_mem_functinons. It allows the user to give libevent replacement functions to use for memory management in place of malloc(), free(), etc. This should be generally useful for memory instrumentation, specialized allocators, and so on. o The kqueue implementation now catches signals that are raised after event_add() is called but before the event_loop() call. This makes it match the other implementations. o The kqueue implementation now restores original signal handlers correctly when its signal events are removed. o Check return value of event_add in signal.c o Add a more powerful evbuffer_readln as a replacement for evbuffer_readline. The new function handles more newline styles, and is more useful with buffers that may contain a nul characters. o Do not mangle socket handles on 64-bit windows. o The configure script now takes an --enable-gcc-warnigns option that turns on many optional gcc warnings. (Nick has been building with these for a while, but they might be useful to other developers.) o move EV_PERSIST handling out of the event backends o small improvements to evhttp documentation o always generate Date and Content-Length headers for HTTP/1.1 replies o set the correct event base for HTTP close events o When building with GCC, use the "format" attribute to verify type correctness of calls to printf-like functions. o Rewrite win32.c backend to be O(n lg n) rather than O(n^2). o Removed obsoleted recalc code o support for 32-bit tag numbers in rpc structures; this is wire compatible, but changes the API slightly. o pull setters/getters out of RPC structures into a base class to which we just need to store a pointer; this reduces the memory footprint of these structures. o prefix {encode,decode}_tag functions with evtag to avoid collisions o fix a bug with event_rpcgen for integers o Correctly handle DNS replies with no answers set (Fixes bug 1846282) o add -Wstrict-aliasing to warnings and more cleanup o removed linger from http server socket; reported by Ilya Martynov o event_rpcgen now allows creating integer arrays o support string arrays in event_rpcgen o change evrpc hooking to allow pausing of RPCs; this will make it possible for the hook to do some meaning ful work; this is not backwards compatible. o allow an http request callback to take ownership of a request structure o allow association of meta data with RPC requests for hook processing o associate more context for hooks to query such as the connection object o remove pending timeouts on event_base_free() o also check EAGAIN for Solaris' event ports; from W.C.A. Wijngaards o devpoll and evport need reinit; tested by W.C.A Wijngaards o event_base_get_method; from Springande Ulv o Send CRLF after each chunk in HTTP output, for compliance with RFC2626. Patch from "propanbutan". Fixes bug 1894184. o Add a int64_t parsing function, with unit tests, so we can apply Scott Lamb's fix to allow large HTTP values. o Use a 64-bit field to hold HTTP content-lengths. Patch from Scott Lamb. o Allow regression code to build even without Python installed o remove NDEBUG ifdefs from evdns.c o detect integer types properly on platforms without stdint.h o udpate documentation of event_loop and event_base_loop; from Tani Hosokawa. o simplify evbuffer by removing orig_buffer o do not insert event into list when evsel->add fails o add support for PUT/DELETE requests; from Josh Rotenberg o introduce evhttp_accept_socket() to accept from an already created socket o include Content-Length in reply for HTTP/1.0 requests with keep-alive o increase listen queue for http sockets to 128; if that is not enough the evhttp_accpet_socket() api can be used with a prepared socket. o Patch from Tani Hosokawa: make some functions in http.c threadsafe. o test support for PUT/DELETE requests; from Josh Rotenberg o rewrite of the evbuffer code to reduce memory copies o Some older Solaris versions demand that _REENTRANT be defined to get strtok_r(); do so. o Do not free the kqop file descriptor in other processes, also allow it to be 0; from Andrei Nigmatulin o Provide OpenSSL style support for multiple threads accessing the same event_base o make event_rpcgen.py generate code include event-config.h; reported by Sam Banks. o switch thread support so that locks get allocated as they are needed. o make event methods static so that they are not exported; from Andrei Nigmatulin o make RPC replies use application/octet-stream as mime type o do not delete uninitialized timeout event in evdns o Correct the documentation on buffer printf functions. o Don't warn on unimplemented epoll_create(): this isn't a problem, just a reason to fall back to poll or select. o Correctly handle timeouts larger than 35 minutes on Linux with epoll.c. This is probably a kernel defect, but we'll have to support old kernels anyway even if it gets fixed. o Make name_from_addr() threadsafe in http.c o Add new thread-safe interfaces to evdns functions. o Make all event_tagging interfaces threadsafe. o Rename internal memory management functions. o New functions (event_assign, event_new, event_free) for use by apps that want to be safely threadsafe, or want to remain ignorant of the contents of struct event. o introduce bufferevent_read_buffer; allows reading without memory copy. o expose bufferevent_setwatermark via header files and fix high watermark on read o fix a bug in buffrevent read water marks and add a test for them o fix a bug in which bufferevent_write_buffer would not schedule a write event o provide bufferevent_input and bufferevent_output without requiring knowledge of the structure o introduce bufferevent_setcb and bufferevent_setfd to allow better manipulation of bufferevents o convert evhttp_connection to use bufferevents. o use libevent's internal timercmp on all platforms, to avoid bugs on old platforms where timercmp(a,b,<=) is buggy. o Remove the never-exported, never-used evhttp_hostportfile function. o Support input/output filters for bufferevents; somewhat similar to libio's model. This will allow us to implement SSL, compression, etc, transparently to users of bufferevents such as the http layer. o allow connections to be removed from an rpc pool o add new evtimer_assign, signal_assign, evtimer_new, and signal_new functions to manipulate timer and signal events, analagous to the now-recommended event_assign and event_new o switch internal uses of event_set over to use event_assign. o introduce evbuffer_contiguous_space() api that tells a user how much data is available in the first buffer chain o introduce evbuffer_reserve_space() and evbuffer_commit_space() to make processing in filters more efficient. o reduce system calls for getting current time by caching it. o separate signal events from io events; making the code less complex. o support for periodic timeouts o support for virtual HTTP hosts. o turn event_initialized() into a function, and add function equivalents to EVENT_SIGNAL and EVENT_FD so that people don't need to include event_struct.h o Build test directory correctly with CPPFLAGS set. o Provide an API for retrieving the supported event mechanisms. o event_base_new_with_config() and corresponding config APIs. o migrate the evhttp header to event2/ but accessors are still missing. o deprecate timeout_* event functions by moving them to event_compat.h o Move windows gettimeofday replacement into a new evutil_gettimeofday(). o Make configure script work on IRIX. o provide a method for canceling ongoing http requests. o Make vsnprintf() returns consistent on win32. o Fix connection keep-alive behavior for HTTP/1.0 o Fix use of freed memory in event_reinit; pointed out by Peter Postma o constify struct timeval * where possible o make event_get_supported_methods obey environment variables o support for edge-triggered events on epoll and kqueue backends: patch from Valery Kholodkov o support for selecting event backends by their features, and for querying the features of a backend. o change failing behavior of event_base_new_with_config: if a config is provided and no backend is selected, return NULL instead of aborting. o deliver partial data to request callbacks when chunked callback is set even if there is no chunking on the http level; allows cancelation of requests from within the chunked callback; from Scott Lamb. o allow min_heap_erase to be called on removed members; from liusifan. o Rename INPUT and OUTPUT to EVRPC_INPUT and EVRPC_OUTPUT. Retain INPUT/OUTPUT aliases on on-win32 platforms for backwards compatibility. o Do not use SO_REUSEADDR when connecting o Support 64-bit integers in RPC structs o Correct handling of trailing headers in chunked replies; from Scott Lamb. o Support multi-line HTTP headers; based on a patch from Moshe Litvin o Reject negative Content-Length headers; anonymous bug report o Detect CLOCK_MONOTONIC at runtime for evdns; anonymous bug report o Various HTTP correctness fixes from Scott Lamb o Fix a bug where deleting signals with the kqueue backend would cause subsequent adds to fail o Support multiple events listening on the same signal; make signals regular events that go on the same event queue; problem report by Alexander Drozdov. o Fix a problem with epoll() and reinit; problem report by Alexander Drozdov. o Fix off-by-one errors in devpoll; from Ian Bell o Make event_add not change any state if it fails; reported by Ian Bell. o Fix a bug where headers arriving in multiple packets were not parsed; fix from Jiang Hong; test by me. o Match the query in DNS replies to the query in the request; from Vsevolod Stakhov. o Add new utility functions to correctly observe and log winsock errors. o Do not remove Accept-Encoding header o Clear the timer cache on entering the event loop; reported by Victor Chang o Only bind the socket on connect when a local address has been provided; reported by Alejo Sanchez o Allow setting of local port for evhttp connections to support millions of connections from a single system; from Richard Jones. o Clear the timer cache when leaving the event loop; reported by Robin Haberkorn o Fix a typo in setting the global event base; reported by lance. o Set the 0x20 bit on outgoing alphabetic characters in DNS requests randomly, and insist on a match in replies. This helps resist DNS poisoning attacks. o Make the http connection close detection work properly with bufferevents and fix a potential memory leak associated with it. o Restructure the event backends so that they do not need to keep track of events themselves, as a side effect multiple events can use the same fd or signal. o Add generic implementations for parsing and emiting IPv6 addresses on platforms that do not have inet_ntop and/or inet_pton. o Allow DNS servers that have IPv6 addresses. o Add an evbuffer_write_atmost() function to write a limited number of bytes to an fd. o Refactor internal notify-main-thread logic to prefer eventfd to pipe, then pipe to socketpair, and only use socketpairs as a last resort. o Try harder to pack all evbuffer reads into as few chains as possible, using readv/WSARecv as appropriate. o New evthread_use_windows_threads() and evthread_use_pthreads() functions to set up the evthread callbacks with reasonable defaults. o Change the semantics of timeouts in conjunction with EV_PERSIST; timeouts in that case will now repeat until deleted. o sendfile, mmap and memory reference support for evbuffers. o New evutil_make_listen_socket_reuseable() to abstract SO_REUSEADDR. o New bind-to option to allow DNS clients to bind to an arbitrary port for outgoing requests. o evbuffers can now be "frozen" to prevent operations at one or both ends. o Bufferevents now notice external attempts to add data to an inbuf or remove it from an outbuf, and stop them. o Fix parsing of queries where the encoded queries contained \r, \n or + o Do not allow internal events to starve lower-priority events. Changes in 1.4.0: o allow \r or \n individually to separate HTTP headers instead of the standard "\r\n"; from Charles Kerr. o demote most http warnings to debug messages o Fix Solaris compilation; from Magne Mahre o Add a "Date" header to HTTP responses, as required by HTTP 1.1. o Support specifying the local address of an evhttp_connection using set_local_address o Fix a memory leak in which failed HTTP connections whould not free the request object o Make adding of array members in event_rpcgen more efficient, but doubling memory allocation o Fix a memory leak in the DNS server o Fix compilation when DNS_USE_OPENSSL_FOR_ID is enabled o Fix buffer size and string generation in evdns_resolve_reverse_ipv6(). o Respond to nonstandard DNS queries with "NOTIMPL" rather than by ignoring them. o In DNS responses, the CD flag should be preserved, not the TC flag. o Fix http.c to compile properly with USE_DEBUG; from Christopher Layne o Handle NULL timeouts correctly on Solaris; from Trond Norbye o Recalculate pending events properly when reallocating event array on Solaris; from Trond Norbye o Add Doxygen documentation to header files; from Mark Heily o Add a evdns_set_transaction_id_fn() function to override the default transaction ID generation code. o Add an evutil module (with header evutil.h) to implement our standard cross-platform hacks, on the theory that somebody else would like to use them too. o Fix signals implementation on windows. o Fix http module on windows to close sockets properly. o Make autogen.sh script run correctly on systems where /bin/sh isn't bash. (Patch from Trond Norbye, rewritten by Hagne Mahre and then Hannah Schroeter.) o Skip calling gettime() in timeout_process if we are not in fact waiting for any events. (Patch from Trond Norbye) o Make test subdirectory compile under mingw. o Fix win32 buffer.c behavior so that it is correct for sockets (which do not like ReadFile and WriteFile). o Make the test.sh script run unit tests for the evpoll method. o Make the entire evdns.h header enclosed in "extern C" as appropriate. o Fix implementation of strsep on platforms that lack it o Fix implementation of getaddrinfo on platforms that lack it; mainly, this will make Windows http.c work better. Original patch by Lubomir Marinov. o Fix evport implementation: port_disassociate called on unassociated events resulting in bogus errors; more efficient memory management; from Trond Norbye and Prakash Sangappa o support for hooks on rpc input and output; can be used to implement rpc independent processing such as compression or authentication. o use a min heap instead of a red-black tree for timeouts; as a result finding the min is a O(1) operation now; from Maxim Yegorushkin o associate an event base with an rpc pool o added two additional libraries: libevent_core and libevent_extra in addition to the regular libevent. libevent_core contains only the event core whereas libevent_extra contains dns, http and rpc support o Begin using libtool's library versioning support correctly. If we don't mess up, this will more or less guarantee binaries linked against old versions of libevent continue working when we make changes to libevent that do not break backward compatibility. o Fix evhttp.h compilation when TAILQ_ENTRY is not defined. o Small code cleanups in epoll_dispatch(). o Increase the maximum number of addresses read from a packet in evdns to 32. o Remove support for the rtsig method: it hasn't compiled for a while, and nobody seems to miss it very much. Let us know if there's a good reason to put it back in. o Rename the "class" field in evdns_server_request to dns_question_class, so that it won't break compilation under C++. Use a macro so that old code won't break. Mark the macro as deprecated. o Fix DNS unit tests so that having a DNS server with broken IPv6 support is no longer cause for aborting the unit tests. o Make event_base_free() succeed even if there are pending non-internal events on a base. This may still leak memory and fds, but at least it no longer crashes. o Post-process the config.h file into a new, installed event-config.h file that we can install, and whose macros will be safe to include in header files. o Remove the long-deprecated acconfig.h file. o Do not require #include before #include . o Add new evutil_timer* functions to wrap (or replace) the regular timeval manipulation functions. o Fix many build issues when using the Microsoft C compiler. o Remove a bash-ism in autogen.sh o When calling event_del on a signal, restore the signal handler's previous value rather than setting it to SIG_DFL. Patch from Christopher Layne. o Make the logic for active events work better with internal events; patch from Christopher Layne. o We do not need to specially remove a timeout before calling event_del; patch from Christopher Layne.