head 1.1; branch 1.1.1; access; symbols libevent-2-1-13-stable:1.1.1.1 netbsd-11-0-RC6:1.1.1.1 netbsd-11-0-RC5:1.1.1.1 netbsd-11-0-RC4:1.1.1.1 netbsd-11-0-RC3:1.1.1.1 netbsd-11-0-RC2:1.1.1.1 netbsd-11-0-RC1:1.1.1.1 perseant-exfatfs-base-20250801:1.1.1.1 netbsd-11:1.1.1.1.0.30 netbsd-11-base:1.1.1.1 netbsd-10-1-RELEASE:1.1.1.1 perseant-exfatfs-base-20240630:1.1.1.1 perseant-exfatfs:1.1.1.1.0.28 perseant-exfatfs-base:1.1.1.1 netbsd-8-3-RELEASE:1.1.1.1 netbsd-9-4-RELEASE:1.1.1.1 netbsd-10-0-RELEASE:1.1.1.1 netbsd-10-0-RC6:1.1.1.1 netbsd-10-0-RC5:1.1.1.1 netbsd-10-0-RC4:1.1.1.1 netbsd-10-0-RC3:1.1.1.1 netbsd-10-0-RC2:1.1.1.1 netbsd-10-0-RC1:1.1.1.1 netbsd-10:1.1.1.1.0.26 netbsd-10-base:1.1.1.1 netbsd-9-3-RELEASE:1.1.1.1 cjep_sun2x-base1:1.1.1.1 cjep_sun2x:1.1.1.1.0.24 cjep_sun2x-base:1.1.1.1 cjep_staticlib_x-base1:1.1.1.1 netbsd-9-2-RELEASE:1.1.1.1 cjep_staticlib_x:1.1.1.1.0.22 cjep_staticlib_x-base:1.1.1.1 libevent-2-1-12-stable:1.1.1.1 netbsd-9-1-RELEASE:1.1.1.1 phil-wifi-20200421:1.1.1.1 phil-wifi-20200411:1.1.1.1 is-mlppp:1.1.1.1.0.20 is-mlppp-base:1.1.1.1 phil-wifi-20200406:1.1.1.1 netbsd-8-2-RELEASE:1.1.1.1 netbsd-9-0-RELEASE:1.1.1.1 netbsd-9-0-RC2:1.1.1.1 netbsd-9-0-RC1:1.1.1.1 phil-wifi-20191119:1.1.1.1 netbsd-9:1.1.1.1.0.18 netbsd-9-base:1.1.1.1 phil-wifi-20190609:1.1.1.1 netbsd-8-1-RELEASE:1.1.1.1 netbsd-8-1-RC1:1.1.1.1 pgoyette-compat-merge-20190127:1.1.1.1 pgoyette-compat-20190127:1.1.1.1 pgoyette-compat-20190118:1.1.1.1 pgoyette-compat-1226:1.1.1.1 pgoyette-compat-1126:1.1.1.1 pgoyette-compat-1020:1.1.1.1 pgoyette-compat-0930:1.1.1.1 pgoyette-compat-0906:1.1.1.1 pgoyette-compat-0728:1.1.1.1 netbsd-8-0-RELEASE:1.1.1.1 phil-wifi:1.1.1.1.0.16 phil-wifi-base:1.1.1.1 pgoyette-compat-0625:1.1.1.1 netbsd-8-0-RC2:1.1.1.1 pgoyette-compat-0521:1.1.1.1 pgoyette-compat-0502:1.1.1.1 pgoyette-compat-0422:1.1.1.1 netbsd-8-0-RC1:1.1.1.1 pgoyette-compat-0415:1.1.1.1 pgoyette-compat-0407:1.1.1.1 pgoyette-compat-0330:1.1.1.1 pgoyette-compat-0322:1.1.1.1 pgoyette-compat-0315:1.1.1.1 pgoyette-compat:1.1.1.1.0.14 pgoyette-compat-base:1.1.1.1 matt-nb8-mediatek:1.1.1.1.0.12 matt-nb8-mediatek-base:1.1.1.1 perseant-stdc-iso10646:1.1.1.1.0.10 perseant-stdc-iso10646-base:1.1.1.1 netbsd-8:1.1.1.1.0.8 netbsd-8-base:1.1.1.1 prg-localcount2-base3:1.1.1.1 prg-localcount2-base2:1.1.1.1 prg-localcount2-base1:1.1.1.1 prg-localcount2:1.1.1.1.0.6 prg-localcount2-base:1.1.1.1 pgoyette-localcount-20170426:1.1.1.1 bouyer-socketcan:1.1.1.1.0.4 bouyer-socketcan-base1:1.1.1.1 pgoyette-localcount:1.1.1.1.0.2 pgoyette-localcount-20170320:1.1.1.1 libevent-2-1-8-stable:1.1.1.1 LIBEVENT:1.1.1; locks; strict; comment @# @; 1.1 date 2017.01.31.21.14.52; author christos; state Exp; branches 1.1.1.1; next ; commitid mv0PIIuv5XZ3haEz; 1.1.1.1 date 2017.01.31.21.14.52; author christos; state Exp; branches 1.1.1.1.2.1 1.1.1.1.4.1; next ; commitid mv0PIIuv5XZ3haEz; 1.1.1.1.2.1 date 2017.01.31.21.14.52; author pgoyette; state dead; branches; next 1.1.1.1.2.2; commitid jjw7cAwgyKq7RfKz; 1.1.1.1.2.2 date 2017.03.20.06.52.22; author pgoyette; state Exp; branches; next ; commitid jjw7cAwgyKq7RfKz; 1.1.1.1.4.1 date 2017.01.31.21.14.52; author bouyer; state dead; branches; next 1.1.1.1.4.2; commitid dUG7nkTKALCadqOz; 1.1.1.1.4.2 date 2017.04.21.16.51.32; author bouyer; state Exp; branches; next ; commitid dUG7nkTKALCadqOz; desc @@ 1.1 log @Initial revision @ text @ What's new in Libevent 2.1 Nick Mathewson 0. Before we start 0.1. About this document This document describes the key differences between Libevent 2.0 and Libevent 2.1, from a user's point of view. It's a work in progress. For better documentation about libevent, see the links at http://libevent.org/ Libevent 2.1 would not be possible without the generous help of numerous volunteers. For a list of who did what in Libevent 2.1, please see the ChangeLog! NOTE: I am very sure that I missed some thing on this list. Caveat haxxor. 0.2. Where to get help Try looking at the other documentation too. All of the header files have documentation in the doxygen format; this gets turned into nice HTML and linked to from the libevent.org website. There is a work-in-progress book with reference manual at http://www.wangafu.net/~nickm/libevent-book/ . You can ask questions on the #libevent IRC channel at irc.oftc.net or on the mailing list at libevent-users@@freehaven.net. The mailing list is subscribers-only, so you will need to subscribe before you post. 0.3. Compatibility Our source-compatibility policy is that correct code (that is to say, code that uses public interfaces of Libevent and relies only on their documented behavior) should have forward source compatibility: any such code that worked with a previous version of Libevent should work with this version too. We don't try to do binary compatibility except within stable release series, so binaries linked against any version of Libevent 2.0 will probably need to be recompiled against Libevent 2.1.4-alpha if you want to use it. It is probable that we'll break binary compatibility again before Libevent 2.1 is stable. 1. New APIs and features 1.1. New ways to build libevent We now provide an --enable-gcc-hardening configure option to turn on GCC features designed for increased code security. There is also an --enable-silent-rules configure option to make compilation run more quietly with automake 1.11 or later. You no longer need to use the --enable-gcc-warnings option to turn on all of the GCC warnings that Libevent uses. The only change from using that option now is to turn warnings into errors. For IDE users, files that are not supposed to be built are now surrounded with appropriate #ifdef lines to keep your IDE from getting upset. There is now an alternative cmake-based build process; cmake users should see the relevant sections in the README. 1.2. New functions for events and the event loop If you're running Libevent with multiple event priorities, you might want to make sure that Libevent checks for new events frequently, so that time-consuming or numerous low-priority events don't keep it from checking for new high-priority events. You can now use the event_config_set_max_dispatch_interval() interface to ensure that the loop checks for new events either every N microseconds, every M callbacks, or both. When configuring an event base, you can now choose whether you want timers to be more efficient, or more precise. (This only has effect on Linux for now.) Timers are efficient by default: to select more precise timers, use the EVENT_BASE_FLAG_PRECISE_TIMER flag when constructing the event_config, or set the EVENT_PRECISE_TIMER environment variable to a non-empty string. There is an EVLOOP_NO_EXIT_ON_EMPTY flag that tells event_base_loop() to keep looping even when there are no pending events. (Ordinarily, event_base_loop() will exit as soon as no events are pending.) Past versions of Libevent have been annoying to use with some memory-leak-checking tools, because Libevent allocated some global singletons but provided no means to free them. There is now a function, libevent_global_shutdown(), that you can use to free all globally held resources before exiting, so that your leak-check tools don't complain. (Note: this function doesn't free non-global things like events, bufferevents, and so on; and it doesn't free anything that wouldn't otherwise get cleaned up by the operating system when your process exit()s. If you aren't using a leak-checking tool, there is not much reason to call libevent_global_shutdown().) There is a new event_base_get_npriorities() function to return the number of priorities set in the event base. Libevent 2.0 added an event_new() function to construct a new struct event on the heap. Unfortunately, with event_new(), there was no equivalent for: struct event ev; event_assign(&ev, base, fd, EV_READ, callback, &ev); In other words, there was no easy way for event_new() to set up an event so that the event itself would be its callback argument. Libevent 2.1 lets you do this by passing "event_self_cbarg()" as the callback argument: struct event *evp; evp = event_new(base, fd, EV_READ, callback, event_self_cbarg()); There's also a new event_base_get_running_event() function you can call from within a Libevent callback to get a pointer to the current event. This should never be strictly necessary, but it's sometimes convenient. The event_base_once() function used to leak some memory if the event that it added was never actually triggered. Now, its memory is tracked in the event_base and freed when the event_base is freed. Note however that Libevent doesn't know how to free any information passed as the callback argument to event_base_once is still something you'll might need a way to de-allocate yourself. There is an event_get_priority() function to return an event's priority. By analogy to event_base_loopbreak(), there is now an event_base_loopcontinue() that tells Libevent to stop processing active event callbacks, and re-scan for new events right away. There's a function, event_base_foreach_event(), that can iterate over every event currently pending or active on an event base, and invoke a user-supplied callback on each. The callback must not alter the events or add or remove anything to the event base. We now have an event_remove_timer() function to remove the timeout on an event while leaving its socket and/or signal triggers unchanged. (If we were designing the API from scratch, this would be the behavior of "event_add(ev, NULL)" on an already-added event with a timeout. But that's a no-op in past versions of Libevent, and we don't want to break compatibility.) You can use the new event_base_get_num_events() function to find the number of events active or pending on an event_base. To find the largest number of events that there have been since the last call, use event_base_get_max_events(). You can now activate all the events waiting for a given fd or signal using the event_base_active_by_fd() and event_base_active_by_signal() APIs. On backends that support it (currently epoll), there is now an EV_CLOSED flag that programs can use to detect when a socket has closed without having to read all the bytes until receiving an EOF. 1.3. Event finalization 1.3.1. Why event finalization? Libevent 2.1 now supports an API for safely "finalizing" events that might be running in multiple threads, and provides a way to slightly change the semantics of event_del() to prevent deadlocks in multithreaded programs. To motivate this feature, consider the following code, in the context of a mulithreaded Libevent application: struct connection *conn = event_get_callback_arg(ev); event_del(ev); connection_free(conn); Suppose that the event's callback might be running in another thread, and using the value of "conn" concurrently. We wouldn't want to execute the connection_free() call until "conn" is no longer in use. How can we make this code safe? Libevent 2.0 answered that question by saying that the event_del() call should block if the event's callback is running in another thread. That way, we can be sure that event_del() has canceled the callback (if the callback hadn't started running yet), or has waited for the callback to finish. But now suppose that the data structure is protected by a lock, and we have the following code: void check_disable(struct connection *connection) { lock(connection); if (should_stop_reading(connection)) event_del(connection->read_event); unlock(connection); } What happens when we call check_disable() from a callback and from another thread? Let's say that the other thread gets the lock first. If it decides to call event_del(), it will wait for the callback to finish. But meanwhile, the callback will be waiting for the lock on the connection. Since each threads is waiting for the other one to release a resource, the program will deadlock. This bug showed up in multithreaded bufferevent programs in 2.1, particularly when freeing bufferevents. (For more information, see the "Deadlock when calling bufferevent_free from an other thread" thread on libevent-users starting on 6 August 2012 and running through February of 2013. You might also like to read my earlier writeup at http://archives.seul.org/libevent/users/Feb-2012/msg00053.html and the ensuing discussion.) 1.3.2. The EV_FINALIZE flag and avoiding deadlock To prevent the deadlock condition described above, Libevent 2.1.3-alpha adds a new flag, "EV_FINALIZE". You can pass it to event_new() and event_assign() along with EV_READ, EV_WRITE, and the other event flags. When an event is constructed with the EV_FINALIZE flag, event_del() will not block on that event, even when the event's callback is running in another thread. By using EV_FINALIZE, you are therefore promising not to use the "event_del(ev); free(event_get_callback_arg(ev));" pattern, but rather to use one of the finalization functions below to clean up the event. EV_FINALIZE has no effect on a single-threaded program, or on a program where events are only used from one thread. There are also two new variants of event_del() that you can use for more fine-grained control: event_del_noblock(ev) event_del_block(ev) The event_del_noblock() function will never block, even if the event callback is running in another thread and doesn't have the EV_FINALIZE flag. The event_del_block() function will _always_ block if the event callback is running in another thread, even if the event _does_ have the EV_FINALIZE flag. [A future version of Libevent may have a way to make the EV_FINALIZE flag the default.] 1.3.3. Safely finalizing events To safely tear down an event that may be running, Libevent 2.1.3-alpha introduces event_finalize() and event_free_finalize(). You call them on an event, and provide a finalizer callback to be run on the event and its callback argument once the event is definitely no longer running. With event_free_finalize(), the event is also freed once the finalizer callback has been invoked. A finalized event cannot be re-added or activated. The finalizer callback must not add events, activate events, or attempt to "resucitate" the event being finalized in any way. If any finalizer callbacks are pending as the event_base is being freed, they will be invoked. You can override this behavior with the new function event_base_free_nofinalize(). 1.4. New debugging features You can now turn on debug logs at runtime using a new function, event_enable_debug_logging(). The event_enable_lock_debugging() function is now spelled correctly. You can still use the old "event_enable_lock_debuging" name, though, so your old programs shouldnt' break. There's also been some work done to try to make the debugging logs more generally useful. 1.5. New evbuffer functions In Libevent 2.0, we introduced evbuffer_add_file() to add an entire file's contents to an evbuffer, and then send them using sendfile() or mmap() as appropriate. This API had some drawbacks, however. Notably, it created one mapping or fd for every instance of the same file added to any evbuffer. Also, adding a file to an evbuffer could make that buffer unusable with SSL bufferevents, filtering bufferevents, and any code that tried to read the contents of the evbuffer. Libevent 2.1 adds a new evbuffer_file_segment API to solve these problems. Now, you can use evbuffer_file_segment_new() to construct a file-segment object, and evbuffer_add_file_segment() to insert it (or part of it) into an evbuffer. These segments avoid creating redundant maps or fds. Better still, the code is smart enough (when the OS supports sendfile) to map the file when that's necessary, and use sendfile() otherwise. File segments can receive callback functions that are invoked when the file segments are freed. The evbuffer_ptr interface has been extended so that an evbuffer_ptr can now yield a point just after the end of the buffer. This makes many algorithms simpler to implement. There's a new evbuffer_add_buffer() interface that you can use to add one buffer to another nondestructively. When you say evbuffer_add_buffer_reference(outbuf, inbuf), outbuf now contains a reference to the contents of inbuf. To aid in adding data in bulk while minimizing evbuffer calls, there is an evbuffer_add_iovec() function. There's a new evbuffer_copyout_from() variant function to enable copying data nondestructively from the middle of a buffer. evbuffer_readln() now supports an EVBUFFER_EOL_NUL argument to fetch NUL-terminated strings from buffers. There's a new evbuffer_set_flags()/evbuffer_clear_flags() that you can use to set EVBUFFER_FLAG_DRAINS_TO_FD. 1.6. New functions and features: bufferevents You can now use the bufferevent_getcb() function to find out a bufferevent's callbacks. Previously, there was no supported way to do that. The largest chunk readable or writeable in a single bufferevent callback is no longer hardcoded; it's now configurable with the new functions bufferevent_set_max_single_read() and bufferevent_set_max_single_write(). For consistency, OpenSSL bufferevents now make sure to always set one of BEV_EVENT_READING or BEV_EVENT_WRITING when invoking an event callback. Calling bufferevent_set_timeouts(bev, NULL, NULL) now removes the timeouts from socket and ssl bufferevents correctly. You can find the priority at which a bufferevent runs with bufferevent_get_priority(). The function bufferevent_get_token_bucket_cfg() can retrieve the rate-limit settings for a bufferevent; bufferevent_getwatermark() can return a bufferevent's current watermark settings. You can manually trigger a bufferevent's callbacks via bufferevent_trigger() and bufferevent_trigger_event(). Also you can manually increment/decrement reference for bufferevent with bufferevent_incref()/bufferevent_decref(), it is useful in situations where a user may reference the bufferevent somewhere else. Now bufferevent_openssl supports "dirty" shutdown (when the peer closes the TCP connection before closing the SSL channel), see bufferevent_openssl_get_allow_dirty_shutdown() and bufferevent_openssl_set_allow_dirty_shutdown(). And also libevent supports openssl 1.1. 1.7. New functions and features: evdns The previous evdns interface used an "open a test UDP socket" trick in order to detect IPv6 support. This was a hack, since it would sometimes badly confuse people's firewall software, even though no packets were sent. The current evdns interface-detection code uses the appropriate OS functions to see which interfaces are configured. The evdns_base_new() function now has multiple possible values for its second (flags) argument. Using 1 and 0 have their old meanings, though the 1 flag now has a symbolic name of EVDNS_BASE_INITIALIZE_NAMESERVERS. A second flag is now supported too: the EVDNS_BASE_DISABLE_WHEN_INACTIVE flag, which tells the evdns_base that it should not prevent Libevent from exiting while it has no DNS requests in progress. There is a new evdns_base_clear_host_addresses() function to remove all the /etc/hosts addresses registered with an evdns instance. Also there is evdns_base_get_nameserver_addr() for retrieve the address of the 'idx'th configured nameserver. 1.8. New functions and features: evconnlistener Libevent 2.1 adds the following evconnlistener flags: LEV_OPT_DEFERRED_ACCEPT -- Tells the OS that it doesn't need to report sockets as having arrived until the initiator has sent some data too. This can greatly improve performance with protocols like HTTP where the client always speaks first. On operating systems that don't support this functionality, this option has no effect. LEV_OPT_REUSEABLE_PORT -- Indicates that we ask to allow multiple servers to bind to the same port if they each set the option Ionly on Linux and >=3.9) LEV_OPT_DISABLED -- Creates an evconnlistener in the disabled (not listening) state. Libevent 2.1 changes the behavior of the LEV_OPT_CLOSE_ON_EXEC flag. Previously, it would apply to the listener sockets, but not to the accepted sockets themselves. That's almost never what you want. Now, it applies both to the listener and the accepted sockets. 1.9. New functions and features: evhttp ********************************************************************** NOTE: The evhttp module will eventually be deprecated in favor of Mark Ellzey's libevhtp library. Don't worry -- this won't happen until libevhtp provides every feature that evhttp does, and provides a compatible interface that applications can use to migrate. ********************************************************************** Previously, you could only set evhttp timeouts in increments of one second. Now, you can use evhttp_set_timeout_tv() and evhttp_connection_set_timeout_tv() to configure microsecond-granularity timeouts. Also there is evhttp_connection_set_initial_retry_tv() to change initial retry timeout. There are a new pair of functions: evhttp_set_bevcb() and evhttp_connection_base_bufferevent_new(), that you can use to configure which bufferevents will be used for incoming and outgoing http connections respectively. These functions, combined with SSL bufferevents, should enable HTTPS support. There's a new evhttp_foreach_bound_socket() function to iterate over every listener on an evhttp object. Whitespace between lines in headers is now folded into a single space; whitespace at the end of a header is now removed. The socket errno value is now preserved when invoking an http error callback. There's a new kind of request callback for errors; you can set it with evhttp_request_set_error_cb(). It gets called when there's a request error, and actually reports the error code and lets you figure out which request failed. You can navigate from an evhttp_connection back to its evhttp with the new evhttp_connection_get_server() function. You can override the default HTTP Content-Type with the new evhttp_set_default_content_type() function There's a new evhttp_connection_get_addr() API to return the peer address of an evhttp_connection. The new evhttp_send_reply_chunk_with_cb() is a variant of evhttp_send_reply_chunk() with a callback to be invoked when the chunk is sent. The evhttp_request_set_header_cb() facility adds a callback to be invoked while parsing headers. The evhttp_request_set_on_complete_cb() facility adds a callback to be invoked on request completion. You can add linger-close for http server by passing EVHTTP_SERVER_LINGERING_CLOSE to evhttp_set_flags(), with this flag server read all the clients body, and only after this respond with an error if the clients body exceed max_body_size (since some clients cannot read response otherwise). The evhttp_connection_set_family() can bypass family hint to evdns. There are some flags available for connections, which can be installed with evhttp_connection_set_flags(): - EVHTTP_CON_REUSE_CONNECTED_ADDR -- reuse connection address on retry (avoid extra DNS request). - EVHTTP_CON_READ_ON_WRITE_ERROR - try read error, since server may already close the connection. The evhttp_connection_free_on_completion() can be used to tell libevent to free the connection object after the last request has completed or failed. There is evhttp_request_get_response_code_line() if evhttp_request_get_response_code() is not enough for you. There are *evhttp_uri_parse_with_flags() that accepts EVHTTP_URI_NONCONFORMANT to tolerate URIs that do not conform to RFC3986. The evhttp_uri_set_flags() can changes the flags on URI. 1.10. New functions and features: evutil There's a function "evutil_secure_rng_set_urandom_device_file()" that you can use to override the default file that Libevent uses to seed its (sort-of) secure RNG. The evutil_date_rfc1123() returns date in RFC1123 There are new API to work with monotonic timer -- monotonic time is guaranteed never to run in reverse, but is not necessarily epoch-based. Use it to make reliable measurements of elapsed time between events even when the system time may be changed: - evutil_monotonic_timer_new()/evutil_monotonic_timer_free() - evutil_configure_monotonic_time() - evutil_gettime_monotonic() Use evutil_make_listen_socket_reuseable_port() to set SO_REUSEPORT (linux >= 3.9) The evutil_make_tcp_listen_socket_deferred() can make a tcp listener socket defer accept()s until there is data to read (TCP_DEFER_ACCEPT). 2. Cross-platform performance improvements 2.1. Better data structures We replaced several users of the sys/queue.h "TAILQ" data structure with the "LIST" data structure. Because this data type doesn't require FIFO access, it requires fewer pointer checks and manipulations to keep it in line. All previous versions of Libevent have kept every pending (added) event in an "eventqueue" data structure. Starting in Libevent 2.0, however, this structure became redundant: every pending timeout event is stored in the timeout heap or in one of the common_timeout queues, and every pending fd or signal event is stored in an evmap. Libevent 2.1 removes this data structure, and thereby saves all of the code that we'd been using to keep it updated. 2.2. Faster activations and timeouts It's a common pattern in older code to use event_base_once() with a 0-second timeout to ensure that a callback will get run 'as soon as possible' in the current iteration of the Libevent loop. We optimize this case by calling event_active() directly, and bypassing the timeout pool. (People who are using this pattern should also consider using event_active() themselves.) Libevent 2.0 would wake up a polling event loop whenever the first timeout in the event loop was adjusted--whether it had become earlier or later. We now only notify the event loop when a change causes the expiration time to become _sooner_ than it would have been otherwise. The timeout heap code is now optimized to perform fewer comparisons and shifts when changing or removing a timeout. Instead of checking for a wall-clock time jump every time we call clock_gettime(), we now check only every 5 seconds. This should save a huge number of gettimeofday() calls. 2.3. Microoptimizations Internal event list maintainance no longer use the antipattern where we have one function with multiple totally independent behaviors depending on an argument: #define OP1 1 #define OP2 2 #define OP3 3 void func(int operation, struct event *ev) { switch (op) { ... } } Instead, these functions are now split into separate functions for each operation: void func_op1(struct event *ev) { ... } void func_op2(struct event *ev) { ... } void func_op3(struct event *ev) { ... } This produces better code generation and inlining decisions on some compilers, and makes the code easier to read and check. 2.4. Evbuffer performance improvements The EVBUFFER_EOL_CRLF line-ending type is now much faster, thanks to smart optimizations. 2.5. HTTP performance improvements o Performance tweak to evhttp_parse_request_line. (aee1a97 Mark Ellzey) o Add missing break to evhttp_parse_request_line (0fcc536) 2.6. Coarse timers by default on Linux Due to limitations of the epoll interface, Libevent programs using epoll have not previously been able to wait for timeouts with accuracy smaller than 1 millisecond. But Libevent had been using CLOCK_MONOTONIC for timekeeping on Linux, which is needlessly expensive: CLOCK_MONOTONIC_COARSE has approximately the resolution corresponding to epoll, and is much faster to invoke than CLOCK_MONOTONIC. To disable coarse timers, and get a more plausible precision, use the new EVENT_BASE_FLAG_PRECISE_TIMER flag when setting up your event base. 3. Backend/OS-specific improvements 3.1. Linux-specific improvements The logic for deciding which arguements to use with epoll_ctl() is now a table-driven lookup, rather than the previous pile of cascading branches. This should minimize epoll_ctl() calls and make the epoll code run a little faster on change-heavy loads. Libevent now takes advantage of Linux's support for enhanced APIs (e.g., SOCK_CLOEXEC, SOCK_NONBLOCK, accept4, pipe2) that allow us to simultaneously create a socket, make it nonblocking, and make it close-on-exec. This should save syscalls throughout our codebase, and avoid race-conditions if an exec() occurs after a socket is socket is created but before we can make it close-on-execute on it. 3.2. Windows-specific improvements We now use GetSystemTimeAsFileTime to implement gettimeofday. It's significantly faster and more accurate than our old ftime()-based approach. 3.3. Improvements in the solaris evport backend. The evport backend has been updated to use many of the infrastructure improvements from Libevent 2.0. Notably, it keeps track of per-fd information using the evmap infrastructure, and removes a number of linear scans over recently-added events. This last change makes it efficient to receive many more events per evport_getn() call, thereby reducing evport overhead in general. 3.4. OSX backend improvements The OSX select backend doesn't like to have more than a certain number of fds set unless an "unlimited select" option has been set. Therefore, we now set it. 3.5. Monotonic clocks on even more platforms Libevent previously used a monotonic clock for its internal timekeeping only on platforms supporting the POSIX clock_gettime() interface. Now, Libevent has support for monotonic clocks on OSX and Windows too, and a fallback implementation for systems without monotonic clocks that will at least keep time running forwards. Using monotonic timers makes Libevent more resilient to changes in the system time, as can happen in small amounts due to clock adjustments from NTP, or in large amounts due to users who move their system clocks all over the timeline in order to keep nagware from nagging them. 3.6. Faster cross-thread notification on kqueue When a thread other than the one in which the main event loop is running needs to wake the thread running the main event loop, Libevent usually writes to a socketpair in order to force the main event loop to wake up. On Linux, we've been able to use eventfd() instead. Now on BSD and OSX systems (any anywhere else that has kqueue with the EVFILT_USER extension), we can use EVFILT_USER to wake up the main thread from kqueue. This should be a tiny bit faster than the previous approach. 4. Infrastructure improvements 4.1. Faster tests I've spent some time to try to make the unit tests run faster in Libevent 2.1. Nearly all of this was a matter of searching slow tests for unreasonably long timeouts, and cutting them down to reasonably long delays, though on one or two cases I actually had to parallelize an operation or improve an algorithm. On my desktop, a full "make verify" run of Libevent 2.0.18-stable requires about 218 seconds. Libevent 2.1.1-alpha cuts this down to about 78 seconds. Faster unit tests are great, since they let programmers test their changes without losing their train of thought. 4.2. Finicky tests are now off-by-default The Tinytest unit testing framework now supports optional tests, and Libevent uses them. By default, Libevent's unit testing framework does not run tests that require a working network, and does not run tests that tend to fail on heavily loaded systems because of timing issues. To re-enable all tests, run ./test/regress using the "@@all" alias. 4.3. Modernized use of autotools Our autotools-based build system has been updated to build without warnings on recent autoconf/automake versions. Libevent's autotools makefiles are no longer recursive. This allows make to use the maximum possible parallelism to do the minimally necessary amount of work. See Peter Miller's "Recursive Make Considered Harmful" at http://miller.emu.id.au/pmiller/books/rmch/ for more information here. We now use the "quiet build" option to suppress distracting messages about which commandlines are running. You can get them back with "make V=1". 4.4. Portability Libevent now uses large-file support internally on platforms where it matters. You shouldn't need to set _LARGEFILE or OFFSET_BITS or anything magic before including the Libevent headers, either, since Libevent now sets the size of ev_off_t to the size of off_t that it received at compile time, not to some (possibly different) size based on current macro definitions when your program is building. We now also use the Autoconf AC_USE_SYSTEM_EXTENSIONS mechanism to enable per-system macros needed to enable not-on-by-default features. Unlike the rest of the autoconf macros, we output these to an internal-use-only evconfig-private.h header, since their names need to survive unmangled. This lets us build correctly on more platforms, and avoid inconsistencies when some files define _GNU_SOURCE and others don't. Libevent now tries to detect OpenSSL via pkg-config. 4.5. Standards conformance Previous Libevent versions had no consistent convention for internal vs external identifiers, and used identifiers starting with the "_" character throughout the codebase. That's no good, since the C standard says that identifiers beginning with _ are reserved. I'm not aware of having any collisions with system identifiers, but it's best to fix these things before they cause trouble. We now avoid all use of the _identifiers in the Libevent source code. These changes were made *mainly* through the use of automated scripts, so there shouldn't be any mistakes, but you never know. As an exception, the names _EVENT_LOG_DEBUG, _EVENT_LOG_MSG_, _EVENT_LOG_WARN, and _EVENT_LOG_ERR are still exposed in event.h: they are now deprecated, but to support older code, they will need to stay around for a while. New code should use EVENT_LOG_DEBUG, EVENT_LOG_MSG, EVENT_LOG_WARN, and EVENT_LOG_ERR instead. 4.6. Event and callback refactoring As a simplification and optimization to Libevent's "deferred callback" logic (introduced in 2.0 to avoid callback recursion), Libevent now treats all of its deferrable callback types using the same logic it uses for active events. Now deferred events no longer cause priority inversion, no longer require special code to cancel them, and so on. Regular events and deferred callbacks now both descend from an internal light-weight event_callback supertype, and both support priorities and take part in the other anti-priority-inversion mechanisms in Libevent. To avoid starvation from callback recursion (which was the reason we introduced "deferred callbacks" in the first place) the implementation now allows an event callback to be scheduled as "active later": instead of running in the current iteration of the event loop, it runs in the next one. 5. Testing Libevent's test coverage level is more or less unchanged since before: we still have over 80% line coverage in our tests on Linux, FreeBSD, NetBSD, Windows, OSX. There are some under-tested modules, though: we need to fix those. And now we have CI: - https://travis-ci.org/libevent/libevent - https://ci.appveyor.com/project/nmathewson/libevent And code coverage: - https://coveralls.io/github/libevent/libevent Plus there is vagrant boxes if you what to test it on more OS'es then travis-ci allows, and there is a wrapper (in python) that will parse logs and provide report: - https://github.com/libevent/libevent-extras/blob/master/tools/vagrant-tests.py 6. Contributing From now we have contributing guide and checkpatch.sh. @ 1.1.1.1 log @Changes in version 2.1.8-stable (22 January 2017) Libevent 2.1.8-stable, it contains openssl fixes for resetting fd and using bufferevent_openssl_filter_new(). vagrant fixes, some build fixes, increased timeout for some tests (to reduce number of failures due to timing issues), date in RFC1123 format and running tests in parallel. There are highlighted changes above. Build fixes: o Fix _FILE_OFFSET_BITS redinition (solaris/autotools) (336f3b11 Azat Khuzhin) o util-internal: fix __func__ redefinition (netbsd) (253e7fa9 Azat Khuzhin) o Fix signedness differ for iov_base (solaris) (2c62062e Azat Khuzhin) o evutil_time: include when there is only sleep()/usleep() (3e75194c Azat Khuzhin) o http: fix formatter for pritnf for req->ntoread (osx) (1cbf26f6 Azat Khuzhin) Testing environment: o Merge branch 'automake-tests-parallel-v4' (*includes ci bits also*) (59e217df Azat Khuzhin) Vagrant env fixes: o vagrant/netbsd: missing libtool (9c9be399 Azat Khuzhin) o vagrant/netbsd: more reliable way of installing packages (36da6877 Azat Khuzhin) o vagrant/osx: use make instead of gmake (there is no gmake) (f7c70aef Azat Khuzhin) o vagrant: add centos box (ca591c5b Azat Khuzhin) Tests: o test/dns: replace servname since solaris does not have "http" (d6bafbbe Azat Khuzhin) o test/thread: netbsd is too slow, increase timeout for conditions_simple (3c7422fc Azat Khuzhin) o test/dns: run async resolving after sync one (to avoid timeouts) (07862531 Azat Khuzhin) o test/http: turn off some tests that based on backlog filling (falky) (26f416c1 Azat Khuzhin) Bugfixes: o Merge branch 'openssl-filter-fixes-v4' (83e0f43b Azat Khuzhin) o Merge branch 'date-rfc1123' (68def435,4798de6c,4545807d Azat Khuzhin) o Merge branch 'be-openssl-fd-reset-fix-v2' (86fa0070,32adf434 Azat Khuzhin) o Merge branch 'openssl-1.1-init-fixes-v2' (18a161f0 Azat Khuzhin) o Fix incorrect MIME type (23f9a20e johnsonlee) Trivial fixes: Documentation updates: o Update README.md (3821cca1 Breaker) Changes in version 2.1.7-rc (2 Novemer 2016) Libevent 2.1.7-rc contains openssl 1.1 support, build fixes, CI improvements and plus Vagrantfile for testing under multiple OS'es. Continious Integration: o Use coveralls.io via travis (9ac000c Azat Khuzhin) o travis-ci: use container-based infrastructure (7e12e96 Azat Khuzhin) o travis-ci/osx: fix compiling/linking openssl libraries (9d2f8d4 Azat Khuzhin) o travis-ci: use gcc-5 (fixes osx|gcc failures) (d7ceae5 Azat Khuzhin) o Testing with vagrant for 6 OS and cmake+autoconf (9585338 Azat Khuzhin) o travis-ci/osx: install lcov (e4e099b Azat Khuzhin) Build Improvements/Fixes: o Fix cmake -DEVENT__COVERAGE=ON (40fbffc Azat Khuzhin) o autogen.sh: learn about gmake (9376ac4 Azat Khuzhin) o autogen.sh: remove all autoconf/automake caches, if any (69cce25 Azat Khuzhin) o cmake: fix finding python2, and check that it is really 2 (3453c08 Azat Khuzhin) o cmake: fix CheckFunctionExistsEx/CheckPrototypeDefinition (CMP0054) (43b69b2 Azat Khuzhin) o cmake: cleanup (dc624ad Zonr Chang) o cmake/win32: fix running regress, but fixing finding python2 interpreter (bcb990a Azat Khuzhin) o cmake: use PYTHON_EXECUTABLE to find python2 (a4d044c Azat Khuzhin) o Merge branch 'force-disable-clockgettime' (83c7cdf Azat Khuzhin) Code Improvements (core) o use ev_uint16_t instead of unsigned short for port (e983712 Thomas Bernard) o Merge branch 'contrib-guide-v2' (b9c5077 Azat Khuzhin) o poll: Prevent libevent from spinning if POLLNVAL occurs (675974c Tim Hentenaar) Testing: o test/regress: cover a polling of invalid fd (cb0df5c Tim Hentenaar) Code Improvements (bufferevent_openssl) o Make it build using OpenSSL 1.1.0 (3e9e0a0 Kurt Roeckx) o Don't call BIO_number_{read|written} on NULL BIOs. (6702da1 Adam Langley) o Switch from a 512 to 2048-bit RSA key. (f9803a6 Adam Langley) Trivial fixes: o Ignore temporary configure files (8fb08ae Azat Khuzhin) o README.md: fix typo: ar -> are (2361616 Simone Basso) o be: just a simple mistake, reinclude the (7521664 Seven) Changes in version 2.1.6-beta (4 July 2016) Libevent 2.1.6-beta contains mostly bug fixes (evbuffers, evthread, evdns, bufferevents, core, http, samples), improvements but mostly to fix some possible issues (EVHTTP_CON_LINGERING_CLOSE), a lot of new unit tests and new appveyor integration. Security Fixes (utils) o evutil_parse_sockaddr_port(): fix buffer overflow (329acc1 Azat Khuzhin) Security Fixes (evdns) o evdns: name_parse(): fix remote stack overread (96f64a0 Azat Khuzhin) o evdns: fix searching empty hostnames (ec65c42 Azat Khuzhin) New APIs (evdns) o New function to get address for nameserver. (537177d Nick Mathewson) New APIs (bufferevents) o expose bufferevent_incref/decref (with fewer modifications) (1ed6718 Mark Ellzey) New APIs (internal) o evdns: export cancel via callbacks in util (like async lib core/extra issues) (8cbe65d Azat Khuzhin) New APIs/Improvements (http) o http: take EVHTTP_CON_LINGERING_CLOSE into account for "Expect: 100-Continue" (ac448a7 Azat Khuzhin) o http: lingering close (like nginx have) for entity-too-large (9fde518 Azat Khuzhin) o http: read server response even after server closed the connection (680742e Azat Khuzhin) o http: export evhttp_connection_set_family() (714fc70 Azat Khuzhin) o http: reuse connected address only with EVHTTP_CON_REUSE_CONNECTED_ADDR (a50f5f0 Azat Khuzhin) o http: use IP address that we got before (if any) during retrying (54c887d Azat Khuzhin) Bugfixes (core) o Fix getaddrinfo under solaris (for multiprotocol case) (40730ae Azat Khuzhin) o Check for Mac OS X 10.4 kqueue bug properly (df6f99e Mark Mentovai) o event_reinit: make signals works after fork() without evsig_add() (88640aa Nicholas Marriott) o event_reinit: always re-init signal's socketpair (ad0c237 Nicholas Marriott) o Free event queues even for recursive finalizers (7c8d015 Azat Khuzhin) o Fix checking for make_base_notifiable() (f337296 Azat Khuzhin) o Set correct socklen for PF_INET6 sockaddr len (3499ad9 Mark Ellzey) o Fix garbage value in socketpair util function, stdint? (043ae74 Mark Ellzey) o fix the return value of event_deferred_cb_schedule_ (38cef64 Greg Hazel) o event_free_debug_globals_locks(): disable lock debugging (e5c87d1 Azat Khuzhin) o event: call event_disable_debug_mode() in libevent_global_shutdown() (941faae Azat Khuzhin) o ht-internal: don't reset hth_table_length explicitly in name_##HT_CLEAR (597c7b2 Azat Khuzhin) Bugfixes (evthread) o evthread: fix evthread_setup_global_lock_() for debug-lock with a real-lock case (e4556fc Azat Khuzhin) o evthread: evthreadimpl_disable_lock_debugging_() for libevent_global_shutdown() (ccc5593 Azat Khuzhin) Bugfixes (evdns) o evdns: avoid double-free in evdns_base_free() for probing requests (4db15e0 Azat Khuzhin) o evdns: evdns_base_free(): fix UAF of evdns_base with @@fail_requests (00313c5 Azat Khuzhin) o evdns: evdns_base_free(): free requests before namservers (14f84bb Azat Khuzhin) o evdns: fix randomize-case by make case-insensitive as required (9c238de Azat Khuzhin) Bugfixes (bufferevents) o be_sock: handle readv() returns ECONNREFUSED (freebsd 9.2) (3189eb0 Azat Khuzhin) o be_filter: avoid data stuck under active watermarks (b627ad8 Eduardo Panisset) o Fix bufferevent_pair to properly set BEV_EVENT_{READING,WRITING} on flush. (2851889 David Paschich) o be_openssl: clear all pending errors before SSL_*() calls (38e0f4a Azat Khuzhin) o be_sock: cancel in-progress dns requests (86dfd2c Azat Khuzhin) o be_sock: unfreeze buffers on fd changing (255525d Azat Khuzhin) o be_sock: bufferevent_socket_connect_hostname(): make it thread-safe (809bb39 Azat Khuzhin) o be_openssl: don't call do_write() directly from outbuf_cb (da52933 Azat Khuzhin) o be_openssl: use bufferevent_enable() instead of bufferevent_add_event_() (0c66d32 Azat Khuzhin) o be_openssl: don't add events during bev creation (like be_sock) (f4b6284 Azat Khuzhin) o Fix lock leak in be_pair_flush() if flush type is BEV_NORMAL (f45d39d Bill Vaughan) o be_openssl: don't use *_auto() in do_handshake() we can't have fd == -1 there (877280d Azat Khuzhin) o be_openssl: don't call set_open_callbacks() if fd == -1 (e8a2da9 Azat Khuzhin) o be_openssl: get rid off hackish "fd_is_set", to fix some corner cases (40b0379 Azat Khuzhin) o be: we don't need to use getpeername() we we have conn_address (2c271e2 Azat Khuzhin) o Call underlying bev ctrl SET_FD on filtered bufferevents (c2aa7dc Mark Ellzey) o be_pair: release shared lock with the latest of bufferevent_pair (92a359e Azat Khuzhin) Bugfixes (http) o [Issue #313] set method to ASCII "NULL" if evhttp_method() returns NULL (17cc636 Mark Ellzey) o evhttp_have_expect(): fix -Wlogical-not-parentheses (24b5214 Azat Khuzhin) o http: set fd to -1 unconditioally, to avoid leaking of DNS requests (7a4b472 Azat Khuzhin) o http: avoid leaking of fd in evhttp_connection_free() (f0e1341 Azat Khuzhin) o http: get fd from be layer during connection reset (4a53c54 Azat Khuzhin) o http: fix EVHTTP_CON_READ_ON_WRITE_ERROR when it doesn't supported by OS (2ff164a Azat Khuzhin) o http: do not do function calls under EVUTIL_ASSERT() to fix NDEBUG builds (7c89999 Azat Khuzhin) o http: fix leaking of response_code_line (8f18a62 Azat Khuzhin) o http: fix "Expect: 100-continue" client side (0b46b39 Azat Khuzhin) o http: fix conflicts EVHTTP_CON_AUTOFREE and EVHTTP_CON_REUSE_CONNECTED_ADDR (4dc0979 Azat Khuzhin) o http: avoid epoll_ctl() on already closed fd (triggers by http/chunk_out) (ab3bc69 Azat Khuzhin) o http: install timeout for read too during connect for ssl (040000d Azat Khuzhin) o http: fix evhttp_request_own() by checking EVHTTP_USER_OWNED in more cases (b0d3964 Azat Khuzhin) o http: fix detecting EOF without write (7ed02ac Azat Khuzhin) o evhttp: Fix failure to send all output data for POST/PUT requests (24eea0d John Ohl) o Fix evhttp_uriencode() regression. (c6b1ec1 Mark Ellzey) o removed unused vars (e94250c Mark Ellzey) o pointer overflow checks for evhttp_uriencode (72afe4c Zonr Chang) Bugfixes (evbuffers) o buffer: fix overflow check in evbuffer_expand_singlechain() (a3f4ccd Azat Khuzhin) o buffer: evbuffer_add_buffer(): clean empty chains from destination buffer (26fd932 Azat Khuzhin) o Fix n_add_for_cb in evbuffer_prepend() in case of new buffer required (0abd039 Azat Khuzhin) o be_filter: actually disable output_filter during processing output (c031215 Simon Perreault) o evbuffer_add: Use last_with_datap if set, not last. (a8769ef Marcus Sundberg) o EVBUFFER_PTR_SET -> EVBUFFER_PTR_ADD (8674e4f jer-gentoo) Bugfixes (evconnlistener) o listener: unlock lev on error in listener_read_cb() (2a71b33 Azat Khuzhin) o Fix potential fd leak in listener_read_cb() (a695a72 Mark Ellzey) Testing o tests: use waitpid(..., WNOWAIT) to fix failing of main/fork under solaris (43eb56c Azat Khuzhin) o test: replace sleeping with syncing pair in main/fork (16d220c Azat Khuzhin) o test/http: do not run tests that based on backlog filling (freebsd) (500b6b7 Azat Khuzhin) o test/bufferevent/iocp: fix test name for "bufferevent_connect_fail_eventcb" (4410e9d Azat Khuzhin) o test/ssl: use send()/recv()/EVUTIL_ERR_RW_RETRIABLE()/EVUTIL_SOCKET_ERROR() to fix win32 (a9e8cd6 Azat Khuzhin) o test/https_basic: increase timeout for complete write (fixes win32) (d5a2f2f Azat Khuzhin) o test: fix building with --disable-thread-support under win32 (a487706 Azat Khuzhin) o test/buffer: evbuffer_add_buffer() with empty chains (a272bc4 Azat Khuzhin) o test/buffer: evbuffer_remove_buffer() with empty chains (prepend) (f0cfa14 Azat Khuzhin) o test/buffer: evbuffer_remove_buffer() with empty chains (evbuffer_add_buffer()) (2880ce6 Azat Khuzhin) o test/buffer: cover evbuffer_expand() for overflow (48dab7a Azat Khuzhin) o test/be_filter: creating test case for data stuck with active watermarks (766194b Eduardo Panisset) o test/http: avoid using conditionals with omitted operands (fixes VS2015) (2a4bf29 Azat Khuzhin) o test/http: don't mix declarations and code (fixes -Wdeclaration-after-statement) (aabf1c2 Azat Khuzhin) o test/buffer: fix leak in test_evbuffer_prepend() (c08d90b Azat Khuzhin) o test/buffer: avoid errors with --no-fork (reinitialize static vars) (e7d1e39 Azat Khuzhin) o test/buffer: cover n_add_for_cb when evbuffer_prepend() need to allocate buffer (e77ff41 Azat Khuzhin) o test/tinytest_macros: add new one tt_nstr_op() (bd19a28 Azat Khuzhin) o test/bufferevent: check that output_filter disabled during processing output (ae28812 Azat Khuzhin) o test/listener: regression for missing unlock in listener_read_cb() (7d85651 Azat Khuzhin) o test/regress: add tests for evbuffer_add() breakage on empty last chain (d5ee739 Marcus Sundberg) o test/http: fix running some tests sequential (with --no-fork) (bddad71 Azat Khuzhin) o test/http: localize evhttp server structure (cbc3209 Azat Khuzhin) o test/dns: regression for empty hostname (d7348ba Azat Khuzhin) o test/http: fix SERVER_TIMEOUT tests under win32 (d49a658 Azat Khuzhin) o test/http: add a helper for creating timedout/failed request (376f107 Azat Khuzhin) o test/http: adopt for C90 (mixed code and declarations) (d02a285 Azat Khuzhin) o test/http: cover NS timed out during request cancellations separatelly (0c343af Azat Khuzhin) o test/http: request cancellation with resolving/{conn,write}-timeouts in progress (334340d Azat Khuzhin) o test/http: exit from the loop in the errorcb to wait cancellation (927ab33 Azat Khuzhin) o regress_clean_dnsserver(): reset global port vars (351207f Azat Khuzhin) o test/http: read_on_write_error: fix it for win32 (3b58169 Azat Khuzhin) o test/http: separate coverage for EVHTTP_CON_READ_ON_WRITE_ERROR (5c2b4c1 Azat Khuzhin) o test/http: cover "Expect: 100-continue" client-server interaction (31d8116 Azat Khuzhin) o test/http: *lingering tests shouldn't have "Expect: 100-continue" (ed469ab Azat Khuzhin) o test: use EVUTIL_SHUT_WR (04fc82f Azat Khuzhin) o test/http: avoid huge stack allocations to fix win32 builds (3166765 Azat Khuzhin) o test: http/lingering_close: cover EVHTTP_SERVER_LINGERING_CLOSE (e122ca1 Azat Khuzhin) o test: http/non_lingering_close: cover ~EVHTTP_SERVER_LINGERING_CLOSE (f41e1b0 Azat Khuzhin) o test: http/*: update expected HTTP codes for body exceeds `max_body_size` (addf2b9 Azat Khuzhin) o test: http/data_length_constrains: set EVHTTP_CON_READ_ON_WRITE_ERROR (d38a723 Azat Khuzhin) o test: increase buffer size for http/data_length_constraints to trigger EPIPE (0792e1e Azat Khuzhin) o test/tinytest_demo: include for win32 to fix tdm-gcc (f062bbe Azat Khuzhin) o test/regress: cover event_del() waiting mechanism (5b58b70 Azat Khuzhin) o test/regress: cover existing signal callbacks and fork() + event_reinit() (ceddc60 Azat Khuzhin) o test/regress: cover signals after fork() + event_reinit() (b075b81 Azat Khuzhin) o test/regress: main/fork: rewrite assertions by just removing event in callback (088d8b3 Azat Khuzhin) o test/dns: check exit code of evdns_getaddrinfo() (0b9d432 Azat Khuzhin) o test/dns: cover evdns_getaddrinfo() and evdns_base_free() with @@fail_requests (4ad3483 Azat Khuzhin) o test/dns: cover @@fail_requests for evdns_base_free() (d6c6fb4 Azat Khuzhin) o test/dns: more graceful coverage of @@fail_requests (123d372 Azat Khuzhin) o test/ssl: cover busy-loop (i.e. {read,write}-blocked-on-{write,read} stuff) (da0ea7a Azat Khuzhin) o test/http: write_during_read for https (23c77b6 Azat Khuzhin) o test/http: connection_fail for https (7ea26f7 Azat Khuzhin) o test/http: stream_out for https (ac04968 Azat Khuzhin) o test/http: chunk_out for https (a71ffb9 Azat Khuzhin) o test/regress: fix ssl-less builds (need to make this prettier) (3160716 Azat Khuzhin) o test/http: allow dirty shutdown for ssl to fix https_incomplete (1ede326 Azat Khuzhin) o test/http: https basic (59714b4 Azat Khuzhin) o test/http: incomplete{,_timeout} for https (615490d Azat Khuzhin) o test/http: add simplest test for http/https/https_dirty_shutdown (93b19dc Azat Khuzhin) o test/http: https: retry coverage (7c2d24a Azat Khuzhin) o test/http: https server support (plus some helpers) (a7088ad Azat Khuzhin) o test/http: more sanity checks (a27c53c Azat Khuzhin) o test/ssl: export getkey()/getcert()/get_ssl_ctx()/init_ssl() for https (0c4c387 Azat Khuzhin) o test/regress_be: basic coverage bufferevent_flush() for pair/sock layers (ad52602 Azat Khuzhin) o test/regress_be: socket_filter_inactive: check bufferevent after creation (f8081af Azat Khuzhin) o test/regress_be: cover finalizers from inactive to active queue (337684b Azat Khuzhin) o test/regress_buffer: fix clang compilation warnings (d8fd4c0 Azat Khuzhin) o test/regress_http: fix compilation warnings (-Wmissing-field-initializers) (cd422e0 Azat Khuzhin) o test/regress_dns: fix compilation warnings (-Wmissing-field-initializers/for) (f55db98 Azat Khuzhin) o tests/regress_dns: cover that randomize-case works case-insensitive (1e8bfbc Azat Khuzhin) o test: fix bufferevent/bufferevent_pair_release_lock in debug mode (3f749e9 Azat Khuzhin) o test: fix bufferevent/bufferevent_pair_release_lock for freebsd (79f9ace Azat Khuzhin) o test/regress_be: bufferevent_enable() shouldn't call eventcb by it's own (a0f308d Azat Khuzhin) o test/regress_be: introduce fake_listener_create() (37dc9e0 Azat Khuzhin) o test/regress_http: cover evhttp_request_own() (6f6fa0d Azat Khuzhin) o test/regress_http: cover write during read (3d15aeb Azat Khuzhin) o test/regress_http: verify that closecb will be called without multiple write (4be6c70 Azat Khuzhin) o test/regress: fix bufferevent_pair_release_lock with EVENT_DEBUG_MODE (6ea6655 Azat Khuzhin) o test/regress_ssl: check events fd/pending after timeout triggered (cdafdf0 Azat Khuzhin) o test/regress_ssl: cover case when server didn't up (failed with timeout) (74845f1 Azat Khuzhin) o test/regress_ssl: covert that we can't change fd with underlying (df507af Azat Khuzhin) o test/regress_ssl: cover that events (read/write) at finish not pending (762edb4 Azat Khuzhin) o test/regress_ssl: cover fd manipulations (b78a829 Azat Khuzhin) o test/regress_ssl: convert open_ssl_bufevs() to mask (46bba73 Azat Khuzhin) o test/regress_ssl: convert client/server to mask too (3455991 Azat Khuzhin) o test/regress_ssl: cover "allow_dirty_shutdown" (0430327 Azat Khuzhin) o test/regress_ssl: convert regress_bufferevent_openssl() to bitmask (342e116 Azat Khuzhin) o tests/regress_ssl: drop duplicated assert (25e56fd Azat Khuzhin) o test/regress_http: initialize "dns_base" to avoid reading trash (9f0bff3 Azat Khuzhin) o test/http: cover retrying with saved conn_address by shutting down dns server (f4874d8 Azat Khuzhin) o be_pair/regress: cover use of shared lock (lock/unlock/free) (a558fcd Azat Khuzhin) o regress_dns: drop hack for event_debug_map_HT_GROW in leak tests (3540a19 Azat Khuzhin) Sample code o Fix memory leak in signal-test.c (666db91 basavesh.as) o sample/hello-world: exAmple, not eXMple (2d3cd35 kirillDanshin) o dns-example: allow to set ns from args (df19a97 Azat Khuzhin) o dns-example: convert to getopt() (32f8592 Azat Khuzhin) o http-connect: make it win32 compilable (1bf7595 Azat Khuzhin) o sample/https-client: allow to change path to ca-certificates (fdf713a Azat Khuzhin) o sample/https-client: check for ERR_remove_thread_state() existence (c4e9d9b Azat Khuzhin) o sample/https-client: replace ERR_remove_state() by ERR_remove_thread_state() (77ad68a Azat Khuzhin) o sample/https-client: add -timeout option (4637aa8 Azat Khuzhin) o sample/https-client: don't try to free uninitialized SSL (f3d7ff5 Azat Khuzhin) o sample/https-client: graceful exit with freeing memory (to make valgrind happy) (24a1f25 Azat Khuzhin) o https-client: correctly handle URLs with no path (like "https://host:port") (29a0482 Andrey Skriabin) o sample/http-connect: don't use assert() to make it work with NDEBUG (6dc71e7 Azat Khuzhin) o sample/http-connect: made it compatible with C90 (f976d43 Azat Khuzhin) o sample: add HTTP CONNECT tunnelling example using libevent http layer (1d34498 Azat Khuzhin) o Update dns-example. (620ff24 Mark Ellzey) Documentation o Update README.md (b8ec70c Mark Ellzey) o Update README.md (80faee9 Mark Ellzey) o Update README.md (ad4a897 Mark Ellzey) o Update README.md (a2b2e1e Mark Ellzey) o Update README.md (0dfa5dc Mark Ellzey) Code Improvements (evthread) o evthread: add evthread_get_{lock,condition}_callbacks() helpers (c0b34f6 Azat Khuzhin) Code Improvements (core) o util: make @@sa const for evutil_socket_connect_() (a8d32c2 Azat Khuzhin) Code Improvements (http) o http: assert's that evbuffer_drain() success on connection reset (2185e63 Azat Khuzhin) o http: introduce evhttp_request_free_() helper (22061ac Azat Khuzhin) o http: introduce evhttp_is_request_connection_close() helper (6540da3 Azat Khuzhin) Code Improvements (bufferevents) o be_sock: bufferevent_socket_set_conn_address(): assert instead of silent no-op (0ab88c2 Azat Khuzhin) o be_sock: sanity check in bufferevent_socket_set_conn_address() (eedbeff Azat Khuzhin) o be: replace sockaddr_storage with sockaddr_in6 for conn_address (3889612 Azat Khuzhin) o be: replace conn_address by full struct instead of pointer (e5615aa Azat Khuzhin) o bufferevent: move conn_address out from http into bufferevent (8bb3842 Azat Khuzhin) o be: make @@sa const for bufferevent_socket_connect() (dc33c78 Azat Khuzhin) Cleanups (core) o Refactoring conditional directives that break parts of statements. (4b41eeb lzmths) o epoll: introduce PRINT_CHANGES() macro to avoid copy-pasting (a1b142b Azat Khuzhin) o tab (6e7a580 Greg Hazel) Cleanups (evbuffers) o buffer_compat: fix comment -- we have EVBUFFER_EOL_ANY not EOL_STYLE_ANY (575ff67 Azat Khuzhin) Cleanups (bufferevents) o be_sock: evutil_getaddrinfo_async_() always return 0 (dbff101 Azat Khuzhin) o be_sock: drop be_sock_add() macro (useless and debug unfriendly) (fad5fe2 Azat Khuzhin) o be: introduce bufferevent_generic_adj_existing_timeouts_() (3c1f58f Azat Khuzhin) o be: add_event: use evutil_timerisset() (a96b73b Azat Khuzhin) o be_openssl: introduce be_openssl_auto_fd() helper (2a8a711 Azat Khuzhin) o be_openssl: introduce set_open_callbacks_auto() (510da71 Azat Khuzhin) Cleanups (http) o http: make fallback for EVHTTP_CON_READ_ON_WRITE_ERROR more cleaner (d405492 Azat Khuzhin) o http: coding style issue (365f181 Azat Khuzhin) Cleanups (evdns) o evnds: inline TEST_NAME macro to make debuggin easier (0c615f4 Azat Khuzhin) Portability Fixes o [#372] check for errno.h (3031617 Mark Ellzey) o Fixed Unicode issue in error messages. (e8b7895 Mattes D) o Assume that ke_udata is an integer type on CloudABI. (5602e45 Ed Schouten) o Add missing include of . (b2c68bc Ed Schouten) o Include , and optionally. (c1404b5 Ed Schouten) o Test against SO_REUSEADDR (along with _WIN32). (ce1776c Ed Schouten) o Always define missing TAILQ functions from sys/queue.h (2828bdb Christopher Wiley) o Don't use BSD u_* types. (fd36647 Ed Schouten) o Remove BSD-ism: TIMEVAL_TO_TIMESPEC(). (193c7de Ed Schouten) o be: include all variations of headers for sockaddr_in6 struct (c212291 Azat Khuzhin) o be: fix sockaddr_in6 type definition for win32 (c42bc6b Azat Khuzhin) Continious Integration: o travis: split long lines, and make it cleaner (685a6a1 Azat Khuzhin) o travis: fix autotools on osx by reinstalling libtool (088ea5e Azat Khuzhin) o appveyor/autotools: link with openssl by passing LDFLAGS/CFLAGS (6fcfa25 Azat Khuzhin) o appveyor: image already had openssl installed (4634b85 Azat Khuzhin) o appveyor: check -DUNICODE -D_UNICODE according to ReleaseChecklist (cmake only) (e9acc44 Azat Khuzhin) o appveyor: ignore failure of mingw-get (1810857 Azat Khuzhin) o appveyor: drop shallow_clone, since we use tags for detecting version in cmake (ac90133 Azat Khuzhin) o appveyor: support cmake & autotools using build matrix (like travis-ci has) (8f95015 Azat Khuzhin) o travis-ci/osx: relink gcc/g++ instead of clang (481481d Azat Khuzhin) o travis-ci: enable multi-os mode (osx, linux) (79917e4 Azat Khuzhin) o travis-ci: increase matrix (--disable-foo) (59649f7 Azat Khuzhin) o travis-ci: adjust alignment (c8be339 Azat Khuzhin) o travis: add builds without debug mode into matrix (3e56da2 Azat Khuzhin) o test: run regress with EVENT_DEBUG_MODE=1 and without (cf2cf2a Azat Khuzhin) o Update travis config for status updates (37453ab Mark Ellzey) o Use autotools for appveyor until cmake is fixed. (1cc2e29 Mark Ellzey) o Fix the link for appveyor OpenSSL installer (WIN32) (107d565 Mark Ellzey) o Forgot to install OpenSSL for appveyor (26164a5 Joakim Söderberg) o Add support for appveyor.com windows CI (5f89c37 Joakim Söderberg) Build Improvements/Fixes: o evutil: mark ai_find_protocol() static (prototype-less) (5a157c8 Azat Khuzhin) o cmake/solaris: set CMAKE_REQUIRED_LIBRARIES to fix functions detections (dc95823 Azat Khuzhin) o cmake/solaris: fix building (link with socket,nsl) (050bfc7 Azat Khuzhin) o cmake: check for ZLIB_INCLUDE_DIR, since we can have only library without headers (c4dfb93 Azat Khuzhin) o autotools/win32: fix searching ssl library (671a24f Azat Khuzhin) o cmake/win32: do not compile regress_thread on -DEVENT__DISABLE_THREAD_SUPPORT=ON (de0c196 Azat Khuzhin) o cmake/win32: do not compile evthread_win32 on -DEVENT__DISABLE_THREAD_SUPPORT=ON (ecb0ec8 Azat Khuzhin) o cmake: fix -DEVENT__ENABLE_VERBOSE_DEBUG (typo on -DUSE_DEBUG) (e35f224 Azat Khuzhin) o cmake: do not use stderr for notifications/version-info (38716c6 Azat Khuzhin) o autoconf: fix --disable-thread-support build under win32 (bb09535 Azat Khuzhin) o buffer: don't mix code and declarations (8892f4c Azat Khuzhin) o Update gitignore file to ignore cscope gen'ed files (0aaa4fb Neeraj Badlani) o For non GCC/clang on OSX the -Wno-deprecated-declarations may not be valid (b5ca365 Rainer Keller) o automake: define serial-tests only if automake have this option (61179de Azat Khuzhin) o test/automake: don't use paralell test harness (since automake 1.12) (44d755e Azat Khuzhin) o Ignore all pkgconfig generated stuff (ce38993 Azat Khuzhin) o libevent_core and libevent_extra also deserve a pkgconfig file (b8d7c62 Jan Heylen) o Ignore verify_tests.bat (win32 version) (0f2de10 Azat Khuzhin) o cmake: require 3.1 only for win32 to make it work under ubunty precise (87f7238 Azat Khuzhin) o cmake: require at least 3.1 for target_sources() (c46ead5 Azat Khuzhin) o cmake: fix adding of compiler flags, and now it will (36588e1 Azat Khuzhin) o Replace -Wswitch-enum with -Wswitch, and add it into cmake rules too (f29f59e Azat Khuzhin) o test/regress_ssl: Fix compile problems for win32 (73d0360 Trond Norbye) o util: fix "%zu" format on TDM-gcc/MinGW-w64 (79b69d8 Azat Khuzhin) o cmake: don't define EVENT__NEED_DLLIMPORT always (fixes VS2013 static build) (49bd790 Azat Khuzhin) o Add missing return statement to del_wait_thread so libevent can build. (4f778ab Nick Mathewson) o cmake: fix building dns-example under win32 (missing getopt) (a1609a8 Azat Khuzhin) o visibility: align it to make it more readable (bb6b53d Azat Khuzhin) o cmake: Fix detection of ssize_t/SSIZE_T (7707f6b Azat Khuzhin) o Ignore more configure stuff (configure.lineno) (8d34302 Azat Khuzhin) o Fixed issue with cmake version generation (d56efd9 Mark Ellzey) o Cmake is now officially working. (7f9646d Mark Ellzey) o More cmake updates, lot's of missing definitions (49a5381 Mark Ellzey) o CMake syntax fixes fo .in files (6aad23d Mark Ellzey) o Revert "The Windows socket type is defined as SOCKET." (a264da8 Mark Ellzey) o CMAKE CMAKE CMAKE CLEANUPS (a9db46a Mark Ellzey) o Lot's of cmake updates (8b228e2 Mark Ellzey) o Provide a mechanism for building the library on Windows with different compiler flags. Add a batch file that builds it for the M[DT][d] options and performs a hunt and gather of the different output libraries. (ded8086 billsegall) o The Windows socket type is defined as SOCKET. (c9e6c3d billsegall) o autotools: fix getservbyname() detection (959a4c2 Azat Khuzhin) o Add missing for openssl_hostname_validation module (3316a21 Azat Khuzhin) o make test/regress_ssl.c compile without warnings (9f02a44 Thomas Bernard) o test/regress_be: drop debug __asm__(int3) to fix arm build (8240379 Azat Khuzhin) o event_debug_created_threadable_ctx_: fix compilation without debug mode (a068f2e Azat Khuzhin) o Add a prototype for event_disable_debug_mode() (bfcedee Sebastian Hahn) o http: eliminate warning about "socklen" in evhttp_connection_connect_() (dfad1a4 Azat Khuzhin) o Updated gitignore (1dbb55d Mark Ellzey) o Update bench_httpclient.c (cb96931 Seungmo Koo) o *fix: bench_httpclient to support win32 (4e9325e zeliard) o Commented out a WIN32 threading / timing test for now (e84e269 Mark Ellzey) o Fix mixed declarations and code (forbidden by ISO C90) (0c7f217 Thomas Bernard) o Fix "function declaration isn’t a prototype" (746d2c5 Thomas Bernard) o This fixes a bug introduced in 27bd9faf498b91923296cc91643e03ec4055c230 (19ba454 Joakim Söderberg) o changed strtotimeval signature as per #211 (bdbc823 Xiao Bao Clark) o Added cmake-generated files to ignore list. (6c12bfe Matyas Dolak) o Ignore `make dist` generated files (8a2c6c7 Azat Khuzhin) Debugging o Debug mode option to error on evthread init AFTER other event calls. (dcfb19a Mark Ellzey) Changes in version 2.1.5-beta (5 January 2015) Security Fixes (evbuffers) o Avoid integer overflow bugs in evbuffer_add() and related functions. See CVE-2014-6272 advisory for more information. (d49bc0e88b81a5812116074dc007f1db0ca1eecd) New APIs (evconnlistener) o Provide support for SO_REUSEPORT through LEV_OPT_REUSABLE_PORT (b625361 Maciej Soltysiak) Bugfixes (core) o Fix use-after-free error in EV_CLOSURE_EVENT callback (3cc0eac John Ohl) o Fix race caused by event_active (3c7d6fc vjpai) Bugfixes (evbuffer) o Fix evbuffer_peek() with len==-1 and start_at non-NULL. (ba59923) o Consistently check for failure from evbuffer_pullup() (60f8f72) o Fix evbuffer_peek() with len==-1 and start_at non-NULL. (fb7e76a) Bugfixes (windows, IOCP) o be async: avoid double close() (f133b86 Azat Khuzhin) Bugfixes (bufferevents) o Fix issue #127, double free for filterevents that use BEV_OPT_CLOSE_ON_FREE (2c82aa0 John Ohl) o make bufferevent_getwatermark api more robust (a21e510 ufo2243) o [Bugfix] fix bufferevent setwatermark suspend_read (b34e4ac ufo2243) o bufferevent_openssl: reset fd_is_set when setfd with -1 is called (3da84c2 Azat Khuzhin) o Fix compilation for older OpenSSL versions. (5c7282f Joakim Soderberg) New APIs (evhttp) o Add evhttp_connection_set_family() to set addrinfo->family for DNS requests (12c29b0 Azat Khuzhin) o Implement interface that provides the ability to have an outbound evhttp_connection free itself once all requests have completed (2b9ec4c,10fe4f John Ohl) New APIs (core) o Implement new/free for struct evutil_monotonic_timer and export monotonic time functions (f2645f8 Andrea Shepard) Bugfixes (evdns) o Load hosts file on Windows. (a0b247c Vilmos Nebehaj) o Don't truncate hosts file path on Windows. (d0dc861 Vilmos Nebehaj) o Fix a crash in evdns related to shutting down evdns (9f39c88,e8fe749) o evdns: avoid read-after-free in evdns_request_timeout_callback() (61262a0 Azat Khuzhin) o Correctly handle allocation failures in evdns_getaddrinfo (6a53d15) o evdns: fix EVDNS_BASE_DISABLE_WHEN_INACTIVE in case retransmit/retry (74d0eee Azat Khuzhin) o evdns: add retry/reissue tests for EVDNS_BASE_DISABLE_WHEN_INACTIVE (3ca9d43 Azat Khuzhin) o evdns: fail ns after we are failing/retrasmitting request (97c750d Azat Khuzhin) Bugfixes (evhttp) o http: reset connection before installing retry timer (fix http retries handling) (bc79cc5 Azat Khuzhin) Testing o regress_dns: fix leaks in getaddrinfo_async{,_cancel_stress} tests (2fdc5f2 Azat Khuzhin) o test: add family argument for http_connection_test_() (177b8a7 Azat Khuzhin) o test: add regress for evhttp_connection_set_family() with AF_INET and AF_UNSPEC (42aefeb Azat Khuzhin) o test/http: add regress test for set family to AF_INET6 (3fbf3cc Azat Khuzhin) o Update to a more recent tinytest_macros. (8da5a18) o test/regress: add simplestsignal: to track reorder bugs separately (b897bef Azat Khuzhin) o test/evbuffer_peek: add regress in case we have first buffer greater (e2d139d Azat Khuzhin) o More evbuffer_peek() test cases (154006a) o use correct tt macro for pointer compare (08c88ea) o regress_buffer: fix 'memcmp' compare size (79800df Maks Naumov) o Fix a use-after-free in unit tests. CID 752027 (3739057) o Fix a dead-code warning in unit tests. CID 1193548 (c119f24) o Use evutil_weakrand() in unit tests. (a677b72, 364c110) o Use a more precise calculation for max in time-ratelim.c (ca5b5c7) o Make a buffer larger in the tests to avoid a scary evbuffer_copyout_from() (fb57b8b) o Fix several memory leaks in the unit tests. (89c1a3b) o Add test for evhttp_connection_free_on_completion (b0e9924 John Ohl) o Fix annoying heisenbug in test-time.c (cb73704) Sample code o Make http-server.c output into good html5 (6d72bdc) o Use FindClose for handle from FindFirstFile in http-server.c (6466e88) o https-client: add -retries argument, for connection retries (d9da844 Azat Khuzhin) Bugfixes (build) o Add missing headerfile for cmake (15d90cc Trond Norbye) o ignore one more test binary (b6593aa Michael Richardson) o ignore config.cache/test-driver files (c83f333 Mike Frysinger) o add a --disable-samples configure flag (0c492b3 Mike Frysinger) o Add a few files created by "make verify" to .gitignore. (1a8295a Pierre Phaneuf) o updates in cmake build (27bd9fa Sergey Nikulov) o Fix cmake error when the Module path has more than one entry. (befbd13 Acer Yang) o Fix CMake shared library build (e69d910 Nobuaki Sukegawa) o Fix warnings when compiling with clang 3.5 (f5b4765 John Ohl) o Fix mixed declarations and code (forbidden by ISO C90) (8afbdbc Thomas Bernard) Bugfixes (miscellaneous) o tree.h: drop duplicated content of tree.h (6193187 Azat Khuzhin) o evdns: disable probing with EVDNS_BASE_DISABLE_WHEN_INACTIVE (610410b,ad0493e,fea86a6,d83b337,5ca9e97 Azat Khuzhin) o [Bugfix] fix grammer error (3a4d249 ufo2243) o Change return type of evutil_load_windows_system_library_ to HMODULE (f691389) o Fix a c90 warning (76643dd) o Fix a typo in a doxygen comment. Reported by 亦得. (be1aeff) o remove trailing comma from enum (b361b8a Jean-Philippe Ouellet) Bugfixes (FreeBSD) o Handle ENOTCAPABLE from FreeBSD - this is returned if an event in the changelist is for an FD that has been closed. (6fd7394 Adrian Chadd) Changes in version 2.1.4-alpha (21 Mar 2014) Libevent 2.1.4-alpha adds a number of new miscellaneous APIs to make Libevent more useful, including support for early close detection with epoll via EPOLLRDHUP, triggering bufferevent callbacks, adding more evhttp callbacks, and more. There are also numerous bugfixes, including a number for finalize-related issues from 2.1.3-alpha; and an alternative (non-primary!) cmake-based build mechanism. New APIs (core) o Added event_base_get_num_events() (0fa107d Mobai Zhang) o New event_base_active_by_fd API (865a142 Greg Hazel, 5c9da9a, 87fa2b0) o Add event_base_active_by_signal by analogy (4865943) o Add access to max event count stats (5173bef, efbd3dc, 26230a2 Andrew Sweeney) o Implemented EV_CLOSED event for epoll backend (EPOLLRDHUP). (b1b69ac Diego Giagio, 53d2793, 43ffcf6, dfe1e52 Marcin Juszkiewicz, ff26633 Joakim Soderberg, 3908a5e) New APIs (evutil_secure_rng) o Add evutil_secure_rng_set_urandom_device_file (2bbb5d7) New APIs (bufferevents) o Add function to fetch underlying ratelimit cfg (4b3d5af Mark Ellzey) o Pass and return const for bufferevent_get_token_bucket_cfg (1c77fbb Mark Ellzey) o Add watermark introspection (4ce242b Ondřej Kuzník) o Add an option to trigger bufferevent I/O callbacks (61ee18b Ondřej Kuzník) o Add an option to trigger bufferevent event callbacks (a7384c7 Ondřej Kuzník) o Clarifications in response to merge req. comments (bd41947 Ondřej Kuzník) o Minor optimizations on bufferevent_trigger options (a3172a4) New APIs (evhttp) o Add evhttp_connection_get_server(). (a7f82a3 Maxime Henrion) o add a http default content type option (5a5acd9 Nicolas Martyanoff) o http: implement new evhttp_connection_get_addr() api. (0c7f040 Azat Khuzhin) o Add a variant of evhttp_send_reply_chunk() with a callback on evhttp_write_buffer() (8d8decf Julien BLACHE) o Allow registering callback for parsing HTTP headers (b0bd7fe Balint Reczey) o Provide on request complete callback facility (b083ca0 Andrew Sweeney) o evhttp_request_set_on_complete_cb to be more specific about what the function actually does and usage (da86dda Andrew Sweeney) o Update unit test to make sure that the callback happens after the output data is written (b85f398 Andrew Sweeney) Features (evdns) o bug fix for issues #293 evdns_base_load_hosts doesn't remove outdated addresses (954d2f9, f03d353, 45eba6f Kuldeep Gupta) Features: (cmake build support) o Initial CMake commit. (e415196 Joakim Soderberg) o Add all tests and benchmarks to CMake project. (e9fc014 Joakim Soderberg) o More work on adding tests to CMake project (99c1dc3 Joakim Soderberg) o Generate a dummy evconfig-private.h so things build properly. (ce14def Joakim Soderberg) o Link libm on unix platforms. (58fcd42 Joakim Soderberg) o Added some GCC specific options. (19222e5 Joakim Soderberg) o Use evutil_closesocket instead. (dbf2b51 Joakim Soderberg) o Add copyright and licensing files for CMake modules. (c259d53 Joakim Soderberg) o Only include WIN32 getopt where it is used. (9bbce0b Joakim Soderberg) o Fix bench_cascade program on Windows. (78da644 Joakim Soderberg) o Don't segfault on no found event backend. (8f2af50 Joakim Soderberg) o Only test the event backends available on the system. (7ea4159 Joakim Soderberg) o Added a "make verify" target. (e053c4f Joakim Soderberg) o Fix the make "verify" target on Windows. (67e5d74 Joakim Soderberg) o Get rid of deprecation warnings for OpenSSL on OSX 10.7+ (69c3516 Joakim Söderberg) o Fix kqueue support. (a831f2f Joakim Söderberg) o Added a test for testing if kqueue works with pipes. (2799b35 Joakim Söderberg) o Change the BSD license from 4 to 3-clause. (86df3ed Joakim Soderberg) o Minimum required python version is 2.4. (968e97b Joakim Soderberg) o Get rid of unknown pragma warnings. (0ef1d04 Joakim Soderberg) o Add a "make verify_coverage" target generation coverage info. (f2483f8 Joakim Soderberg) o Fix the "make verify" target on NetBSD (4ac086a Joakim Soderberg) o Only look for ZLib when it is used (if tests are included). (f780593 Joakim Soderberg) o Added EVENT__ENABLE_GCC_WARNINGS, turns all warnings into errors. (dd413bd Joakim Soderberg) o Add CMake config and install targets. (f3446ed Joakim Soderberg) o Fix typo (4b754df Joakim Soderberg) o Some work on making it possible to simply do add_subdirectory() on the project. (49ab363 Joakim Soderberg) o Set USE_DEBUG=1 on EVENT__ENABLE_VERBOSE_DEBUG (fd42e70 Joakim Soderberg) o Fix so that old nmake project still builds. (24d6466 Joakim Soderberg) o Rename README to README.md and use markdown to format. (d2bc39a Joakim Soderberg) o Update README with CMake build instructions. (604b8cc Joakim Soderberg) o Clean up the README some. (8d4cb35 JoakimSoderberg) o Forgotten headers for old nmake project compatability. (8697b99 Joakim Soderberg) o Change all uses of WIN32 to _WIN32 (4e14395 Joakim Söderberg) o Fix include bug. (2024467 Joakim Söderberg) o Check if we're on OSX before disabling deprecation in le-proxy (8b40a5b Joakim Söderberg) o Fix broken autotools build. (ae1bd82 Joakim Söderberg) o Disclaimerize cmake a little in the README (d03b5bf) o Fix CMake compile when OpenSSL is disabled. (e423d42 Joakim Söderberg) o CMake: Get rid of python not found warning when regress tests turned off. (d38d798 Joakim Söderberg) o Fix https-client compilation on Windows. (d7be788 Joakim Soderberg) o Guard against EVENT_NOWIN32 being set during testing. (f1715b4 Joakim Soderberg) o Check for OSX when checking for clang. (e212c54 Joakim Soderberg) o Added a Travis-CI configuration file. (8c0f0a9 Joakim Soderberg) o Added -Qunused-arguments for clang on macosx (ed99d92 Trond Norbye) o Rename event_extras to event_extra (a0dd5df Trond Norbye) o Add option to build shared library (4545fa9 Trond Norbye) o Add -Qunused-arguments for clang on macos (b56611d Trond Norbye) o Add cmake-related files to .gitignore (e061321 Trond Norbye) o Export event_extra not event_extras. (2b41bcf Joakim Söderberg) Bugfixes (core) o If evsel->del() fails, don't leave the evmap in an inconsistent state (9b5a527 Maxime Henrion) o Move event_debug_note_teardown_ before mm_free. (69b5c64) o Check CLOCK_MONOTONIC_* at runtime if needed. (911abf3) o Fix reinit of fds with EV_WRITE but not EV_READ. (ebfd8a8 maksqwe) o Tweaked callbacks to prevent race condition (https://github.com/libevent/libevent/issues/104) (40830f1, 2ea15ed John Ohl) o Move assert(ev) to before we use ev in EV_CLOSURE_EVENT_FINALIZE case (9805972) Bugfixes (evhttp) o Fix a double close() bug in evhttp when the underlying bufferevent uses BEV_OPT_CLOSE_ON_FREE. (31db8a0 Maxime Henrion) o Fix an unlikely but possible error case for http connections (f22049e) o Avoid racy bufferevent activation (5eb1788 Nate Rosenblum) Bugfixes on 2.0 (Windows) o Use windows vsnprintf fixup logic on all windows environments (e826f19) o libevent/win32_dealloc() : fix sizeof(pointer) vs sizeof(*pointer) (b8f5980 Frank Denis) Bugfixes (evutil_secure_rng) o When we seed from /proc/sys/kernel/random/uuid, count it as success (e35b540) o We should return after arc4random_buf() (1ea1f26 Makoto Kato) o Avoid other RNG initialization FS reads when urandom file is specified (9695e9c) o Really remove RNG seeds from the stack (f5ced88) o Fix another arc4random_buf-related warning (e64a2b0) Bugfixes (bufferevents) o Initialize async bufferevent timeout CBs unconditionally (af9b2a7) Bugfixes (evdns) o Checking request nameserver for NULL, before using it. (5c710c0 Belobrov Andrey) o Fix SEGFAULT after evdns_base_resume if no nameservers installed. (14971a8 Azat Khuzhin) o Actually use the log facility for reporting evdns problems. (e1766a1) o Fix SEGFAULT after evdns_base_resume if no nameservers installed. (f8d7df8 Azat Khuzhin) o fix for ServFail from RIPE Atlas release (62f596b Antony Antony) Bugfixes (compilation) o Fix test compilation with nmake: add the gdi.lib dependency (5ba8ab7) o Whoops. It is gdi.lib, not gdi32.lib. (github issue #61) (8ab612e) o Don't use return since return type is void and build error occurs using clang (838161d Makoto Kato) o Use void casts to suppress some "unchecked return value" warns (7080d55) o rpcgen: Generate regress.gen.[c,h] in build rather than src dir (243386c Ross Lagerwall) o Fix a compiler warning when checking for arc4random_buf linker breakage. (5cb3865) o Fix 'make distcheck' by adding regress.gen.[ch] to DISTCLEANFILES (239d834) o Fix a c90 warning (c207682) o Fix consts in WIN32-Code/getopt*.[ch] (57abb35) Bugfixes (locks, synchronization) o Missed lock acquire/release in event_base_cancel_single_callback_() (d3d999a Azat Khuzhin) o Fix locking in bufferevent_get_options_(). (dbc9cd4 Maxime Henrion) Bugfixes (leaks) o Avoid leaking segment mappings when offset is not a page multiple (d409514) Testing o Add tests for evdns_base_resume(). (1cd9ff5 Azat Khuzhin) o Fix dns/leak_resume_send_err test. (7e876df Azat Khuzhin) o Add checks for evhttp_connection_get_server() in unit tests. (fbc323b Maxime Henrion) o Fix a (failure-only) null dereference in the unit tests (1104d0b) o Fix a logic error in test_evbuffer_freeze (7765884) o Add missing check to test_evbuffer_file_segment_add_cleanup_cb (eba4506) o Fix some crash-on-fail cases in DNS regression tests (87cd6f0) o DNS tests: add a missing check (f314900) o Finalize tests: add a missing check (82b6956) o test_evutil_rtrim: add another missing check. (e193c95) o regress_main: logging all if env EVENT_DEBUG_LOGGING_ALL isset (611e28b Azat Khuzhin) o regress_http: add tests for evhttp_connection_get_addr() (4dd500c Azat Khuzhin) o Update to the latest version of tinytest (7a80476) o Heap-allocate zlib data structure in regress_zlib tests (4947c18) Performance tweaks (core) o Avoid redundant syscall to make a nonblocking socket nonblocking (42c03da Maxime Henrion) o Avoid redundant syscall if making a socket cloexec twice (1f29b18) o Avoid redundant invocations of init_extension_functions for IOCP (3b77d62) Documentation o Document that arc4random is not a great cryptographic PRNG. (6e49696) o Small doxygen tweaks (6e67b51) o Try another doxygen tweak (ccf432b) o Clarify event_base_loop exit conditions (031a803) o Fix a typo (be7bf2c Ondřej Kuzník) o Document deferred eventcb behaviour (13a9a02 Ondřej Kuzník) o Typo fixes from Linus Nordberg (cec62cb, 8cd695b) o Fix duplicate paragraph in evbuffer_ptr documentation (58408ee) Code Improvements (coverity) o Fix a pile of coverity warnings in the unit tests (867f401) o Fix coverity warnings in benchmark tools. (ff7f739) o Whoops; fix compilation in bench.c (544cf88) o Remove spurious checks in evrpc.c error cases (coverity) (991b362) o Fix a couple of compilation warnings in regress_http.c (860767e) o Fix even more coverity warnings. (d240328) o Stop checking for inet_aton; we don't use it. (f665d5c) o Add an include to evrpc-internal to fix openbsd compilation warning (5e161c6) Cleanups o Remove an unreachable return statement in minheap-internal.h (e639a9e) o Refactor evmap_{io,signal}_active_() to tolerate bad inputs (974c60e) o Fix needless bufferevent includes in evdns.c (254c04e) o Fix a couple of "#ifdef WIN32" instances (88ecda3) o Remove unneeded declaration in bufferevent-internal.h (4c8ebcd) Sample code o le-proxy: Fail more gracefully if opening listener fails (44b2491) o http-server: drop uri_root from base_url in http-server. (6171e1c Azat Khuzhin) o https-client: POST supported, args supported (c5887f7 Alexey Ozeritsky) o https-client: code cleanup (29af65e Alexey Ozeritsky) o https-client: Small tweaks to https-client.c (90786eb) o https-client: Set hostname for SNI extension (by f69m) (d1976f8) o https-client: add a cast to https-client.c (462e6b6) Changes in version 2.1.3-alpha (1 May 2013) Libevent 2.1.3-alpha fixes various bugs, adds new unit tests, and cleans up the code in a couple of places. It has a new callback in evhttp for reporting errors during a request, a new feature for allowing evdns to not keep the event_base looping when there are no requests inflight, and example code for writing an https client. Libevent 2.1.3-alpha also has an important new (experimental) event finalization feature to allow safe event teardown in multithreaded programs. This ought to fix the longstanding bug with deadlocks in multithreaded use of SSL-based bufferevents that some people have been experiencing since Libevent 2.0. Core (event finalization) o Implement event_finalize() and related functions to avoid certain deadlocks (8eedeab) o Use finalization feature so bufferevents can avoid deadlocks (02fbf68) o Always run pending finalizers when event_base_free() is called (e9ebef8) o Remove bufferevent_del_generic_timeout_cbs as now unused (4ea4c6a) o More documentation for finalization feature (a800b91) o Make the event_finalize* functions return an error code (5d11f4f) o Mark the finalize stuff as experiemental in case it needs to change (23e2e29) Evdns o evdns: New flag to make evdns not prevent the event loop from exiting (6b7fa62 Azat Khuzhin) Bugfixes (Core) o Make event_remove_timer behave correctly with persistent timers (5623e80) o Unit test for event_remove_timer with EV_PERSIST. (96150dd) o Double-check next timeout when adding events (9443868 Nate Rosenblum) o event_base_update_cache_time should be a no-op if the loop isn't running (5e6fa2a) Bugfixes (evhttp, crash fix, from 2.0) o fix #73 and fix http_connection_fail_test to catch it (b618204 Greg Hazel) Bugfixes (compilation and portability, from 2.0) o Fix compilation with WIN32_HAVE_CONDITION_VARIABLES enabled (7e45739) o Fix missing AC_PROG_SED on older Autoconfs (9ab2b3f Tay Ray Chuan) o Backport libevent to vanilla Autoconf 2.59 (as used in RHEL5) (74d4c44 Kevin Bowling) o Use AC_CONFIG_HEADERS in place of AM_CONFIG_HEADERS for autmake 1.13 compat (817ea36) o Rename configure.in to configure.ac to appease newer autoconfs (0c79787) o Avoid using top_srcdir in TESTS: new automakes do not like this (a55514e) Bugfixes (resource leaks/lock errors on error, from 2.0) o Avoid leaking fds on evconnlistener with no callback set (69db261) o Avoid double-close on getsockname error in evutil_ersatz_socketpair (0a822a6) o Fix a locking error in bufferevent_socket_get_dns_error. (0a5eb2e) Documentation Fixes (from 2.0) o Fix a mistake in evbuffer_remove() arguments in example http server code (c322c20 Gyepi Sam) o Fix a typo in a comment in buffer.h. Spotted by Alt_F4 (773b0a5) Documentation Fixes o minor documentation typos (809586a Patrick Pelletier) o Fix cut-and-paste err in whatsnew-2.1 (49905ac) o Fix comment to refer to sample/include.am correctly (9e8cdf3 Sebastian Hahn) o Fix typo : Dispatching instead of Dispaching (0c2bacc Volker Lendecke) o fix some hinky indentation in evhttp_make_request (80e220e Patrick Pelletier) o "buffer" spelling (a452811 Patrick Pelletier) o Specify return behavior in header for evbuffer_pullup() in corner case (cf8d1cd Dan Petro) o Clarify an important point about event_base_foreach_event() (920a5e6) Compilation Fixes/Tool Support o avoid valgrind false positive by zeroing epoll_event (1258614 Patrick Pelletier) o Fix harmless clang enum warning (b452a43 Sebastian Hahn) o remove all exes on "make clean", not just regress.exe (974bfa0 Patrick Pelletier) o Make --disable-libevent-regress work again (787fd74) o Do not build strlcpy.c when it will have no code. (4914620) Portability Fixes o When EWOULDBLOCK is not EAGAIN, treat it as equivalent to it (bf7a0ff) o Preliminary changes for Minix3. (0dda56a Nicholas Heath) o Use AC_CONFIG_HEADERS in place of AM_CONFIG_HEADERS for autmake 1.13 compat (bf278b) o Avoid using $(top_srcdir) in TESTS. (2863c83) o build test/test-script.sh on systems with a less-featureful $< (f935e21) o Implement EVUTIL_ERR_IS_EAGAIN on windows. (42aaf4d) Evhttp changes: o Fix ipv6 support for http. When URL contain domain, not IP address. (71e709c Azat Khuzhin) o uri decode: fix for warning "use of uninitialised value" (64b6ece Azat Khuzhin) o uri decode: changed the test for the existence of the next character (e1903e3 Azat Khuzhin) o Move prototype of evhttp_decode_uri_internal() to http-internal.h (de8101a Azat Khuzhin) o Test: decoding just part of string with evhttp_decode_uri_internal() (1367653 Azat Khuzhin) o Add new error_cb for actual reporting of HTTP request errors. (7b07719 Azat Khuzhin) o Add test for EVREQ_HTTP_REQUEST_CANCEL into http_cancel_test() (862c217 Azat Khuzhin) o Drop extra header http_struct.h from regress_http.c (54cc800 Azat Khuzhin) Testing o Add regress test ipv6_for_domain. (9ec88bd Azat Khuzhin) o Add an environment variable (EVENT_DEBUG_MODE) to run unit tests in debug mode (2fad0f3) o Add a test with an active_later event at event_base_free time. (1c3147f) o Make all tests pass under EVENT_DEBUG_MODE=1 (b1b054f) o Add some verbose notes to bufferevent unit tests (9d893c9) o New test for active_later->active transition on event_active (a153874) o New tests for event_base_foreach_event() (0b096ef) o Unit tests for event_base_gettimeofday_cached() and event_base_update_cache_time() (30ea291) o A test for event_get_assignment() (f09629e) o More unit tests for initializing common timeouts. (d596739) o Fix a bug in the new main/event_foreach test (702c9aa) Windows: o use FormatMessage for winsock errors (0c6ec5d, 2078e9b, 4ccdd53, c9ad3af Patrick Pelletier) o a program to print out the error strings for winsock errors (7296512 Patrick Pelletier) o Fix a warning introduced in 0c6ec5d8 (eeb700c) o Fix another warning introduced in 0c6ec5d8 (ed26561) Examples (http) o Add sample/https-client.c, an example of stacking evhttp as a client on top of bufferevent_ssl. (be46c99 Catalin Patulea) o use ${OPENSSL_LIBS} instead of -lssl -lcrypto (bf31fa5 Patrick Pelletier) o https-client was putting newlines at 256-byte boundaries (42d7441 Patrick Pelletier) o better handling of OpenSSL errors (5754d96 Patrick Pelletier) o use Debian's default root certificate location (aacd674 Patrick Pelletier) o use iSECPartners code to validate hostname in certificate (64d9f16 Patrick Pelletier) o avoid sign mismatch warning in openssl_hostname_validation.c (6021cb5 Patrick Pelletier) o pull in wildcard matching code from cURL (4db9da6 Patrick Pelletier) o Another tweak to https-client.c (95acdaa) o Remove http_struct.h usage in sample/https-client.c (8a90a85) Changes in version 2.1.2-alpha (18 Nov 2012) Libevent 2.1.2-alpha includes more portable for monotonic timers, refactors much of Libevent's internal and external infrastructure, closes some longstanding gaps in the interface, makde other improvements. Ths log below tries to organize features by rough area of effect. It omits a few commits which were pure bugfixes on other commits listed below. For more detail, see the git changelogs. For more insight, see the "whatsnew-2.1.txt" document included in the Libevent 2.1.2-alpha distribution. Libevent 2.1.2-alpha also includes all changes made in 2.0.19-stable through 2.0.21-stable inclusive. Performance (core): o Replace pipe-based notification with EVFILT_USER where possible. This should make multithreaded programs on OSX and *BSD alert the main thread a little faster. (53a07fe) o Make th_base_lock nonrecursive. (9cd5acb) New/Changed API Functions: o New event_get_priority() function to return an event's priority (f90e255) o Add a bufferevent_get_priority() function (bd39554) o Add an event_base_loopcontinue() to tell Libevent to rescan for more events right away (7d6aa5e) o Add a new callback to get called on evbuffer_file_segment free (e9f8feb yangacer, 64051b9) o Expose event_base_foreach_event() as a public API. (84fd6d7 Roman Puls, 232055e, ffe1643) o Add an event_remove_timer() to remove timer on an event without deleting it (e3b2e08) o Make bufferevent_set_timeouts(bev, NULL, NULL) have plausible semantics (9dee36b) o Rename event_enable_lock_debuging() to ..._debugging(). (The old name should still work.) (07e132e) o Add missing implementation for event_enable_debug_logging (3b3e21d) PORTABLE MONOTONIC TIMERS: Libevent 2.1.2 includes internal support for monotonic timers on (nearly) all supported platforms, including Windows, and OSX. Libevent applications should now be more resilient to jumps forwards or backwards in the system clock. Also, on Linux systems with epoll, we now optionally support microsecond-level timeouts (whereas epoll only supports millisecond-precision timeouts). o Use mach_absolute_time() for monotonic clock support on OSX. (b8fd6f9) o Do not track use_monotonic field when is no monotonic clock (cb653a0) o EVENT_BASE_FLAG_PRECISE_TIMER indicates we want fine timer precision (ddd69d3) o On Linux, use CLOCK_MONOTONIC_COARSE by default (55780a7) o Implement a GetTickCount-based monotonic timer for Windows (d5e1d5a) o Refactor monotonic timer handling into a new type and set of functions; add a gettimeofday-based ratcheting implementation (f5e4eb0) o Add EVENT_PRECISE_TIMER environment var for selecting precise-but-slow timer (a2598ec) o Implement fast/precise monotonic clocks on Windows (2c47045) o Simple unit tests for monotonic timers (630f077) o Improve the monotonic-time unit test: make it check the step size (7428c78) o When PRECISE_TIMERS is set with epoll, use timerfd for microsecond precision (26c7582) o Split out time-related evutil functions into a new evutil_time.c (c419485) o Split out time-related prototypes into time-internal.h (71bca50) o Add evutil_time.obj to Makefile.nmake (0ba0683) o Avoid giving a spurious warning when timerfd support is unavailable (1aaf9f0 Dave Hart) o Make test_evutil_monotonic a little more tolerant (def3b83) o Avoid unused-var warning on systems with clock_gettime but without CLOCK_MONOTONIC_COARSE (9be5468) EVENT_BASE_ONCE LEAKS: If a callback added by event_base_once() is never invoked, Libevent no longer leaks internal memory. o Free dangling event_once objects on event_base_free() (c17dd59) o Add a unit test in which an event is created with event_base_once() but never fires (4343edf) TESTING SUPPORT, FIXES AND IMPROVEMENTS: Libevent now disables by default its unit tests that would touch the network, or that tend to fail on heavily-loaded systems. To re-enable them, invoke the ./test/regress program with the @@all alias. o Simplify test.sh code significantly. (9b856fd Ross Lagerwall) o Make all tests that hit the network disabled by default (f2cea87) o Avoid a resource leak on error in http client benchmark (ea92fba) o Update to latest tinytest (911b4f0349377) (ef7c4f7) o Avoid (unlikely) overflow in bench_httpclient.c (5671033) o Shave 700 msec off the persistent_timeout_jump test (21205b8) o Check return value of write() in regress.c (c8009d2) o Make load-dependent monotonic timer tests off-by-default (2b6fe8b) o Add deferred_cb_skew to list of timing-dependent tests (34c8f31) o Avoid test -e; older shs don't have one. (f1bd938) o Fix renegotiation test to work around openssl 1.0.1 bug (c2f3086) o Fix a couple of compile warnings in the unit tests (5a9a014) MISC: o Change evutil_weakrand_() to avoid platform random() (e86af4b Nicholas Marriott, 3aa4415) INFRASTRUCTURE (Active-later events): As a simplification and optimization to Libevent's "deferred callback" logic (introduced in 2.0 to avoid callback recursion), Libevent now treats all of its deferrable callback types using the same logic it uses for active events. Now deferred events no longer cause priority inversion, no longer require special code to cancel them, and so on. o Refactor the callback part of an event into its own event_callback type (cba59e5) o Add "active later" event_callbacks to supersede deferred (745a63d) o event_base_assert_ok: check value of event_active_count for correctness (fec8bae) o Replace deferred_cbs with event_callback-based implementation. (ae2b84b) o Replace more deferred_cb names with event_callback (a4079aa) o Give event_base_process_active a single exit path (581b5be) o Restore our priority-inversion-prevention code with deferreds (c0e425a) o Refactor event_persist_closure: raise and extract some common logic (bec22b4) o Remove the unused bits from EVLIST_ALL (9889a3d) ||||||| merged common ancestors @ text @@ 1.1.1.1.4.1 log @file whatsnew-2.1.txt was added on branch bouyer-socketcan on 2017-04-21 16:51:32 +0000 @ text @d1 768 @ 1.1.1.1.4.2 log @Sync with HEAD @ text @a0 768 What's new in Libevent 2.1 Nick Mathewson 0. Before we start 0.1. About this document This document describes the key differences between Libevent 2.0 and Libevent 2.1, from a user's point of view. It's a work in progress. For better documentation about libevent, see the links at http://libevent.org/ Libevent 2.1 would not be possible without the generous help of numerous volunteers. For a list of who did what in Libevent 2.1, please see the ChangeLog! NOTE: I am very sure that I missed some thing on this list. Caveat haxxor. 0.2. Where to get help Try looking at the other documentation too. All of the header files have documentation in the doxygen format; this gets turned into nice HTML and linked to from the libevent.org website. There is a work-in-progress book with reference manual at http://www.wangafu.net/~nickm/libevent-book/ . You can ask questions on the #libevent IRC channel at irc.oftc.net or on the mailing list at libevent-users@@freehaven.net. The mailing list is subscribers-only, so you will need to subscribe before you post. 0.3. Compatibility Our source-compatibility policy is that correct code (that is to say, code that uses public interfaces of Libevent and relies only on their documented behavior) should have forward source compatibility: any such code that worked with a previous version of Libevent should work with this version too. We don't try to do binary compatibility except within stable release series, so binaries linked against any version of Libevent 2.0 will probably need to be recompiled against Libevent 2.1.4-alpha if you want to use it. It is probable that we'll break binary compatibility again before Libevent 2.1 is stable. 1. New APIs and features 1.1. New ways to build libevent We now provide an --enable-gcc-hardening configure option to turn on GCC features designed for increased code security. There is also an --enable-silent-rules configure option to make compilation run more quietly with automake 1.11 or later. You no longer need to use the --enable-gcc-warnings option to turn on all of the GCC warnings that Libevent uses. The only change from using that option now is to turn warnings into errors. For IDE users, files that are not supposed to be built are now surrounded with appropriate #ifdef lines to keep your IDE from getting upset. There is now an alternative cmake-based build process; cmake users should see the relevant sections in the README. 1.2. New functions for events and the event loop If you're running Libevent with multiple event priorities, you might want to make sure that Libevent checks for new events frequently, so that time-consuming or numerous low-priority events don't keep it from checking for new high-priority events. You can now use the event_config_set_max_dispatch_interval() interface to ensure that the loop checks for new events either every N microseconds, every M callbacks, or both. When configuring an event base, you can now choose whether you want timers to be more efficient, or more precise. (This only has effect on Linux for now.) Timers are efficient by default: to select more precise timers, use the EVENT_BASE_FLAG_PRECISE_TIMER flag when constructing the event_config, or set the EVENT_PRECISE_TIMER environment variable to a non-empty string. There is an EVLOOP_NO_EXIT_ON_EMPTY flag that tells event_base_loop() to keep looping even when there are no pending events. (Ordinarily, event_base_loop() will exit as soon as no events are pending.) Past versions of Libevent have been annoying to use with some memory-leak-checking tools, because Libevent allocated some global singletons but provided no means to free them. There is now a function, libevent_global_shutdown(), that you can use to free all globally held resources before exiting, so that your leak-check tools don't complain. (Note: this function doesn't free non-global things like events, bufferevents, and so on; and it doesn't free anything that wouldn't otherwise get cleaned up by the operating system when your process exit()s. If you aren't using a leak-checking tool, there is not much reason to call libevent_global_shutdown().) There is a new event_base_get_npriorities() function to return the number of priorities set in the event base. Libevent 2.0 added an event_new() function to construct a new struct event on the heap. Unfortunately, with event_new(), there was no equivalent for: struct event ev; event_assign(&ev, base, fd, EV_READ, callback, &ev); In other words, there was no easy way for event_new() to set up an event so that the event itself would be its callback argument. Libevent 2.1 lets you do this by passing "event_self_cbarg()" as the callback argument: struct event *evp; evp = event_new(base, fd, EV_READ, callback, event_self_cbarg()); There's also a new event_base_get_running_event() function you can call from within a Libevent callback to get a pointer to the current event. This should never be strictly necessary, but it's sometimes convenient. The event_base_once() function used to leak some memory if the event that it added was never actually triggered. Now, its memory is tracked in the event_base and freed when the event_base is freed. Note however that Libevent doesn't know how to free any information passed as the callback argument to event_base_once is still something you'll might need a way to de-allocate yourself. There is an event_get_priority() function to return an event's priority. By analogy to event_base_loopbreak(), there is now an event_base_loopcontinue() that tells Libevent to stop processing active event callbacks, and re-scan for new events right away. There's a function, event_base_foreach_event(), that can iterate over every event currently pending or active on an event base, and invoke a user-supplied callback on each. The callback must not alter the events or add or remove anything to the event base. We now have an event_remove_timer() function to remove the timeout on an event while leaving its socket and/or signal triggers unchanged. (If we were designing the API from scratch, this would be the behavior of "event_add(ev, NULL)" on an already-added event with a timeout. But that's a no-op in past versions of Libevent, and we don't want to break compatibility.) You can use the new event_base_get_num_events() function to find the number of events active or pending on an event_base. To find the largest number of events that there have been since the last call, use event_base_get_max_events(). You can now activate all the events waiting for a given fd or signal using the event_base_active_by_fd() and event_base_active_by_signal() APIs. On backends that support it (currently epoll), there is now an EV_CLOSED flag that programs can use to detect when a socket has closed without having to read all the bytes until receiving an EOF. 1.3. Event finalization 1.3.1. Why event finalization? Libevent 2.1 now supports an API for safely "finalizing" events that might be running in multiple threads, and provides a way to slightly change the semantics of event_del() to prevent deadlocks in multithreaded programs. To motivate this feature, consider the following code, in the context of a mulithreaded Libevent application: struct connection *conn = event_get_callback_arg(ev); event_del(ev); connection_free(conn); Suppose that the event's callback might be running in another thread, and using the value of "conn" concurrently. We wouldn't want to execute the connection_free() call until "conn" is no longer in use. How can we make this code safe? Libevent 2.0 answered that question by saying that the event_del() call should block if the event's callback is running in another thread. That way, we can be sure that event_del() has canceled the callback (if the callback hadn't started running yet), or has waited for the callback to finish. But now suppose that the data structure is protected by a lock, and we have the following code: void check_disable(struct connection *connection) { lock(connection); if (should_stop_reading(connection)) event_del(connection->read_event); unlock(connection); } What happens when we call check_disable() from a callback and from another thread? Let's say that the other thread gets the lock first. If it decides to call event_del(), it will wait for the callback to finish. But meanwhile, the callback will be waiting for the lock on the connection. Since each threads is waiting for the other one to release a resource, the program will deadlock. This bug showed up in multithreaded bufferevent programs in 2.1, particularly when freeing bufferevents. (For more information, see the "Deadlock when calling bufferevent_free from an other thread" thread on libevent-users starting on 6 August 2012 and running through February of 2013. You might also like to read my earlier writeup at http://archives.seul.org/libevent/users/Feb-2012/msg00053.html and the ensuing discussion.) 1.3.2. The EV_FINALIZE flag and avoiding deadlock To prevent the deadlock condition described above, Libevent 2.1.3-alpha adds a new flag, "EV_FINALIZE". You can pass it to event_new() and event_assign() along with EV_READ, EV_WRITE, and the other event flags. When an event is constructed with the EV_FINALIZE flag, event_del() will not block on that event, even when the event's callback is running in another thread. By using EV_FINALIZE, you are therefore promising not to use the "event_del(ev); free(event_get_callback_arg(ev));" pattern, but rather to use one of the finalization functions below to clean up the event. EV_FINALIZE has no effect on a single-threaded program, or on a program where events are only used from one thread. There are also two new variants of event_del() that you can use for more fine-grained control: event_del_noblock(ev) event_del_block(ev) The event_del_noblock() function will never block, even if the event callback is running in another thread and doesn't have the EV_FINALIZE flag. The event_del_block() function will _always_ block if the event callback is running in another thread, even if the event _does_ have the EV_FINALIZE flag. [A future version of Libevent may have a way to make the EV_FINALIZE flag the default.] 1.3.3. Safely finalizing events To safely tear down an event that may be running, Libevent 2.1.3-alpha introduces event_finalize() and event_free_finalize(). You call them on an event, and provide a finalizer callback to be run on the event and its callback argument once the event is definitely no longer running. With event_free_finalize(), the event is also freed once the finalizer callback has been invoked. A finalized event cannot be re-added or activated. The finalizer callback must not add events, activate events, or attempt to "resucitate" the event being finalized in any way. If any finalizer callbacks are pending as the event_base is being freed, they will be invoked. You can override this behavior with the new function event_base_free_nofinalize(). 1.4. New debugging features You can now turn on debug logs at runtime using a new function, event_enable_debug_logging(). The event_enable_lock_debugging() function is now spelled correctly. You can still use the old "event_enable_lock_debuging" name, though, so your old programs shouldnt' break. There's also been some work done to try to make the debugging logs more generally useful. 1.5. New evbuffer functions In Libevent 2.0, we introduced evbuffer_add_file() to add an entire file's contents to an evbuffer, and then send them using sendfile() or mmap() as appropriate. This API had some drawbacks, however. Notably, it created one mapping or fd for every instance of the same file added to any evbuffer. Also, adding a file to an evbuffer could make that buffer unusable with SSL bufferevents, filtering bufferevents, and any code that tried to read the contents of the evbuffer. Libevent 2.1 adds a new evbuffer_file_segment API to solve these problems. Now, you can use evbuffer_file_segment_new() to construct a file-segment object, and evbuffer_add_file_segment() to insert it (or part of it) into an evbuffer. These segments avoid creating redundant maps or fds. Better still, the code is smart enough (when the OS supports sendfile) to map the file when that's necessary, and use sendfile() otherwise. File segments can receive callback functions that are invoked when the file segments are freed. The evbuffer_ptr interface has been extended so that an evbuffer_ptr can now yield a point just after the end of the buffer. This makes many algorithms simpler to implement. There's a new evbuffer_add_buffer() interface that you can use to add one buffer to another nondestructively. When you say evbuffer_add_buffer_reference(outbuf, inbuf), outbuf now contains a reference to the contents of inbuf. To aid in adding data in bulk while minimizing evbuffer calls, there is an evbuffer_add_iovec() function. There's a new evbuffer_copyout_from() variant function to enable copying data nondestructively from the middle of a buffer. evbuffer_readln() now supports an EVBUFFER_EOL_NUL argument to fetch NUL-terminated strings from buffers. There's a new evbuffer_set_flags()/evbuffer_clear_flags() that you can use to set EVBUFFER_FLAG_DRAINS_TO_FD. 1.6. New functions and features: bufferevents You can now use the bufferevent_getcb() function to find out a bufferevent's callbacks. Previously, there was no supported way to do that. The largest chunk readable or writeable in a single bufferevent callback is no longer hardcoded; it's now configurable with the new functions bufferevent_set_max_single_read() and bufferevent_set_max_single_write(). For consistency, OpenSSL bufferevents now make sure to always set one of BEV_EVENT_READING or BEV_EVENT_WRITING when invoking an event callback. Calling bufferevent_set_timeouts(bev, NULL, NULL) now removes the timeouts from socket and ssl bufferevents correctly. You can find the priority at which a bufferevent runs with bufferevent_get_priority(). The function bufferevent_get_token_bucket_cfg() can retrieve the rate-limit settings for a bufferevent; bufferevent_getwatermark() can return a bufferevent's current watermark settings. You can manually trigger a bufferevent's callbacks via bufferevent_trigger() and bufferevent_trigger_event(). Also you can manually increment/decrement reference for bufferevent with bufferevent_incref()/bufferevent_decref(), it is useful in situations where a user may reference the bufferevent somewhere else. Now bufferevent_openssl supports "dirty" shutdown (when the peer closes the TCP connection before closing the SSL channel), see bufferevent_openssl_get_allow_dirty_shutdown() and bufferevent_openssl_set_allow_dirty_shutdown(). And also libevent supports openssl 1.1. 1.7. New functions and features: evdns The previous evdns interface used an "open a test UDP socket" trick in order to detect IPv6 support. This was a hack, since it would sometimes badly confuse people's firewall software, even though no packets were sent. The current evdns interface-detection code uses the appropriate OS functions to see which interfaces are configured. The evdns_base_new() function now has multiple possible values for its second (flags) argument. Using 1 and 0 have their old meanings, though the 1 flag now has a symbolic name of EVDNS_BASE_INITIALIZE_NAMESERVERS. A second flag is now supported too: the EVDNS_BASE_DISABLE_WHEN_INACTIVE flag, which tells the evdns_base that it should not prevent Libevent from exiting while it has no DNS requests in progress. There is a new evdns_base_clear_host_addresses() function to remove all the /etc/hosts addresses registered with an evdns instance. Also there is evdns_base_get_nameserver_addr() for retrieve the address of the 'idx'th configured nameserver. 1.8. New functions and features: evconnlistener Libevent 2.1 adds the following evconnlistener flags: LEV_OPT_DEFERRED_ACCEPT -- Tells the OS that it doesn't need to report sockets as having arrived until the initiator has sent some data too. This can greatly improve performance with protocols like HTTP where the client always speaks first. On operating systems that don't support this functionality, this option has no effect. LEV_OPT_REUSEABLE_PORT -- Indicates that we ask to allow multiple servers to bind to the same port if they each set the option Ionly on Linux and >=3.9) LEV_OPT_DISABLED -- Creates an evconnlistener in the disabled (not listening) state. Libevent 2.1 changes the behavior of the LEV_OPT_CLOSE_ON_EXEC flag. Previously, it would apply to the listener sockets, but not to the accepted sockets themselves. That's almost never what you want. Now, it applies both to the listener and the accepted sockets. 1.9. New functions and features: evhttp ********************************************************************** NOTE: The evhttp module will eventually be deprecated in favor of Mark Ellzey's libevhtp library. Don't worry -- this won't happen until libevhtp provides every feature that evhttp does, and provides a compatible interface that applications can use to migrate. ********************************************************************** Previously, you could only set evhttp timeouts in increments of one second. Now, you can use evhttp_set_timeout_tv() and evhttp_connection_set_timeout_tv() to configure microsecond-granularity timeouts. Also there is evhttp_connection_set_initial_retry_tv() to change initial retry timeout. There are a new pair of functions: evhttp_set_bevcb() and evhttp_connection_base_bufferevent_new(), that you can use to configure which bufferevents will be used for incoming and outgoing http connections respectively. These functions, combined with SSL bufferevents, should enable HTTPS support. There's a new evhttp_foreach_bound_socket() function to iterate over every listener on an evhttp object. Whitespace between lines in headers is now folded into a single space; whitespace at the end of a header is now removed. The socket errno value is now preserved when invoking an http error callback. There's a new kind of request callback for errors; you can set it with evhttp_request_set_error_cb(). It gets called when there's a request error, and actually reports the error code and lets you figure out which request failed. You can navigate from an evhttp_connection back to its evhttp with the new evhttp_connection_get_server() function. You can override the default HTTP Content-Type with the new evhttp_set_default_content_type() function There's a new evhttp_connection_get_addr() API to return the peer address of an evhttp_connection. The new evhttp_send_reply_chunk_with_cb() is a variant of evhttp_send_reply_chunk() with a callback to be invoked when the chunk is sent. The evhttp_request_set_header_cb() facility adds a callback to be invoked while parsing headers. The evhttp_request_set_on_complete_cb() facility adds a callback to be invoked on request completion. You can add linger-close for http server by passing EVHTTP_SERVER_LINGERING_CLOSE to evhttp_set_flags(), with this flag server read all the clients body, and only after this respond with an error if the clients body exceed max_body_size (since some clients cannot read response otherwise). The evhttp_connection_set_family() can bypass family hint to evdns. There are some flags available for connections, which can be installed with evhttp_connection_set_flags(): - EVHTTP_CON_REUSE_CONNECTED_ADDR -- reuse connection address on retry (avoid extra DNS request). - EVHTTP_CON_READ_ON_WRITE_ERROR - try read error, since server may already close the connection. The evhttp_connection_free_on_completion() can be used to tell libevent to free the connection object after the last request has completed or failed. There is evhttp_request_get_response_code_line() if evhttp_request_get_response_code() is not enough for you. There are *evhttp_uri_parse_with_flags() that accepts EVHTTP_URI_NONCONFORMANT to tolerate URIs that do not conform to RFC3986. The evhttp_uri_set_flags() can changes the flags on URI. 1.10. New functions and features: evutil There's a function "evutil_secure_rng_set_urandom_device_file()" that you can use to override the default file that Libevent uses to seed its (sort-of) secure RNG. The evutil_date_rfc1123() returns date in RFC1123 There are new API to work with monotonic timer -- monotonic time is guaranteed never to run in reverse, but is not necessarily epoch-based. Use it to make reliable measurements of elapsed time between events even when the system time may be changed: - evutil_monotonic_timer_new()/evutil_monotonic_timer_free() - evutil_configure_monotonic_time() - evutil_gettime_monotonic() Use evutil_make_listen_socket_reuseable_port() to set SO_REUSEPORT (linux >= 3.9) The evutil_make_tcp_listen_socket_deferred() can make a tcp listener socket defer accept()s until there is data to read (TCP_DEFER_ACCEPT). 2. Cross-platform performance improvements 2.1. Better data structures We replaced several users of the sys/queue.h "TAILQ" data structure with the "LIST" data structure. Because this data type doesn't require FIFO access, it requires fewer pointer checks and manipulations to keep it in line. All previous versions of Libevent have kept every pending (added) event in an "eventqueue" data structure. Starting in Libevent 2.0, however, this structure became redundant: every pending timeout event is stored in the timeout heap or in one of the common_timeout queues, and every pending fd or signal event is stored in an evmap. Libevent 2.1 removes this data structure, and thereby saves all of the code that we'd been using to keep it updated. 2.2. Faster activations and timeouts It's a common pattern in older code to use event_base_once() with a 0-second timeout to ensure that a callback will get run 'as soon as possible' in the current iteration of the Libevent loop. We optimize this case by calling event_active() directly, and bypassing the timeout pool. (People who are using this pattern should also consider using event_active() themselves.) Libevent 2.0 would wake up a polling event loop whenever the first timeout in the event loop was adjusted--whether it had become earlier or later. We now only notify the event loop when a change causes the expiration time to become _sooner_ than it would have been otherwise. The timeout heap code is now optimized to perform fewer comparisons and shifts when changing or removing a timeout. Instead of checking for a wall-clock time jump every time we call clock_gettime(), we now check only every 5 seconds. This should save a huge number of gettimeofday() calls. 2.3. Microoptimizations Internal event list maintainance no longer use the antipattern where we have one function with multiple totally independent behaviors depending on an argument: #define OP1 1 #define OP2 2 #define OP3 3 void func(int operation, struct event *ev) { switch (op) { ... } } Instead, these functions are now split into separate functions for each operation: void func_op1(struct event *ev) { ... } void func_op2(struct event *ev) { ... } void func_op3(struct event *ev) { ... } This produces better code generation and inlining decisions on some compilers, and makes the code easier to read and check. 2.4. Evbuffer performance improvements The EVBUFFER_EOL_CRLF line-ending type is now much faster, thanks to smart optimizations. 2.5. HTTP performance improvements o Performance tweak to evhttp_parse_request_line. (aee1a97 Mark Ellzey) o Add missing break to evhttp_parse_request_line (0fcc536) 2.6. Coarse timers by default on Linux Due to limitations of the epoll interface, Libevent programs using epoll have not previously been able to wait for timeouts with accuracy smaller than 1 millisecond. But Libevent had been using CLOCK_MONOTONIC for timekeeping on Linux, which is needlessly expensive: CLOCK_MONOTONIC_COARSE has approximately the resolution corresponding to epoll, and is much faster to invoke than CLOCK_MONOTONIC. To disable coarse timers, and get a more plausible precision, use the new EVENT_BASE_FLAG_PRECISE_TIMER flag when setting up your event base. 3. Backend/OS-specific improvements 3.1. Linux-specific improvements The logic for deciding which arguements to use with epoll_ctl() is now a table-driven lookup, rather than the previous pile of cascading branches. This should minimize epoll_ctl() calls and make the epoll code run a little faster on change-heavy loads. Libevent now takes advantage of Linux's support for enhanced APIs (e.g., SOCK_CLOEXEC, SOCK_NONBLOCK, accept4, pipe2) that allow us to simultaneously create a socket, make it nonblocking, and make it close-on-exec. This should save syscalls throughout our codebase, and avoid race-conditions if an exec() occurs after a socket is socket is created but before we can make it close-on-execute on it. 3.2. Windows-specific improvements We now use GetSystemTimeAsFileTime to implement gettimeofday. It's significantly faster and more accurate than our old ftime()-based approach. 3.3. Improvements in the solaris evport backend. The evport backend has been updated to use many of the infrastructure improvements from Libevent 2.0. Notably, it keeps track of per-fd information using the evmap infrastructure, and removes a number of linear scans over recently-added events. This last change makes it efficient to receive many more events per evport_getn() call, thereby reducing evport overhead in general. 3.4. OSX backend improvements The OSX select backend doesn't like to have more than a certain number of fds set unless an "unlimited select" option has been set. Therefore, we now set it. 3.5. Monotonic clocks on even more platforms Libevent previously used a monotonic clock for its internal timekeeping only on platforms supporting the POSIX clock_gettime() interface. Now, Libevent has support for monotonic clocks on OSX and Windows too, and a fallback implementation for systems without monotonic clocks that will at least keep time running forwards. Using monotonic timers makes Libevent more resilient to changes in the system time, as can happen in small amounts due to clock adjustments from NTP, or in large amounts due to users who move their system clocks all over the timeline in order to keep nagware from nagging them. 3.6. Faster cross-thread notification on kqueue When a thread other than the one in which the main event loop is running needs to wake the thread running the main event loop, Libevent usually writes to a socketpair in order to force the main event loop to wake up. On Linux, we've been able to use eventfd() instead. Now on BSD and OSX systems (any anywhere else that has kqueue with the EVFILT_USER extension), we can use EVFILT_USER to wake up the main thread from kqueue. This should be a tiny bit faster than the previous approach. 4. Infrastructure improvements 4.1. Faster tests I've spent some time to try to make the unit tests run faster in Libevent 2.1. Nearly all of this was a matter of searching slow tests for unreasonably long timeouts, and cutting them down to reasonably long delays, though on one or two cases I actually had to parallelize an operation or improve an algorithm. On my desktop, a full "make verify" run of Libevent 2.0.18-stable requires about 218 seconds. Libevent 2.1.1-alpha cuts this down to about 78 seconds. Faster unit tests are great, since they let programmers test their changes without losing their train of thought. 4.2. Finicky tests are now off-by-default The Tinytest unit testing framework now supports optional tests, and Libevent uses them. By default, Libevent's unit testing framework does not run tests that require a working network, and does not run tests that tend to fail on heavily loaded systems because of timing issues. To re-enable all tests, run ./test/regress using the "@@all" alias. 4.3. Modernized use of autotools Our autotools-based build system has been updated to build without warnings on recent autoconf/automake versions. Libevent's autotools makefiles are no longer recursive. This allows make to use the maximum possible parallelism to do the minimally necessary amount of work. See Peter Miller's "Recursive Make Considered Harmful" at http://miller.emu.id.au/pmiller/books/rmch/ for more information here. We now use the "quiet build" option to suppress distracting messages about which commandlines are running. You can get them back with "make V=1". 4.4. Portability Libevent now uses large-file support internally on platforms where it matters. You shouldn't need to set _LARGEFILE or OFFSET_BITS or anything magic before including the Libevent headers, either, since Libevent now sets the size of ev_off_t to the size of off_t that it received at compile time, not to some (possibly different) size based on current macro definitions when your program is building. We now also use the Autoconf AC_USE_SYSTEM_EXTENSIONS mechanism to enable per-system macros needed to enable not-on-by-default features. Unlike the rest of the autoconf macros, we output these to an internal-use-only evconfig-private.h header, since their names need to survive unmangled. This lets us build correctly on more platforms, and avoid inconsistencies when some files define _GNU_SOURCE and others don't. Libevent now tries to detect OpenSSL via pkg-config. 4.5. Standards conformance Previous Libevent versions had no consistent convention for internal vs external identifiers, and used identifiers starting with the "_" character throughout the codebase. That's no good, since the C standard says that identifiers beginning with _ are reserved. I'm not aware of having any collisions with system identifiers, but it's best to fix these things before they cause trouble. We now avoid all use of the _identifiers in the Libevent source code. These changes were made *mainly* through the use of automated scripts, so there shouldn't be any mistakes, but you never know. As an exception, the names _EVENT_LOG_DEBUG, _EVENT_LOG_MSG_, _EVENT_LOG_WARN, and _EVENT_LOG_ERR are still exposed in event.h: they are now deprecated, but to support older code, they will need to stay around for a while. New code should use EVENT_LOG_DEBUG, EVENT_LOG_MSG, EVENT_LOG_WARN, and EVENT_LOG_ERR instead. 4.6. Event and callback refactoring As a simplification and optimization to Libevent's "deferred callback" logic (introduced in 2.0 to avoid callback recursion), Libevent now treats all of its deferrable callback types using the same logic it uses for active events. Now deferred events no longer cause priority inversion, no longer require special code to cancel them, and so on. Regular events and deferred callbacks now both descend from an internal light-weight event_callback supertype, and both support priorities and take part in the other anti-priority-inversion mechanisms in Libevent. To avoid starvation from callback recursion (which was the reason we introduced "deferred callbacks" in the first place) the implementation now allows an event callback to be scheduled as "active later": instead of running in the current iteration of the event loop, it runs in the next one. 5. Testing Libevent's test coverage level is more or less unchanged since before: we still have over 80% line coverage in our tests on Linux, FreeBSD, NetBSD, Windows, OSX. There are some under-tested modules, though: we need to fix those. And now we have CI: - https://travis-ci.org/libevent/libevent - https://ci.appveyor.com/project/nmathewson/libevent And code coverage: - https://coveralls.io/github/libevent/libevent Plus there is vagrant boxes if you what to test it on more OS'es then travis-ci allows, and there is a wrapper (in python) that will parse logs and provide report: - https://github.com/libevent/libevent-extras/blob/master/tools/vagrant-tests.py 6. Contributing From now we have contributing guide and checkpatch.sh. @ 1.1.1.1.2.1 log @file whatsnew-2.1.txt was added on branch pgoyette-localcount on 2017-03-20 06:52:22 +0000 @ text @d1 768 @ 1.1.1.1.2.2 log @Sync with HEAD @ text @a0 768 What's new in Libevent 2.1 Nick Mathewson 0. Before we start 0.1. About this document This document describes the key differences between Libevent 2.0 and Libevent 2.1, from a user's point of view. It's a work in progress. For better documentation about libevent, see the links at http://libevent.org/ Libevent 2.1 would not be possible without the generous help of numerous volunteers. For a list of who did what in Libevent 2.1, please see the ChangeLog! NOTE: I am very sure that I missed some thing on this list. Caveat haxxor. 0.2. Where to get help Try looking at the other documentation too. All of the header files have documentation in the doxygen format; this gets turned into nice HTML and linked to from the libevent.org website. There is a work-in-progress book with reference manual at http://www.wangafu.net/~nickm/libevent-book/ . You can ask questions on the #libevent IRC channel at irc.oftc.net or on the mailing list at libevent-users@@freehaven.net. The mailing list is subscribers-only, so you will need to subscribe before you post. 0.3. Compatibility Our source-compatibility policy is that correct code (that is to say, code that uses public interfaces of Libevent and relies only on their documented behavior) should have forward source compatibility: any such code that worked with a previous version of Libevent should work with this version too. We don't try to do binary compatibility except within stable release series, so binaries linked against any version of Libevent 2.0 will probably need to be recompiled against Libevent 2.1.4-alpha if you want to use it. It is probable that we'll break binary compatibility again before Libevent 2.1 is stable. 1. New APIs and features 1.1. New ways to build libevent We now provide an --enable-gcc-hardening configure option to turn on GCC features designed for increased code security. There is also an --enable-silent-rules configure option to make compilation run more quietly with automake 1.11 or later. You no longer need to use the --enable-gcc-warnings option to turn on all of the GCC warnings that Libevent uses. The only change from using that option now is to turn warnings into errors. For IDE users, files that are not supposed to be built are now surrounded with appropriate #ifdef lines to keep your IDE from getting upset. There is now an alternative cmake-based build process; cmake users should see the relevant sections in the README. 1.2. New functions for events and the event loop If you're running Libevent with multiple event priorities, you might want to make sure that Libevent checks for new events frequently, so that time-consuming or numerous low-priority events don't keep it from checking for new high-priority events. You can now use the event_config_set_max_dispatch_interval() interface to ensure that the loop checks for new events either every N microseconds, every M callbacks, or both. When configuring an event base, you can now choose whether you want timers to be more efficient, or more precise. (This only has effect on Linux for now.) Timers are efficient by default: to select more precise timers, use the EVENT_BASE_FLAG_PRECISE_TIMER flag when constructing the event_config, or set the EVENT_PRECISE_TIMER environment variable to a non-empty string. There is an EVLOOP_NO_EXIT_ON_EMPTY flag that tells event_base_loop() to keep looping even when there are no pending events. (Ordinarily, event_base_loop() will exit as soon as no events are pending.) Past versions of Libevent have been annoying to use with some memory-leak-checking tools, because Libevent allocated some global singletons but provided no means to free them. There is now a function, libevent_global_shutdown(), that you can use to free all globally held resources before exiting, so that your leak-check tools don't complain. (Note: this function doesn't free non-global things like events, bufferevents, and so on; and it doesn't free anything that wouldn't otherwise get cleaned up by the operating system when your process exit()s. If you aren't using a leak-checking tool, there is not much reason to call libevent_global_shutdown().) There is a new event_base_get_npriorities() function to return the number of priorities set in the event base. Libevent 2.0 added an event_new() function to construct a new struct event on the heap. Unfortunately, with event_new(), there was no equivalent for: struct event ev; event_assign(&ev, base, fd, EV_READ, callback, &ev); In other words, there was no easy way for event_new() to set up an event so that the event itself would be its callback argument. Libevent 2.1 lets you do this by passing "event_self_cbarg()" as the callback argument: struct event *evp; evp = event_new(base, fd, EV_READ, callback, event_self_cbarg()); There's also a new event_base_get_running_event() function you can call from within a Libevent callback to get a pointer to the current event. This should never be strictly necessary, but it's sometimes convenient. The event_base_once() function used to leak some memory if the event that it added was never actually triggered. Now, its memory is tracked in the event_base and freed when the event_base is freed. Note however that Libevent doesn't know how to free any information passed as the callback argument to event_base_once is still something you'll might need a way to de-allocate yourself. There is an event_get_priority() function to return an event's priority. By analogy to event_base_loopbreak(), there is now an event_base_loopcontinue() that tells Libevent to stop processing active event callbacks, and re-scan for new events right away. There's a function, event_base_foreach_event(), that can iterate over every event currently pending or active on an event base, and invoke a user-supplied callback on each. The callback must not alter the events or add or remove anything to the event base. We now have an event_remove_timer() function to remove the timeout on an event while leaving its socket and/or signal triggers unchanged. (If we were designing the API from scratch, this would be the behavior of "event_add(ev, NULL)" on an already-added event with a timeout. But that's a no-op in past versions of Libevent, and we don't want to break compatibility.) You can use the new event_base_get_num_events() function to find the number of events active or pending on an event_base. To find the largest number of events that there have been since the last call, use event_base_get_max_events(). You can now activate all the events waiting for a given fd or signal using the event_base_active_by_fd() and event_base_active_by_signal() APIs. On backends that support it (currently epoll), there is now an EV_CLOSED flag that programs can use to detect when a socket has closed without having to read all the bytes until receiving an EOF. 1.3. Event finalization 1.3.1. Why event finalization? Libevent 2.1 now supports an API for safely "finalizing" events that might be running in multiple threads, and provides a way to slightly change the semantics of event_del() to prevent deadlocks in multithreaded programs. To motivate this feature, consider the following code, in the context of a mulithreaded Libevent application: struct connection *conn = event_get_callback_arg(ev); event_del(ev); connection_free(conn); Suppose that the event's callback might be running in another thread, and using the value of "conn" concurrently. We wouldn't want to execute the connection_free() call until "conn" is no longer in use. How can we make this code safe? Libevent 2.0 answered that question by saying that the event_del() call should block if the event's callback is running in another thread. That way, we can be sure that event_del() has canceled the callback (if the callback hadn't started running yet), or has waited for the callback to finish. But now suppose that the data structure is protected by a lock, and we have the following code: void check_disable(struct connection *connection) { lock(connection); if (should_stop_reading(connection)) event_del(connection->read_event); unlock(connection); } What happens when we call check_disable() from a callback and from another thread? Let's say that the other thread gets the lock first. If it decides to call event_del(), it will wait for the callback to finish. But meanwhile, the callback will be waiting for the lock on the connection. Since each threads is waiting for the other one to release a resource, the program will deadlock. This bug showed up in multithreaded bufferevent programs in 2.1, particularly when freeing bufferevents. (For more information, see the "Deadlock when calling bufferevent_free from an other thread" thread on libevent-users starting on 6 August 2012 and running through February of 2013. You might also like to read my earlier writeup at http://archives.seul.org/libevent/users/Feb-2012/msg00053.html and the ensuing discussion.) 1.3.2. The EV_FINALIZE flag and avoiding deadlock To prevent the deadlock condition described above, Libevent 2.1.3-alpha adds a new flag, "EV_FINALIZE". You can pass it to event_new() and event_assign() along with EV_READ, EV_WRITE, and the other event flags. When an event is constructed with the EV_FINALIZE flag, event_del() will not block on that event, even when the event's callback is running in another thread. By using EV_FINALIZE, you are therefore promising not to use the "event_del(ev); free(event_get_callback_arg(ev));" pattern, but rather to use one of the finalization functions below to clean up the event. EV_FINALIZE has no effect on a single-threaded program, or on a program where events are only used from one thread. There are also two new variants of event_del() that you can use for more fine-grained control: event_del_noblock(ev) event_del_block(ev) The event_del_noblock() function will never block, even if the event callback is running in another thread and doesn't have the EV_FINALIZE flag. The event_del_block() function will _always_ block if the event callback is running in another thread, even if the event _does_ have the EV_FINALIZE flag. [A future version of Libevent may have a way to make the EV_FINALIZE flag the default.] 1.3.3. Safely finalizing events To safely tear down an event that may be running, Libevent 2.1.3-alpha introduces event_finalize() and event_free_finalize(). You call them on an event, and provide a finalizer callback to be run on the event and its callback argument once the event is definitely no longer running. With event_free_finalize(), the event is also freed once the finalizer callback has been invoked. A finalized event cannot be re-added or activated. The finalizer callback must not add events, activate events, or attempt to "resucitate" the event being finalized in any way. If any finalizer callbacks are pending as the event_base is being freed, they will be invoked. You can override this behavior with the new function event_base_free_nofinalize(). 1.4. New debugging features You can now turn on debug logs at runtime using a new function, event_enable_debug_logging(). The event_enable_lock_debugging() function is now spelled correctly. You can still use the old "event_enable_lock_debuging" name, though, so your old programs shouldnt' break. There's also been some work done to try to make the debugging logs more generally useful. 1.5. New evbuffer functions In Libevent 2.0, we introduced evbuffer_add_file() to add an entire file's contents to an evbuffer, and then send them using sendfile() or mmap() as appropriate. This API had some drawbacks, however. Notably, it created one mapping or fd for every instance of the same file added to any evbuffer. Also, adding a file to an evbuffer could make that buffer unusable with SSL bufferevents, filtering bufferevents, and any code that tried to read the contents of the evbuffer. Libevent 2.1 adds a new evbuffer_file_segment API to solve these problems. Now, you can use evbuffer_file_segment_new() to construct a file-segment object, and evbuffer_add_file_segment() to insert it (or part of it) into an evbuffer. These segments avoid creating redundant maps or fds. Better still, the code is smart enough (when the OS supports sendfile) to map the file when that's necessary, and use sendfile() otherwise. File segments can receive callback functions that are invoked when the file segments are freed. The evbuffer_ptr interface has been extended so that an evbuffer_ptr can now yield a point just after the end of the buffer. This makes many algorithms simpler to implement. There's a new evbuffer_add_buffer() interface that you can use to add one buffer to another nondestructively. When you say evbuffer_add_buffer_reference(outbuf, inbuf), outbuf now contains a reference to the contents of inbuf. To aid in adding data in bulk while minimizing evbuffer calls, there is an evbuffer_add_iovec() function. There's a new evbuffer_copyout_from() variant function to enable copying data nondestructively from the middle of a buffer. evbuffer_readln() now supports an EVBUFFER_EOL_NUL argument to fetch NUL-terminated strings from buffers. There's a new evbuffer_set_flags()/evbuffer_clear_flags() that you can use to set EVBUFFER_FLAG_DRAINS_TO_FD. 1.6. New functions and features: bufferevents You can now use the bufferevent_getcb() function to find out a bufferevent's callbacks. Previously, there was no supported way to do that. The largest chunk readable or writeable in a single bufferevent callback is no longer hardcoded; it's now configurable with the new functions bufferevent_set_max_single_read() and bufferevent_set_max_single_write(). For consistency, OpenSSL bufferevents now make sure to always set one of BEV_EVENT_READING or BEV_EVENT_WRITING when invoking an event callback. Calling bufferevent_set_timeouts(bev, NULL, NULL) now removes the timeouts from socket and ssl bufferevents correctly. You can find the priority at which a bufferevent runs with bufferevent_get_priority(). The function bufferevent_get_token_bucket_cfg() can retrieve the rate-limit settings for a bufferevent; bufferevent_getwatermark() can return a bufferevent's current watermark settings. You can manually trigger a bufferevent's callbacks via bufferevent_trigger() and bufferevent_trigger_event(). Also you can manually increment/decrement reference for bufferevent with bufferevent_incref()/bufferevent_decref(), it is useful in situations where a user may reference the bufferevent somewhere else. Now bufferevent_openssl supports "dirty" shutdown (when the peer closes the TCP connection before closing the SSL channel), see bufferevent_openssl_get_allow_dirty_shutdown() and bufferevent_openssl_set_allow_dirty_shutdown(). And also libevent supports openssl 1.1. 1.7. New functions and features: evdns The previous evdns interface used an "open a test UDP socket" trick in order to detect IPv6 support. This was a hack, since it would sometimes badly confuse people's firewall software, even though no packets were sent. The current evdns interface-detection code uses the appropriate OS functions to see which interfaces are configured. The evdns_base_new() function now has multiple possible values for its second (flags) argument. Using 1 and 0 have their old meanings, though the 1 flag now has a symbolic name of EVDNS_BASE_INITIALIZE_NAMESERVERS. A second flag is now supported too: the EVDNS_BASE_DISABLE_WHEN_INACTIVE flag, which tells the evdns_base that it should not prevent Libevent from exiting while it has no DNS requests in progress. There is a new evdns_base_clear_host_addresses() function to remove all the /etc/hosts addresses registered with an evdns instance. Also there is evdns_base_get_nameserver_addr() for retrieve the address of the 'idx'th configured nameserver. 1.8. New functions and features: evconnlistener Libevent 2.1 adds the following evconnlistener flags: LEV_OPT_DEFERRED_ACCEPT -- Tells the OS that it doesn't need to report sockets as having arrived until the initiator has sent some data too. This can greatly improve performance with protocols like HTTP where the client always speaks first. On operating systems that don't support this functionality, this option has no effect. LEV_OPT_REUSEABLE_PORT -- Indicates that we ask to allow multiple servers to bind to the same port if they each set the option Ionly on Linux and >=3.9) LEV_OPT_DISABLED -- Creates an evconnlistener in the disabled (not listening) state. Libevent 2.1 changes the behavior of the LEV_OPT_CLOSE_ON_EXEC flag. Previously, it would apply to the listener sockets, but not to the accepted sockets themselves. That's almost never what you want. Now, it applies both to the listener and the accepted sockets. 1.9. New functions and features: evhttp ********************************************************************** NOTE: The evhttp module will eventually be deprecated in favor of Mark Ellzey's libevhtp library. Don't worry -- this won't happen until libevhtp provides every feature that evhttp does, and provides a compatible interface that applications can use to migrate. ********************************************************************** Previously, you could only set evhttp timeouts in increments of one second. Now, you can use evhttp_set_timeout_tv() and evhttp_connection_set_timeout_tv() to configure microsecond-granularity timeouts. Also there is evhttp_connection_set_initial_retry_tv() to change initial retry timeout. There are a new pair of functions: evhttp_set_bevcb() and evhttp_connection_base_bufferevent_new(), that you can use to configure which bufferevents will be used for incoming and outgoing http connections respectively. These functions, combined with SSL bufferevents, should enable HTTPS support. There's a new evhttp_foreach_bound_socket() function to iterate over every listener on an evhttp object. Whitespace between lines in headers is now folded into a single space; whitespace at the end of a header is now removed. The socket errno value is now preserved when invoking an http error callback. There's a new kind of request callback for errors; you can set it with evhttp_request_set_error_cb(). It gets called when there's a request error, and actually reports the error code and lets you figure out which request failed. You can navigate from an evhttp_connection back to its evhttp with the new evhttp_connection_get_server() function. You can override the default HTTP Content-Type with the new evhttp_set_default_content_type() function There's a new evhttp_connection_get_addr() API to return the peer address of an evhttp_connection. The new evhttp_send_reply_chunk_with_cb() is a variant of evhttp_send_reply_chunk() with a callback to be invoked when the chunk is sent. The evhttp_request_set_header_cb() facility adds a callback to be invoked while parsing headers. The evhttp_request_set_on_complete_cb() facility adds a callback to be invoked on request completion. You can add linger-close for http server by passing EVHTTP_SERVER_LINGERING_CLOSE to evhttp_set_flags(), with this flag server read all the clients body, and only after this respond with an error if the clients body exceed max_body_size (since some clients cannot read response otherwise). The evhttp_connection_set_family() can bypass family hint to evdns. There are some flags available for connections, which can be installed with evhttp_connection_set_flags(): - EVHTTP_CON_REUSE_CONNECTED_ADDR -- reuse connection address on retry (avoid extra DNS request). - EVHTTP_CON_READ_ON_WRITE_ERROR - try read error, since server may already close the connection. The evhttp_connection_free_on_completion() can be used to tell libevent to free the connection object after the last request has completed or failed. There is evhttp_request_get_response_code_line() if evhttp_request_get_response_code() is not enough for you. There are *evhttp_uri_parse_with_flags() that accepts EVHTTP_URI_NONCONFORMANT to tolerate URIs that do not conform to RFC3986. The evhttp_uri_set_flags() can changes the flags on URI. 1.10. New functions and features: evutil There's a function "evutil_secure_rng_set_urandom_device_file()" that you can use to override the default file that Libevent uses to seed its (sort-of) secure RNG. The evutil_date_rfc1123() returns date in RFC1123 There are new API to work with monotonic timer -- monotonic time is guaranteed never to run in reverse, but is not necessarily epoch-based. Use it to make reliable measurements of elapsed time between events even when the system time may be changed: - evutil_monotonic_timer_new()/evutil_monotonic_timer_free() - evutil_configure_monotonic_time() - evutil_gettime_monotonic() Use evutil_make_listen_socket_reuseable_port() to set SO_REUSEPORT (linux >= 3.9) The evutil_make_tcp_listen_socket_deferred() can make a tcp listener socket defer accept()s until there is data to read (TCP_DEFER_ACCEPT). 2. Cross-platform performance improvements 2.1. Better data structures We replaced several users of the sys/queue.h "TAILQ" data structure with the "LIST" data structure. Because this data type doesn't require FIFO access, it requires fewer pointer checks and manipulations to keep it in line. All previous versions of Libevent have kept every pending (added) event in an "eventqueue" data structure. Starting in Libevent 2.0, however, this structure became redundant: every pending timeout event is stored in the timeout heap or in one of the common_timeout queues, and every pending fd or signal event is stored in an evmap. Libevent 2.1 removes this data structure, and thereby saves all of the code that we'd been using to keep it updated. 2.2. Faster activations and timeouts It's a common pattern in older code to use event_base_once() with a 0-second timeout to ensure that a callback will get run 'as soon as possible' in the current iteration of the Libevent loop. We optimize this case by calling event_active() directly, and bypassing the timeout pool. (People who are using this pattern should also consider using event_active() themselves.) Libevent 2.0 would wake up a polling event loop whenever the first timeout in the event loop was adjusted--whether it had become earlier or later. We now only notify the event loop when a change causes the expiration time to become _sooner_ than it would have been otherwise. The timeout heap code is now optimized to perform fewer comparisons and shifts when changing or removing a timeout. Instead of checking for a wall-clock time jump every time we call clock_gettime(), we now check only every 5 seconds. This should save a huge number of gettimeofday() calls. 2.3. Microoptimizations Internal event list maintainance no longer use the antipattern where we have one function with multiple totally independent behaviors depending on an argument: #define OP1 1 #define OP2 2 #define OP3 3 void func(int operation, struct event *ev) { switch (op) { ... } } Instead, these functions are now split into separate functions for each operation: void func_op1(struct event *ev) { ... } void func_op2(struct event *ev) { ... } void func_op3(struct event *ev) { ... } This produces better code generation and inlining decisions on some compilers, and makes the code easier to read and check. 2.4. Evbuffer performance improvements The EVBUFFER_EOL_CRLF line-ending type is now much faster, thanks to smart optimizations. 2.5. HTTP performance improvements o Performance tweak to evhttp_parse_request_line. (aee1a97 Mark Ellzey) o Add missing break to evhttp_parse_request_line (0fcc536) 2.6. Coarse timers by default on Linux Due to limitations of the epoll interface, Libevent programs using epoll have not previously been able to wait for timeouts with accuracy smaller than 1 millisecond. But Libevent had been using CLOCK_MONOTONIC for timekeeping on Linux, which is needlessly expensive: CLOCK_MONOTONIC_COARSE has approximately the resolution corresponding to epoll, and is much faster to invoke than CLOCK_MONOTONIC. To disable coarse timers, and get a more plausible precision, use the new EVENT_BASE_FLAG_PRECISE_TIMER flag when setting up your event base. 3. Backend/OS-specific improvements 3.1. Linux-specific improvements The logic for deciding which arguements to use with epoll_ctl() is now a table-driven lookup, rather than the previous pile of cascading branches. This should minimize epoll_ctl() calls and make the epoll code run a little faster on change-heavy loads. Libevent now takes advantage of Linux's support for enhanced APIs (e.g., SOCK_CLOEXEC, SOCK_NONBLOCK, accept4, pipe2) that allow us to simultaneously create a socket, make it nonblocking, and make it close-on-exec. This should save syscalls throughout our codebase, and avoid race-conditions if an exec() occurs after a socket is socket is created but before we can make it close-on-execute on it. 3.2. Windows-specific improvements We now use GetSystemTimeAsFileTime to implement gettimeofday. It's significantly faster and more accurate than our old ftime()-based approach. 3.3. Improvements in the solaris evport backend. The evport backend has been updated to use many of the infrastructure improvements from Libevent 2.0. Notably, it keeps track of per-fd information using the evmap infrastructure, and removes a number of linear scans over recently-added events. This last change makes it efficient to receive many more events per evport_getn() call, thereby reducing evport overhead in general. 3.4. OSX backend improvements The OSX select backend doesn't like to have more than a certain number of fds set unless an "unlimited select" option has been set. Therefore, we now set it. 3.5. Monotonic clocks on even more platforms Libevent previously used a monotonic clock for its internal timekeeping only on platforms supporting the POSIX clock_gettime() interface. Now, Libevent has support for monotonic clocks on OSX and Windows too, and a fallback implementation for systems without monotonic clocks that will at least keep time running forwards. Using monotonic timers makes Libevent more resilient to changes in the system time, as can happen in small amounts due to clock adjustments from NTP, or in large amounts due to users who move their system clocks all over the timeline in order to keep nagware from nagging them. 3.6. Faster cross-thread notification on kqueue When a thread other than the one in which the main event loop is running needs to wake the thread running the main event loop, Libevent usually writes to a socketpair in order to force the main event loop to wake up. On Linux, we've been able to use eventfd() instead. Now on BSD and OSX systems (any anywhere else that has kqueue with the EVFILT_USER extension), we can use EVFILT_USER to wake up the main thread from kqueue. This should be a tiny bit faster than the previous approach. 4. Infrastructure improvements 4.1. Faster tests I've spent some time to try to make the unit tests run faster in Libevent 2.1. Nearly all of this was a matter of searching slow tests for unreasonably long timeouts, and cutting them down to reasonably long delays, though on one or two cases I actually had to parallelize an operation or improve an algorithm. On my desktop, a full "make verify" run of Libevent 2.0.18-stable requires about 218 seconds. Libevent 2.1.1-alpha cuts this down to about 78 seconds. Faster unit tests are great, since they let programmers test their changes without losing their train of thought. 4.2. Finicky tests are now off-by-default The Tinytest unit testing framework now supports optional tests, and Libevent uses them. By default, Libevent's unit testing framework does not run tests that require a working network, and does not run tests that tend to fail on heavily loaded systems because of timing issues. To re-enable all tests, run ./test/regress using the "@@all" alias. 4.3. Modernized use of autotools Our autotools-based build system has been updated to build without warnings on recent autoconf/automake versions. Libevent's autotools makefiles are no longer recursive. This allows make to use the maximum possible parallelism to do the minimally necessary amount of work. See Peter Miller's "Recursive Make Considered Harmful" at http://miller.emu.id.au/pmiller/books/rmch/ for more information here. We now use the "quiet build" option to suppress distracting messages about which commandlines are running. You can get them back with "make V=1". 4.4. Portability Libevent now uses large-file support internally on platforms where it matters. You shouldn't need to set _LARGEFILE or OFFSET_BITS or anything magic before including the Libevent headers, either, since Libevent now sets the size of ev_off_t to the size of off_t that it received at compile time, not to some (possibly different) size based on current macro definitions when your program is building. We now also use the Autoconf AC_USE_SYSTEM_EXTENSIONS mechanism to enable per-system macros needed to enable not-on-by-default features. Unlike the rest of the autoconf macros, we output these to an internal-use-only evconfig-private.h header, since their names need to survive unmangled. This lets us build correctly on more platforms, and avoid inconsistencies when some files define _GNU_SOURCE and others don't. Libevent now tries to detect OpenSSL via pkg-config. 4.5. Standards conformance Previous Libevent versions had no consistent convention for internal vs external identifiers, and used identifiers starting with the "_" character throughout the codebase. That's no good, since the C standard says that identifiers beginning with _ are reserved. I'm not aware of having any collisions with system identifiers, but it's best to fix these things before they cause trouble. We now avoid all use of the _identifiers in the Libevent source code. These changes were made *mainly* through the use of automated scripts, so there shouldn't be any mistakes, but you never know. As an exception, the names _EVENT_LOG_DEBUG, _EVENT_LOG_MSG_, _EVENT_LOG_WARN, and _EVENT_LOG_ERR are still exposed in event.h: they are now deprecated, but to support older code, they will need to stay around for a while. New code should use EVENT_LOG_DEBUG, EVENT_LOG_MSG, EVENT_LOG_WARN, and EVENT_LOG_ERR instead. 4.6. Event and callback refactoring As a simplification and optimization to Libevent's "deferred callback" logic (introduced in 2.0 to avoid callback recursion), Libevent now treats all of its deferrable callback types using the same logic it uses for active events. Now deferred events no longer cause priority inversion, no longer require special code to cancel them, and so on. Regular events and deferred callbacks now both descend from an internal light-weight event_callback supertype, and both support priorities and take part in the other anti-priority-inversion mechanisms in Libevent. To avoid starvation from callback recursion (which was the reason we introduced "deferred callbacks" in the first place) the implementation now allows an event callback to be scheduled as "active later": instead of running in the current iteration of the event loop, it runs in the next one. 5. Testing Libevent's test coverage level is more or less unchanged since before: we still have over 80% line coverage in our tests on Linux, FreeBSD, NetBSD, Windows, OSX. There are some under-tested modules, though: we need to fix those. And now we have CI: - https://travis-ci.org/libevent/libevent - https://ci.appveyor.com/project/nmathewson/libevent And code coverage: - https://coveralls.io/github/libevent/libevent Plus there is vagrant boxes if you what to test it on more OS'es then travis-ci allows, and there is a wrapper (in python) that will parse logs and provide report: - https://github.com/libevent/libevent-extras/blob/master/tools/vagrant-tests.py 6. Contributing From now we have contributing guide and checkpatch.sh. @