From 8cff93ce55aba9c100289b6a2e1a7af912997997 Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Sun, 22 Sep 2019 23:07:36 +0200 Subject: [PATCH] [streaming] A bit of fixing up --- src/httpd_streaming.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/httpd_streaming.c b/src/httpd_streaming.c index ab6f2c69..53a6023a 100644 --- a/src/httpd_streaming.c +++ b/src/httpd_streaming.c @@ -115,9 +115,9 @@ streaming_close_cb(struct evhttp_connection *evcon, void *arg) DPRINTF(E_INFO, L_STREAMING, "Stopping mp3 streaming to %s:%d\n", address, (int)port); pthread_mutex_lock(&streaming_sessions_lck); - if (streaming_sessions == NULL) + if (!streaming_sessions) { - // This close comes duing deinit() - we don't free `this` since it is + // This close comes during deinit() - we don't free `this` since it is // already a dangling ptr (free'd in deinit()) at this stage pthread_mutex_unlock(&streaming_sessions_lck); return; @@ -136,7 +136,7 @@ streaming_close_cb(struct evhttp_connection *evcon, void *arg) { DPRINTF(E_LOG, L_STREAMING, "Bug! Got a failure callback for an unknown stream (%s:%d)\n", address, (int)port); free(this); - pthread_mutex_unlock(&streaming_sessions_lck); + pthread_mutex_unlock(&streaming_sessions_lck); return; } @@ -148,9 +148,8 @@ streaming_close_cb(struct evhttp_connection *evcon, void *arg) if (session->require_icy) --streaming_icy_clients; - /* Possible libevent bug; ownership of evhttp_request with libevent - * Workaround to force mem cleanup, prefered over evhttp_request_free() - */ + // Valgrind says libevent doesn't free the request on disconnect (even though it owns it - libevent bug?), + // so we do it with a reply end evhttp_send_reply_end(session->req); free(session); @@ -160,7 +159,8 @@ streaming_close_cb(struct evhttp_connection *evcon, void *arg) event_del(streamingev); event_del(metaev); } - pthread_mutex_unlock(&streaming_sessions_lck); + + pthread_mutex_unlock(&streaming_sessions_lck); } static void