tpws: fix cleanup in resolver_init

This commit is contained in:
bol-van 2024-04-05 12:21:40 +03:00
parent a760745452
commit d13e9cb092

View File

@ -181,12 +181,12 @@ bool resolver_init(int threads, int fd_signal_pipe)
pthread_attr_t attr; pthread_attr_t attr;
if (pthread_attr_init(&attr)) goto ex1; if (pthread_attr_init(&attr)) goto ex2;
// set minimum thread stack size // set minimum thread stack size
if (pthread_attr_setstacksize(&attr,20480)) if (pthread_attr_setstacksize(&attr,20480))
{ {
pthread_attr_destroy(&attr); pthread_attr_destroy(&attr);
goto ex1; goto ex2;
} }
for(t=0, resolver.threads=threads ; t<threads ; t++) for(t=0, resolver.threads=threads ; t<threads ; t++)
{ {
@ -197,15 +197,12 @@ bool resolver_init(int threads, int fd_signal_pipe)
} }
} }
pthread_attr_destroy(&attr); pthread_attr_destroy(&attr);
if (!resolver.threads) if (!resolver.threads) goto ex2;
{
// could not start any threads
free(resolver.thread);
goto ex1;
}
return true; return true;
ex2:
free(resolver.thread);
ex1: ex1:
pthread_mutex_destroy(&resolver.resolve_list_lock); pthread_mutex_destroy(&resolver.resolve_list_lock);
return false; return false;