Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
http server: add http_server_running flag (clang sanitizer)
  • Loading branch information
perexg committed Mar 10, 2016
1 parent a54d695 commit ef01fca
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/http.c
Expand Up @@ -44,6 +44,7 @@
#endif

void *http_server;
static int http_server_running;

static http_path_list_t http_paths;

Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand Down

0 comments on commit ef01fca

Please sign in to comment.