]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
http: attempt to remove pointless errors on shutdown
authorAdam Sutton <dev@adamsutton.me.uk>
Tue, 22 Apr 2014 08:59:53 +0000 (09:59 +0100)
committerAdam Sutton <dev@adamsutton.me.uk>
Tue, 22 Apr 2014 09:01:38 +0000 (10:01 +0100)
This is still not foolproof and I'm not 100% convinced there couldn't be an
error (including crash?) on shutdown.

src/http.c

index 07d52cf4b176aea351d1bef7944a66ed1f51419b..ddf7021346717d37fec536c5e0c9fcb2540230b9 100644 (file)
@@ -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);
 }