[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] Handling the connection close



On Sun, Mar 20, 2016 at 11:31:29AM -0400, Michael wrote:
> This is an example in http.c
> 
> I wonder how can I get EVHTTP_CON_READING_ERROR?? Since when the connection
> is closed, I can only get an error code, and this code seems only telling
> your send or recv has finished or not.
> 
> evhttp_connection_read_on_write_error(struct evhttp_connection *evcon,
>     struct evhttp_request *req)
> {
>     struct evbuffer *buf;
> 
>     /** Second time, we can't read anything */
>     if (evcon->flags & EVHTTP_CON_READING_ERROR) {
>         evcon->flags &= ~EVHTTP_CON_READING_ERROR;
>         evhttp_connection_fail_(evcon, EVREQ_HTTP_EOF);
>         return;
>     }
> 
>     req->kind = EVHTTP_RESPONSE;
> 
>     buf = bufferevent_get_output(evcon->bufev);
>     evbuffer_unfreeze(buf, 1);
>     evbuffer_drain(buf, evbuffer_get_length(buf));
>     evbuffer_freeze(buf, 1);
> 
>     evhttp_start_read_(evcon);
>     evcon->flags |= EVHTTP_CON_READING_ERROR;
> }

Oh, this is kind of interesting:

Can you take a look at:
https://github.com/libevent/libevent/commit/2ff164abac40d827fd35e0b4436d22137c1cc0b4

(plus a referenced commit too).
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.