From 31e768580340328c979f04d2971123768b54f0f2 Mon Sep 17 00:00:00 2001 From: Adam Sutton Date: Tue, 22 Apr 2014 09:59:53 +0100 Subject: [PATCH] http: attempt to remove pointless errors on shutdown This is still not foolproof and I'm not 100% convinced there couldn't be an error (including crash?) on shutdown. --- src/http.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/http.c b/src/http.c index 07d52cf4..ddf70213 100644 --- a/src/http.c +++ b/src/http.c @@ -265,6 +265,9 @@ http_error(http_connection_t *hc, int error) { const char *errtxt = http_rc2str(error); char addrstr[50]; + + if (!http_server) return; + tcp_get_ip_str((struct sockaddr*)hc->hc_peer, addrstr, 50); tvhlog(LOG_ERR, "HTTP", "%s: %s -- %d", @@ -788,7 +791,7 @@ http_serve_requests(http_connection_t *hc, htsbuf_queue_t *spill) free(hc->hc_password); hc->hc_password = NULL; - } while(hc->hc_keep_alive); + } while(hc->hc_keep_alive && http_server); error: free(hdrline); @@ -868,12 +871,13 @@ http_server_done(void) http_path_t *hp; pthread_mutex_lock(&global_lock); + if (http_server) + tcp_server_delete(http_server); + http_server = NULL; while ((hp = LIST_FIRST(&http_paths)) != NULL) { LIST_REMOVE(hp, hp_link); free((void *)hp->hp_path); free(hp); } pthread_mutex_unlock(&global_lock); - if (http_server) - tcp_server_delete(http_server); }