diff --git a/src/httpd.c b/src/httpd.c index 482288b8..b2b5d955 100644 --- a/src/httpd.c +++ b/src/httpd.c @@ -127,9 +127,7 @@ static pthread_t tid_httpd; static void stream_end(struct stream_ctx *st, int failed) { - /* This is an extension to the stock evhttp */ - st->req->fail_cb = NULL; - st->req->fail_cb_arg = NULL; + evhttp_connection_set_closecb(st->req->evcon, NULL, NULL); if (!failed) evhttp_send_reply_end(st->req); @@ -292,7 +290,7 @@ stream_chunk_raw_cb(int fd, short event, void *arg) } static void -stream_fail_cb(struct evhttp_request *req, void *arg) +stream_fail_cb(struct evhttp_connection *evcon, void *arg) { struct stream_ctx *st; @@ -583,9 +581,7 @@ httpd_stream_file(struct evhttp_request *req, int id) } #endif - /* This is an extension to the stock evhttp */ - req->fail_cb = stream_fail_cb; - req->fail_cb_arg = st; + evhttp_connection_set_closecb(req->evcon, stream_fail_cb, st); DPRINTF(E_INFO, L_HTTPD, "Kicking off streaming for %s\n", mfi->path); diff --git a/src/httpd_daap.c b/src/httpd_daap.c index 5028c2d7..9a5f9537 100644 --- a/src/httpd_daap.c +++ b/src/httpd_daap.c @@ -589,7 +589,7 @@ daap_session_find(struct evhttp_request *req, struct evkeyvalq *query, struct ev /* Update requests helpers */ static void -update_fail_cb(struct evhttp_request *req, void *arg) +update_fail_cb(struct evhttp_connection *evcon, void *arg) { struct daap_update_request *ur; struct daap_update_request *p; @@ -598,6 +598,8 @@ update_fail_cb(struct evhttp_request *req, void *arg) DPRINTF(E_DBG, L_DAAP, "Update request: client closed connection\n"); + evhttp_connection_set_closecb(ur->req->evcon, NULL, NULL); + if (ur == update_requests) update_requests = ur->next; else @@ -1179,12 +1181,10 @@ daap_reply_update(struct evhttp_request *req, struct evbuffer *evbuf, char **uri ur->next = update_requests; update_requests = ur; - /* Set fail_cb; this is an extension to the stock evhttp and will - * get called if the connection fails before we have an update to - * push out to the client. + /* If the connection fails before we have an update to push out + * to the client, we need to know. */ - req->fail_cb = update_fail_cb; - req->fail_cb_arg = ur; + evhttp_connection_set_closecb(req->evcon, update_fail_cb, ur); } static void diff --git a/src/httpd_dacp.c b/src/httpd_dacp.c index ad89f090..a57b9dca 100644 --- a/src/httpd_dacp.c +++ b/src/httpd_dacp.c @@ -67,7 +67,7 @@ static struct dacp_update_request *update_requests; /* Update requests helpers */ static void -update_fail_cb(struct evhttp_request *req, void *arg) +update_fail_cb(struct evhttp_connection *evcon, void *arg) { struct dacp_update_request *ur; struct dacp_update_request *p; @@ -76,6 +76,8 @@ update_fail_cb(struct evhttp_request *req, void *arg) DPRINTF(E_DBG, L_DACP, "Update request: client closed connection\n"); + evhttp_connection_set_closecb(ur->req->evcon, NULL, NULL); + if (ur == update_requests) update_requests = ur->next; else @@ -306,12 +308,10 @@ dacp_reply_playstatusupdate(struct evhttp_request *req, struct evbuffer *evbuf, ur->next = update_requests; update_requests = ur; - /* Set fail_cb; this is an extension to the stock evhttp and will - * get called if the connection fails before we have an update to - * push out to the client. + /* If the connection fails before we have an update to push out + * to the client, we need to know. */ - req->fail_cb = update_fail_cb; - req->fail_cb_arg = ur; + evhttp_connection_set_closecb(req->evcon, update_fail_cb, ur); } static void