@cryptotaxi247 / netdata-1 / commits / 878ec498d

properly reset host variables to allow multithreaded access

Costa Tsaousis (ktsaou) committed Jun 18, 2017 at 00:15 UTC 878ec498d7e93a53d6f53e9d13b64f512ebf14ab
1 file changed +6 -3
src/rrdhost.c
+6 -3
@@ -59,19 +59,22 @@ RRDHOST *rrdhost_find_by_hostname(const char *hostname, uint32_t hash) {
59 // RRDHOST - internal helpers
60
61 static inline void rrdhost_init_tags(RRDHOST *host, const char *tags) {
62 - freez((void *)host->tags);
62 + void *old = (void *)host->tags;
63 host->tags = (tags && *tags)?strdupz(tags):NULL;
64 + freez(old);
65 }
66
67 static inline void rrdhost_init_hostname(RRDHOST *host, const char *hostname) {
67 - freez(host->hostname);
68 + void *old = host->hostname;
69 host->hostname = strdupz(hostname);
70 host->hash_hostname = simple_hash(host->hostname);
71 + freez(old);
72 }
73
74 static inline void rrdhost_init_os(RRDHOST *host, const char *os) {
73 - freez((void *)host->os);
75 + void *old = (void *)host->os;
76 host->os = strdupz(os?os:"unknown");
77 + freez(old);
78 }
79
80 static inline void rrdhost_init_machine_guid(RRDHOST *host, const char *machine_guid) {