mirror of
https://github.com/3proxy/3proxy.git
synced 2025-02-23 18:45:40 +08:00
Correct error handling for thread creation
Error handling corrected for thread creation in case of e.g. insufficient system resources.
This commit is contained in:
parent
085b47d64e
commit
a425dc40b3
@ -470,22 +470,26 @@ int MODULEMAINFUNC (int argc, char** argv){
|
|||||||
#else
|
#else
|
||||||
h = (HANDLE)CreateThread((LPSECURITY_ATTRIBUTES )NULL, (unsigned)32768, (BEGINTHREADFUNC)srv.pf, (void *) newparam, 0, &thread);
|
h = (HANDLE)CreateThread((LPSECURITY_ATTRIBUTES )NULL, (unsigned)32768, (BEGINTHREADFUNC)srv.pf, (void *) newparam, 0, &thread);
|
||||||
#endif
|
#endif
|
||||||
newparam->threadid = (unsigned)thread;
|
|
||||||
if (h) {
|
|
||||||
srv.childcount++;
|
srv.childcount++;
|
||||||
|
if (h) {
|
||||||
|
newparam->threadid = (unsigned)thread;
|
||||||
CloseHandle(h);
|
CloseHandle(h);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
myfree(newparam);
|
sprintf((char *)buf, "_beginthreadex(): %s", _strerror(NULL));
|
||||||
|
if(!srv.silent)(*srv.logfunc)(&defparam, buf);
|
||||||
|
freeparam(newparam);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if((error = pthread_create(&thread, &pa, (PTHREADFUNC)srv.pf, (void *)newparam))){
|
|
||||||
|
error = pthread_create(&thread, &pa, (PTHREADFUNC)srv.pf, (void *)newparam);
|
||||||
|
srv.childcount++;
|
||||||
|
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);
|
freeparam(newparam);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
srv.childcount++;
|
|
||||||
newparam->threadid = (unsigned)thread;
|
newparam->threadid = (unsigned)thread;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user