@cryptotaxi247 / netdata-1 / commits / ad1a317f2

exit the web client thread when netdata exits

Costa Tsaousis (ktsaou) committed Feb 21, 2017 at 22:58 UTC ad1a317f2f9a190df3a1af694a4ee55534a631d5
1 file changed +8
src/web_client.c
+8
@@ -2828,6 +2828,8 @@ void *web_client_main(void *ptr)
2828 log_access("%llu: %s port %s connected on thread task id %d", w->id, w->client_ip, w->client_port, gettid());
2829
2830 for(;;) {
2831 + if(unlikely(netdata_exit)) break;
2832 +
2833 if(unlikely(w->dead)) {
2834 debug(D_WEB_CLIENT, "%llu: client is dead.", w->id);
2835 break;
@@ -2879,6 +2881,8 @@ void *web_client_main(void *ptr)
2881 timeout = web_client_timeout * 1000;
2882 retval = poll(fds, fdmax, timeout);
2883
2884 + if(unlikely(netdata_exit)) break;
2885 +
2886 if(unlikely(retval == -1)) {
2887 if(errno == EAGAIN || errno == EINTR) {
2888 debug(D_WEB_CLIENT, "%llu: EAGAIN received.", w->id);
@@ -2893,6 +2897,8 @@ void *web_client_main(void *ptr)
2897 break;
2898 }
2899
2900 + if(unlikely(netdata_exit)) break;
2901 +
2902 int used = 0;
2903 if(w->wait_send && ofd->revents & POLLOUT) {
2904 used++;
@@ -2902,6 +2908,8 @@ void *web_client_main(void *ptr)
2908 }
2909 }
2910
2911 + if(unlikely(netdata_exit)) break;
2912 +
2913 if(w->wait_receive && (ifd->revents & POLLIN || ifd->revents & POLLPRI)) {
2914 used++;
2915 if(web_client_receive(w) < 0) {