[streaming] A bit of fixing up

This commit is contained in:
ejurgensen 2019-09-22 23:07:36 +02:00
parent 586dc4342d
commit 8cff93ce55

View File

@ -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); DPRINTF(E_INFO, L_STREAMING, "Stopping mp3 streaming to %s:%d\n", address, (int)port);
pthread_mutex_lock(&streaming_sessions_lck); 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 // already a dangling ptr (free'd in deinit()) at this stage
pthread_mutex_unlock(&streaming_sessions_lck); pthread_mutex_unlock(&streaming_sessions_lck);
return; return;
@ -148,9 +148,8 @@ streaming_close_cb(struct evhttp_connection *evcon, void *arg)
if (session->require_icy) if (session->require_icy)
--streaming_icy_clients; --streaming_icy_clients;
/* Possible libevent bug; ownership of evhttp_request with libevent // Valgrind says libevent doesn't free the request on disconnect (even though it owns it - libevent bug?),
* Workaround to force mem cleanup, prefered over evhttp_request_free() // so we do it with a reply end
*/
evhttp_send_reply_end(session->req); evhttp_send_reply_end(session->req);
free(session); free(session);
@ -160,6 +159,7 @@ streaming_close_cb(struct evhttp_connection *evcon, void *arg)
event_del(streamingev); event_del(streamingev);
event_del(metaev); event_del(metaev);
} }
pthread_mutex_unlock(&streaming_sessions_lck); pthread_mutex_unlock(&streaming_sessions_lck);
} }