From: Jaroslav Kysela Date: Thu, 10 Mar 2016 17:20:01 +0000 (+0100) Subject: http server: add http_server_running flag (clang sanitizer) X-Git-Tag: v4.2.1~894 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ef01fca63a81e1e9a181a393610d6d0f78d07d93;p=thirdparty%2Ftvheadend.git http server: add http_server_running flag (clang sanitizer) --- diff --git a/src/http.c b/src/http.c index 7ae844e97..c0e3cf8c6 100644 --- a/src/http.c +++ b/src/http.c @@ -44,6 +44,7 @@ #endif void *http_server; +static int http_server_running; static http_path_list_t http_paths; @@ -404,7 +405,7 @@ http_error(http_connection_t *hc, int error) { const char *errtxt = http_rc2str(error); - if (!http_server) return; + if (!atomic_get(&http_server_running)) return; if (error != HTTP_STATUS_FOUND && error != HTTP_STATUS_MOVED) tvhlog(error < 400 ? LOG_INFO : LOG_ERR, "http", "%s: %s %s %s -- %d", @@ -1163,7 +1164,7 @@ http_serve_requests(http_connection_t *hc) hc->hc_logout_cookie = 0; - } while(hc->hc_keep_alive && http_server); + } while(hc->hc_keep_alive && atomic_get(&http_server_running)); error: free(hdrline); @@ -1223,6 +1224,7 @@ http_server_init(const char *bindaddr) .cancel = http_cancel }; http_server = tcp_server_create("http", "HTTP", bindaddr, tvheadend_webui_port, &ops, NULL); + atomic_set(&http_server_running, 1); } void @@ -1237,6 +1239,7 @@ http_server_done(void) http_path_t *hp; pthread_mutex_lock(&global_lock); + atomic_set(&http_server_running, 0); if (http_server) tcp_server_delete(http_server); http_server = NULL;