From: Adam Sutton Date: Tue, 22 Apr 2014 08:59:53 +0000 (+0100) Subject: http: attempt to remove pointless errors on shutdown X-Git-Tag: v4.1~2129 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=31e768580340328c979f04d2971123768b54f0f2;p=thirdparty%2Ftvheadend.git 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. --- diff --git a/src/http.c b/src/http.c index 07d52cf4b..ddf702134 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); }