Menu

#59 evhttp: extend close detection to incoming requests

open
None
5
2011-09-12
2010-01-30
No

evhttp can detect when a connection gets closed by the peer, but only for outgoing connections. For incoming connections, evhttp will only notice that the connection has gone down when it'll try to send a reply.

This is a problem for protocols implementing a push mechanism with HTTP requests that the server won't reply to until some event happens. In this context, the server needs to be notified when the connection goes down so as to perform cleanup tasks.

The proposed patch extends the detection mechanism used for outgoing connections and comes on top of my previous evhttp patch (submitted as #2862554) adding a "connection failed" callback to evhttp_request.

Like my previous patch, this is tested and included in my forked-daapd project. Works just fine.

Discussion

  • Julien BLACHE

    Julien BLACHE - 2010-01-30

    Proposed patch

     
  • Nick Mathewson

    Nick Mathewson - 2010-02-05
    • milestone: --> 774675
    • assigned_to: nobody --> nprovos
     
  • Anonymous

    Anonymous - 2011-08-17

    libevent-2.0 series also has this issue.
    Now it works fine with following patch(passed with make verify)

    --- http.c.old 2011-08-17 12:31:19.000000000 +0800
    +++ http.c 2011-08-17 12:32:20.000000000 +0800
    @@ -810,6 +810,10 @@
    * connection so that we can reply to it.
    */
    evcon->state = EVCON_WRITING;
    + /*
    + * enable READ event for detect connection error
    + */
    + bufferevent_enable(req->evcon->bufev, EV_READ);
    }

    /* notify the user of the request */

     
  • Nick Mathewson

    Nick Mathewson - 2011-09-12

    moving to the patches tracker where it belongs

     
  • Nick Mathewson

    Nick Mathewson - 2011-09-12
    • milestone: 774675 -->
     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.