]> arthur.barton.de Git - netdata.git/commitdiff
eliminate a memory leak while creating the streaming thread
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Thu, 23 Feb 2017 18:02:56 +0000 (20:02 +0200)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Thu, 23 Feb 2017 18:02:56 +0000 (20:02 +0200)
src/rrdpush.c

index 563a8d287942b8ac7ca51b42b84969c97481d3f1..417b95117a036325559f27e397ccff86cce95ab9 100644 (file)
@@ -607,15 +607,14 @@ int rrdpush_receiver_thread_spawn(RRDHOST *host, struct web_client *w, char *url
     rpt->client_ip    = strdupz(w->client_ip);
     rpt->client_port  = strdupz(w->client_port);
     rpt->update_every = update_every;
-
-    pthread_t *thread = mallocz(sizeof(pthread_t));
+    pthread_t thread;
 
     debug(D_SYSTEM, "Starting STREAM thread for client [%s]:%s.", w->client_ip, w->client_port);
 
-    if(pthread_create(thread, NULL, rrdpush_receiver_thread, (void *)rpt))
+    if(pthread_create(&thread, NULL, rrdpush_receiver_thread, (void *)rpt))
         error("failed to create new STREAM thread for client [%s]:%s.", w->client_ip, w->client_port);
 
-    else if(pthread_detach(*thread))
+    else if(pthread_detach(thread))
         error("Cannot request detach newly created thread for client [%s]:%s.", w->client_ip, w->client_port);
 
     // prevent the caller from closing the streaming socket