Browse Source

Cancel and join proxy send and receive threads on shutdown to avoid deref after removing their memory

master
Con Kolivas 11 years ago
parent
commit
007afe7ac8
  1. 8
      src/generator.c

8
src/generator.c

@ -961,9 +961,6 @@ static void *proxy_recv(void *arg)
ckpool_t *ckp = proxi->ckp; ckpool_t *ckp = proxi->ckp;
rename_proc("proxyrecv"); rename_proc("proxyrecv");
/* We don't wait for them to pthread_join in case it takes a while, so
* we detach the threads instead to clean up themselves */
pthread_detach(pthread_self());
while (42) { while (42) {
notify_instance_t *ni, *tmp; notify_instance_t *ni, *tmp;
@ -1043,7 +1040,6 @@ static void *proxy_send(void *arg)
connsock_t *cs = proxi->cs; connsock_t *cs = proxi->cs;
rename_proc("proxysend"); rename_proc("proxysend");
pthread_detach(pthread_self());
while (42) { while (42) {
notify_instance_t *ni; notify_instance_t *ni;
@ -1312,6 +1308,10 @@ static int proxy_mode(ckpool_t *ckp, proc_instance_t *pi)
free(proxi->enonce1); free(proxi->enonce1);
free(proxi->enonce1bin); free(proxi->enonce1bin);
free(proxi->sessionid); free(proxi->sessionid);
pthread_cancel(proxi->pth_psend);
pthread_cancel(proxi->pth_precv);
join_pthread(proxi->pth_psend);
join_pthread(proxi->pth_precv);
dealloc(si->data); dealloc(si->data);
dealloc(si->url); dealloc(si->url);
dealloc(si->auth); dealloc(si->auth);

Loading…
Cancel
Save