eliminate a memory leak while creating the streaming thread
Costa Tsaousis (ktsaou) committed
Feb 23, 2017 at 20:02 UTC
82f7432f0a7f9f154a09e8e14947c79ad9d34643
1 file changed
+3
-4
src/rrdpush.c
+3
-4
@@ -607,15 +607,14 @@ int rrdpush_receiver_thread_spawn(RRDHOST *host, struct web_client *w, char *url
607
rpt->client_ip = strdupz(w->client_ip);
608
rpt->client_port = strdupz(w->client_port);
609
rpt->update_every = update_every;
610
-
611
- pthread_t *thread = mallocz(sizeof(pthread_t));
610
+ pthread_t thread;
611
612
debug(D_SYSTEM, "Starting STREAM thread for client [%s]:%s.", w->client_ip, w->client_port);
613
615
- if(pthread_create(thread, NULL, rrdpush_receiver_thread, (void *)rpt))
614
+ if(pthread_create(&thread, NULL, rrdpush_receiver_thread, (void *)rpt))
615
error("failed to create new STREAM thread for client [%s]:%s.", w->client_ip, w->client_port);
616
618
- else if(pthread_detach(*thread))
617
+ else if(pthread_detach(thread))
618
error("Cannot request detach newly created thread for client [%s]:%s.", w->client_ip, w->client_port);
619
620
// prevent the caller from closing the streaming socket