2014-04-12

Libevent HTTP server memory leak

Views: 8142 | Add Comments

The c1000k comet/push server icomet has just fixed a bug of memory leak. This bug is caused by not pairing every call to evhttp_send_reply_start() with evhttp_send_reply_end().

The icomet project use libevent’s HTTP server API to easily set up a comet server, when a client connected, it calls:

evhttp_send_reply_start(req, HTTP_OK, "OK");

To send chunked data. And after a few seconds(by configuration) the long-polling times out, it ends up the HTTP request by calling:

evhttp_send_reply_end(req);

But when the client interupts the request, the callback function registered by evhttp_connection_set_closecb() is called, and evhttp_send_reply_end() is not called, so libevent will never free that request, memory leaks!

Posted by ideawu at 2014-04-12 12:04:55

Leave a Comment