diff --git a/src/httpd.c b/src/httpd.c index 4d1b241e..8a5087bf 100644 --- a/src/httpd.c +++ b/src/httpd.c @@ -837,7 +837,7 @@ stream_chunk_raw_cb(int fd, short event, void *arg) } static void -stream_fail_cb(struct httpd_request *hreq, void *arg) +stream_fail_cb(void *arg) { struct stream_ctx *st = arg; diff --git a/src/httpd_daap.c b/src/httpd_daap.c index 800283ae..5fed4db9 100644 --- a/src/httpd_daap.c +++ b/src/httpd_daap.c @@ -300,7 +300,7 @@ update_refresh_cb(int fd, short event, void *arg) } static void -update_fail_cb(struct httpd_request *hreq, void *arg) +update_fail_cb(void *arg) { struct daap_update_request *ur = arg; diff --git a/src/httpd_dacp.c b/src/httpd_dacp.c index 6de4f342..f8ec8c9d 100644 --- a/src/httpd_dacp.c +++ b/src/httpd_dacp.c @@ -773,7 +773,7 @@ playstatusupdate_cb(int fd, short what, void *arg) } static void -update_fail_cb(struct httpd_request *hreq, void *arg) +update_fail_cb(void *arg) { struct dacp_update_request *ur = arg; diff --git a/src/httpd_internal.h b/src/httpd_internal.h index 9e57ce04..0157601e 100644 --- a/src/httpd_internal.h +++ b/src/httpd_internal.h @@ -57,7 +57,7 @@ typedef struct httpd_backend_data httpd_backend_data; typedef char *httpd_uri_path_parts[31]; typedef void (*httpd_request_cb)(struct httpd_request *hreq, void *arg); -typedef void (*httpd_close_cb)(struct httpd_request *hreq, void *arg); +typedef void (*httpd_close_cb)(void *arg); typedef void (*httpd_connection_chunkcb)(httpd_connection *conn, void *arg); typedef void (*httpd_query_iteratecb)(const char *key, const char *val, void *arg); diff --git a/src/httpd_libevhttp.c b/src/httpd_libevhttp.c index ac5a3bc4..6949df8a 100644 --- a/src/httpd_libevhttp.c +++ b/src/httpd_libevhttp.c @@ -248,6 +248,9 @@ httpd_request_new(httpd_backend *backend, httpd_server *server, const char *uri, return NULL; } +// Since this is async, libevent will already have closed the connection, so +// the parts of hreq that are from httpd_connection will now be invalid e.g. +// peer_address. static void closecb_worker(evutil_socket_t fd, short event, void *arg) { @@ -257,7 +260,7 @@ closecb_worker(evutil_socket_t fd, short event, void *arg) pthread_mutex_lock(&disconnect->lock); if (disconnect->cb) - disconnect->cb(hreq, disconnect->cbarg); + disconnect->cb(disconnect->cbarg); pthread_mutex_unlock(&disconnect->lock); @@ -289,7 +292,7 @@ closecb_httpd(httpd_connection *conn, void *arg) if (!disconnect->cb) return; - disconnect->cb(hreq, disconnect->cbarg); + disconnect->cb(disconnect->cbarg); httpd_send_reply_end(hreq); // hreq is now deallocated } diff --git a/src/httpd_streaming.c b/src/httpd_streaming.c index 16bf329f..1306e390 100644 --- a/src/httpd_streaming.c +++ b/src/httpd_streaming.c @@ -196,7 +196,7 @@ session_new(struct httpd_request *hreq, bool icy_is_requested) /* ----------------------------- Event callbacks ---------------------------- */ static void -conn_close_cb(struct httpd_request *hreq, void *arg) +conn_close_cb(void *arg) { struct streaming_session *session = arg;