Viallard Anthony | 2 Sep 10:33 2014

Abnormal delay on read

Hello there,

I have a problem with libevent (version 2.0.21).

I have 2 programs. One is sending requests (lets call it program A) to 
the other (program B) which process the request and send the response.

There are 2 kinds of request: one sent each 10 seconds (like a ping) and 
another one which is sent asynchronously when A has to.

All is working good at the beginning. But after a while, there is a 
delay between the request sent by A and the trigger of the read callback 
on B. All the request are shifted. During this delay, B proceed old ping 
requests... And this delay gradually increases.

I did a tcpdump capture on each side and I see there isn't a delay on 
the ethernet layer.

It's like there a mysterious queue somewhere...

However, I think I do the correct things in my read callback and I don't 
use watermarks.

Maybe, someone has already seen this kind of bad behavior ?

Here the code of my read callback (this function is generic for my 2 


(Continue reading)

gerkenjohannes | 29 Aug 18:30 2014

Assert fail in evhttp_connection_fail_ with req=0x00 on error=EVREQ_HTTP_TIMEOUT at http.c:691


when I add new evhttp requests to an running event_loop, I get "epoll ADD: Bad file descriptor" and later "SIGABRT".
The event_base is running in an seperate worker thread, the main thread is doing the evhttp_make_request.

Output from GDB:

Output from GDB with libevent debugging on:

I get the assert fail in the folowing 2 cases:

case 1:
1. add new requests to the running event_base

case 2:
1. call loop_brake from the main thread
2. wait for the loop to "brake" in the worker thread
3. put the worker thread to sleep
4. add new requests
5. wake up the worker thread
6. run the event_loop

Is this bug in libevent or my code?

Best regards,
To unsubscribe, send an e-mail to majordomo <at> with
unsubscribe libevent-users    in the body.
(Continue reading)

B.R. | 29 Aug 17:53 2014

Design struggle

I am trying to implement a modular filter plug-in system on top of libevent.

The main concept principles are:
1°) Filters are created cointaining information of connections they should be bound to (protocol, port), events that should trigger them and a callback pointer to link with the event
2°) Based on those filters, the necessary sockets are created and each socket is linked to a list of filters matching them
3°) For each filter, an event is created liking the callback to the socket file descriptor
4°) Each filter is then able to read information from the socket and possibly stack information to write that socket, registering a WRITE event on it

My concern here are concurrency (not really race condition since the app is single-threaded) :
I) If multiple filters ask to be triggered on READ event on the same socket, what will they see? Will they all be able to read the same message which triggered the event and not another one (ie another message received while processing the filter list)?

II) If multiple filters wanna write data to the socket, is it safe to have each filter having its separate buffer and triggering its own WRITE event on it?

Here is a use case summing up both previous inquiries:
Say a filter wrote data to a socket after parsing the content it read on it, and that the peer reacted to that answer, what will subsequent filters, for which the READ event has been triggered by the initial message, read?
a) Initial message?
b) Either initial message or answer (race, undecided)?
c) Nothing since the event has been canceled (not pending anymore), the subsequent filters will only receive a new event for READ on reception of the answer

I am thinking of using a dispatcher which would sequentially (and manually) trigger the event of each of the filters. However that implies not linking the filters event with the socket, thus forcing me to maintain a separate buffer for each of the filter (with memory and processing overhead that implies). Moreover, the problem reappears if another message is received on the socket while the dispatching loop is at work... and the sequential work makes the benefit of the event-based system disappear!

I do not know if the bufferevents would be useful to my case. Anyway, those are not an option, since part of the traffic I am handling is UDP datagrams.

I am new to the library. Please enlighten me if I have missed some key points in its design/handling.
B. R.
B.R. | 18 Aug 15:33 2014

Linking to library in other project


I am a new user here :o)

I plan on using the libevent library for the very first time in a project.
I wonder about something related to cross-compiling for Windows and Linux:

I compiled libevent with MinGW+MSYS on Windows in order to link my project against the libevent.a (static linking).
What if I want to link my project with the same library for the Linux version? I do not see any libevent.lib. Shall I use the libevent.a again? Or should I compile libevent in Linux first then use its output library, which I guess would be libevent(.dll).lib?


B. R.
Erik Fears | 9 Aug 03:53 2014

evdns_cancel_request may not fully cancel


I've run into an issue in my codebase where it appears evdns is calling 
a callback on a request that I've canceled.

This is an issue for me, because once I call evdns_cancel_request, I've 
also freed my own context associated with the request (i.e. the 
void* passed back by libevent to the callback).

If the result was always DNS_ERR_CANCEL on a cancelled request, 
this wouldn't be a problem, because I could abort. It seems that in some 
cases the result could be DNS_ERR_NONE if the callback was 
already pending

I believe this code may be to blame?

evdns_cancel_request(struct evdns_base *base, struct evdns_request *handle)

if (handle->pending_cb) {

Is this expected?


Gawen ARAB | 5 Aug 12:09 2014

Libevent 2.1 release ?

Hey guys,

Sorry if the question had been asked, I didn't find the info in this mailing-list.

I was wondering what was missing to have a 2.1 beta or 2.1 stable ? What are the events you think is required before triggering the release ?



Yang Gao | 16 Jul 23:46 2014

Race condition on event_debug_mode_too_late.


In one of our tests, we saw a race condition on event_debug_mode_too_late. We are using 2.0.21 stable.

In the test, one thread has on top of the stack
#0  event_assign
#1  event_new
#2 ... omitted

and another is doing
#0  event_add_internal
#1  event_add
#2  ... omitted

Setting macro _EVENT_DISABLE_DEBUG_MODE fixes the problem. 

A google search shows this might be similar to reports here:
and here:



CJ Ess | 5 Jul 03:55 2014

libevent http post/put example, please

I believe I've Googled thoroughly and gone through everything on Github, and while I can find many step-by-step examples of handling http GETs with libevent, I can not find any good examples of how to handle a POST or PUT. The few examples I do find seem to assume that the entire request, headers and body, is in memory.

I would like to see an example of receiving a POST or PUT with a large body - larger then available memory. Does anyone have one they could post here or send to me privately?

Andre | 3 Jul 17:41 2014

Using evbuffer_add to write into a file

I have a lot of functions for serialization data. At the moment I am 
just sending these data to other sockets. But I want to save some of the 
information with the same functions for serialization in a file. So I 
thought that there is might be a chance to fopen and fwrite the data via 
libevent with it's file descriptor. I searched a lot but I found nothing 
similar to this.
I am using libevent 2.1.4.
Thanks in advance.
To unsubscribe, send an e-mail to majordomo <at> with
unsubscribe libevent-users    in the body.

Hiroaki Hata | 27 Jun 15:50 2014

output buffer length check of SSL connection


le-proxy.c sample is very helpful for me. Thanks Nick.

I'm tried to use it for SSL connections and noticed some transmitted 
packets dropped. 
In congestion control, we have to check the length of output buffer,
but when the SSL is used, the buffer of the underlay bufferevent b_out
should be checked rather than the filter event of SSL.
In the sample code, the underlay bufferevent is overwritten with b_ssl.
I cached b_out and checked the buffer length of it and set write callback
to it, then the congestion works well.
This is a just comment but I appreciate you for your detailed online manuals
and comprehensive examples.

Hiroaki Hata

To unsubscribe, send an e-mail to majordomo <at> with
unsubscribe libevent-users    in the body.

Robin | 26 Jun 14:36 2014

Event timeout after it has been freed

I'm still investigating the issues from my other email and came across 
another thing.
This might, again, be due to memory corruption on my side - I'm hoping 
it isn't though.

I implemented a simple timer-event class which basically creates an 
event with a timeout and calls an std::function once that timeout is hit.
Every now and then I get crashes in my ping event.
The ping event is a lambda which captures the "this" pointer of my 
socket and just pings the client every 30 seconds.
The crashes are always related to the ping event having a nullptr as the 
socket pointer.
So I did some recording in gdb and came to the conclusion it gets set to 
0 in the destructor of the event class, which gets called when a socket 
Backtrace can be seen here:
Destructor just calls event_del, if the event is running, followed by an 
It rarely happens, I had to wait for that crash for about 5hours, thats 
10k connections minimum.

Could it be the event doesnt get canceled when it is pending?
Like the event "queue" could look something like this
1. Disconnect socket x
2. Socket y recieve
4. Socket x send
5. Event z timeout

"1." would cancel Event z though
(I am just guessing here since I have no idea why it's happening)

Really hope someone is able to help me out, slowly going insane..


To unsubscribe, send an e-mail to majordomo <at> with
unsubscribe libevent-users    in the body.