@cryptotaxi247 / netdata-1 / commits / 7065ef2db

restore ad-hoc cancelability handling; prevent web access thread logs

Costa Tsaousis (ktsaou) committed Dec 28, 2017 at 05:02 UTC 7065ef2db866552c08f775c3a51d3b6873da24a3
7 files changed +19 -3
src/backends.c
+4
@@ -677,6 +677,8 @@ void *backends_main(void *ptr) {
677 // ------------------------------------------------------------------------
678 // add to the buffer the data we need to send to the backend
679
680 + netdata_thread_disable_cancelability();
681 +
682 size_t count_hosts = 0;
683 size_t count_charts_total = 0;
684 size_t count_dims_total = 0;
@@ -724,6 +726,8 @@ void *backends_main(void *ptr) {
726 }
727 rrd_unlock();
728
729 + netdata_thread_enable_cancelability();
730 +
731 debug(D_BACKEND, "BACKEND: buffer has %zu bytes, added metrics for %zu dimensions, of %zu charts, from %zu hosts", buffer_strlen(b), count_dims_total, count_charts_total, count_hosts);
732
733 // ------------------------------------------------------------------------
src/locks.c
+2 -2
@@ -6,7 +6,7 @@
6 static __thread int netdata_thread_first_cancelability = 0;
7 static __thread int netdata_thread_lock_cancelability = 0;
8
9 -static inline void netdata_thread_disable_cancelability(void) {
9 +inline void netdata_thread_disable_cancelability(void) {
10 int old;
11 int ret = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old);
12 if(ret != 0)
@@ -19,7 +19,7 @@ static inline void netdata_thread_disable_cancelability(void) {
19 }
20 }
21
22 -static inline void netdata_thread_enable_cancelability(void) {
22 +inline void netdata_thread_enable_cancelability(void) {
23 if(netdata_thread_lock_cancelability < 1) {
24 error("THREAD_CANCELABILITY: netdata_thread_enable_cancelability(): invalid thread cancelability count %d on thread %s - results will be undefined - please report this!", netdata_thread_lock_cancelability, netdata_thread_tag());
25 }
src/locks.h
+2
@@ -33,6 +33,8 @@ extern int netdata_rwlock_unlock_debug( const char *file, const char *function,
33 extern int netdata_rwlock_tryrdlock_debug( const char *file, const char *function, const unsigned long line, netdata_rwlock_t *rwlock);
34 extern int netdata_rwlock_trywrlock_debug( const char *file, const char *function, const unsigned long line, netdata_rwlock_t *rwlock);
35
36 +extern void netdata_thread_disable_cancelability(void);
37 +extern void netdata_thread_enable_cancelability(void);
38
39 #ifdef NETDATA_INTERNAL_CHECKS
40
src/plugin_tc.c
+2
@@ -978,8 +978,10 @@ void *tc_main(void *ptr) {
978 // debug(D_TC_LOOP, "END line");
979
980 if(likely(device)) {
981 + netdata_thread_disable_cancelability();
982 tc_device_commit(device);
983 // tc_device_free(device);
984 + netdata_thread_enable_cancelability();
985 }
986
987 device = NULL;
src/rrdpush.c
+4
@@ -582,6 +582,8 @@ void *rrdpush_sender_thread(void *ptr) {
582 // but the socket is in non-blocking mode
583 // so, we will not block at send()
584
585 + netdata_thread_disable_cancelability();
586 +
587 debug(D_STREAM, "STREAM: Getting exclusive lock on host...");
588 rrdpush_buffer_lock(host);
589
@@ -631,6 +633,8 @@ void *rrdpush_sender_thread(void *ptr) {
633 debug(D_STREAM, "STREAM: Releasing exclusive lock on host...");
634 rrdpush_buffer_unlock(host);
635
636 + netdata_thread_enable_cancelability();
637 +
638 // END RRDPUSH LOCKED SESSION
639 }
640 else {
src/rrdset.c
+4
@@ -1098,6 +1098,8 @@ void rrdset_done(RRDSET *st) {
1098 next_store_ut, // the timestamp in microseconds, of the next entry to store in the db
1099 update_every_ut = st->update_every * USEC_PER_SEC; // st->update_every in microseconds
1100
1101 + netdata_thread_disable_cancelability();
1102 +
1103 // a read lock is OK here
1104 rrdset_rdlock(st);
1105
@@ -1540,4 +1542,6 @@ void rrdset_done(RRDSET *st) {
1542 */
1543
1544 rrdset_unlock(st);
1545 +
1546 + netdata_thread_enable_cancelability();
1547 }
src/web_server.c
+1 -1
@@ -193,7 +193,7 @@ void *socket_listen_main_multi_threaded(void *ptr) {
193 else
194 web_client_set_tcp(w);
195
196 - if(netdata_thread_create(&w->thread, "WEB_CLIENT", NETDATA_THREAD_OPTION_DEFAULT, web_client_main, w) != 0)
196 + if(netdata_thread_create(&w->thread, "WEB_CLIENT", NETDATA_THREAD_OPTION_DONT_LOG, web_client_main, w) != 0)
197 WEB_CLIENT_IS_OBSOLETE(w);
198 }
199 }