mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-27 06:33:21 -05:00
Add a fail_cb to evhttp_request for connection failures
The callback will be executed if a failure (timeout, read error) is detected on an incoming connection. This can be used to detect a client closing the connection while engaged in a chunked reply and actively pushing chunks to the client. Without this notification, it is impossible to know if/when a connection gets closed and react appropriately (ie. stop pushing chunks) resulting in a segfault.
This commit is contained in:
parent
e4fe084619
commit
1ffcbdae27
@ -229,6 +229,9 @@ struct {
|
|||||||
void (*cb)(struct evhttp_request *, void *);
|
void (*cb)(struct evhttp_request *, void *);
|
||||||
void *cb_arg;
|
void *cb_arg;
|
||||||
|
|
||||||
|
void (*fail_cb)(struct evhttp_request *, void *);
|
||||||
|
void *fail_cb_arg;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Chunked data callback - call for each completed chunk if
|
* Chunked data callback - call for each completed chunk if
|
||||||
* specified. If not specified, all the data is delivered via
|
* specified. If not specified, all the data is delivered via
|
||||||
|
@ -650,7 +650,11 @@ evhttp_connection_fail(struct evhttp_connection *evcon,
|
|||||||
* reply before the connection can be freed.
|
* reply before the connection can be freed.
|
||||||
*/
|
*/
|
||||||
if (evhttp_connection_incoming_fail(req, error) == -1)
|
if (evhttp_connection_incoming_fail(req, error) == -1)
|
||||||
evhttp_connection_free(evcon);
|
{
|
||||||
|
if (req->fail_cb)
|
||||||
|
req->fail_cb(req, req->fail_cb_arg);
|
||||||
|
evhttp_connection_free(evcon);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user