Nick Mathewson [Tue, 24 Dec 2013 16:30:06 +0000 (11:30 -0500)]
Minor optimizations on bufferevent_trigger options
By making BEV_TRIG_DEFER_CALLBACKS equal to BEV_OPT_DEFER_CALLBACKS,
and BEV_TRIG_IGNORE_WATERMARKS disjoint from BEV_OPT_*, we can save a
few operations in bufferevent_run_*, which is critical-path.
Nick Mathewson [Tue, 24 Dec 2013 16:20:52 +0000 (11:20 -0500)]
Make bufferevent_trigger_nolock_() inline
Since most of its callers are using constant EV_READ or EV_WRITE, and
using constant 0 as its argument, this should eliminate most of the
overhead for this function in the fast case.
Nick Mathewson [Fri, 6 Dec 2013 15:50:17 +0000 (10:50 -0500)]
Rename flush_outdated_host_addresses to clear_host_addresses
"flush" can imply writing something out to a file or connection before
clearing it; "clear" always means "remove". It's also potentially
misleading to say "outdated" here, since the function removes _all_
addresses regardless, not just certain outdated ones.
Also, don't free the lock in this function. Also reindent the function.
Kuldeep Gupta [Fri, 6 Dec 2013 11:36:20 +0000 (17:06 +0530)]
bug fix for issues #293 evdns_base_load_hosts doesn't remove outdated addresses
As mentioned at https://sourceforge.net/p/levent/bugs/293/
created a small function "evdns_base_flush_outdated_host_addresses" which removes all the previous host addresses, if user wants to clean up the list of hosts can call and use this function.
Defination of this function is part of another patch.
Kuldeep Gupta [Fri, 6 Dec 2013 11:23:16 +0000 (16:53 +0530)]
bug fix for issues #293 evdns_base_load_hosts doesn't remove outdated adresses
As mentioned at https://sourceforge.net/p/levent/bugs/293/
created a small function "evdns_base_flush_outdated_host_addresses" which removes all the previous requests of hosts , if user wants to clean up the list of hosts can call and use this function.
Requires function declaration to be added in include/event2/dns.h
Adding it in another patch for the same bug.
Julien BLACHE [Sat, 2 May 2009 18:40:11 +0000 (20:40 +0200)]
Add a variant of evhttp_send_reply_chunk() with a callback on evhttp_write_buffer()
evhttp_write_buffer() used by evhttp_send_reply_chunk() can take callback
executed when (part of) the buffer has been written. Using this callback to
schedule the next chunk avoids buffering large amounts of data in memory.
Azat Khuzhin [Tue, 1 Oct 2013 15:12:13 +0000 (19:12 +0400)]
http: implement new evhttp_connection_get_addr() api.
Basically tcp final handshake looks like this:
(C - client, S - server)
ACK[C] - FIN/ACK[S] - FIN/ACK[S] - ACK [C]
However there are servers, that didn't close connection like this,
while it is still _considered_ as valid, and using libevent http layer
we can do requests to such servers.
And in this case we can't extract IP address from socket, because it is
already closed, and getpeername() will return: "transport endpoint is not connected".
So we need to store address that we are connecting to, after we know it,
and that is what this patch do.
I have reproduced it, however it have some extra packages.
(I will try to fix it)
https://github.com/azat/nfq-examples/blob/master/nfqnl_rst_fin.c
Ross Lagerwall [Sun, 15 Sep 2013 19:48:15 +0000 (21:48 +0200)]
rpcgen: Generate regress.gen.[c,h] in build rather than src dir
Currently an out-of-tree build will either write to the src dir or reuse
the existing regress.gen.[c,h]. But if building from a read-only git
tree (or if the git dir is cleaned), these files will not exist and the
build fails. So write the files to the build dir. If the system does
not have python, the regress.gen.[c,h] will be used from the src dir if
they exist.
The evhttp_send_reply method invokes evhttp_write_buffer with a
callback that may release the underlying request object and
bufferevent upon completion. This cleanup callback is invoked by the
underlying bufferevent's write callback. Improperly enabling write
events before referencing the bufferevent could lead to use after free
and memory corruption.
Azat Khuzhin [Tue, 13 Aug 2013 14:19:50 +0000 (18:19 +0400)]
sample: drop uri_root from base_url in http-server.
By default there is "0.0.0.0", and this address will work only from
the same machine, and besides there is no need in uri_root in base_url,
because it will be added automatically by browser.
Nick Mathewson [Tue, 6 Aug 2013 23:06:58 +0000 (19:06 -0400)]
Add some assertions to please coverity.
In event_process_active_single_queue, EVLIST_INIT must be set on any
event that uses one of the event-only closures, and so "ev" will be
set in those cases. But coverity's worried here (CIDs numerous). So
instead, just add the assertions that should make it happy.
Maxime Henrion [Wed, 31 Jul 2013 15:02:07 +0000 (15:02 +0000)]
Add checks for evhttp_connection_get_server() in unit tests.
They validate that this function behave as expected; that is, it returns
NULL for outgoing connections, and returns the HTTP server object that
received the connection for incoming ones.