mirror of
https://github.com/3proxy/3proxy.git
synced 2025-02-24 02:55:40 +08:00
Prevent deadlock on thread creation error
This commit is contained in:
parent
e0262c23b0
commit
46211c26d2
@ -643,6 +643,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
newparam->prev = newparam->next = NULL;
|
newparam->prev = newparam->next = NULL;
|
||||||
|
error = 0;
|
||||||
pthread_mutex_lock(&srv.counter_mutex);
|
pthread_mutex_lock(&srv.counter_mutex);
|
||||||
if(!srv.child){
|
if(!srv.child){
|
||||||
srv.child = newparam;
|
srv.child = newparam;
|
||||||
@ -665,7 +666,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
else {
|
else {
|
||||||
sprintf((char *)buf, "_beginthreadex(): %s", _strerror(NULL));
|
sprintf((char *)buf, "_beginthreadex(): %s", _strerror(NULL));
|
||||||
if(!srv.silent)(*srv.logfunc)(&defparam, buf);
|
if(!srv.silent)(*srv.logfunc)(&defparam, buf);
|
||||||
freeparam(newparam);
|
error = 1;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@ -674,13 +675,14 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
if(error){
|
if(error){
|
||||||
sprintf((char *)buf, "pthread_create(): %s", strerror(error));
|
sprintf((char *)buf, "pthread_create(): %s", strerror(error));
|
||||||
if(!srv.silent)(*srv.logfunc)(&defparam, buf);
|
if(!srv.silent)(*srv.logfunc)(&defparam, buf);
|
||||||
freeparam(newparam);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
newparam->threadid = (unsigned)thread;
|
newparam->threadid = (unsigned)thread;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
pthread_mutex_unlock(&srv.counter_mutex);
|
pthread_mutex_unlock(&srv.counter_mutex);
|
||||||
|
if(error) freeparam(newparam);
|
||||||
|
|
||||||
memset(&defparam.sincl, 0, sizeof(defparam.sincl));
|
memset(&defparam.sincl, 0, sizeof(defparam.sincl));
|
||||||
memset(&defparam.sincr, 0, sizeof(defparam.sincr));
|
memset(&defparam.sincr, 0, sizeof(defparam.sincr));
|
||||||
if(isudp) while(!srv.fds.events)usleep(SLEEPTIME);
|
if(isudp) while(!srv.fds.events)usleep(SLEEPTIME);
|
||||||
|
Loading…
Reference in New Issue
Block a user