Fix for connect back

This commit is contained in:
z3APA3A 2020-11-23 18:58:33 +03:00
parent 828e00e668
commit 4d63f957c2

View File

@ -32,6 +32,14 @@ void * threadfunc (void *p) {
dolog(param, (unsigned char *)"Connect back accept() failed"); dolog(param, (unsigned char *)"Connect back accept() failed");
continue; continue;
} }
{
#ifdef _WIN32
unsigned long ul=1;
ioctlsocket(param->remsock, FIONBIO, &ul);
#else
fcntl(param->remsock,F_SETFL,O_NONBLOCK | fcntl(param->remsock,F_GETFL));
#endif
}
#ifndef WITHMAIN #ifndef WITHMAIN
param->req = param->sinsr; param->req = param->sinsr;
if(param->srv->acl) param->res = checkACL(param); if(param->srv->acl) param->res = checkACL(param);
@ -42,7 +50,7 @@ void * threadfunc (void *p) {
continue; continue;
} }
#endif #endif
if(socksendto(param->remsock, (struct sockaddr*)&param->sinsr, (unsigned char *)"C", 1, CONNBACK_TO) != 1){ if(socksendto(param->remsock, (struct sockaddr*)&param->sinsr, (unsigned char *)"C", 1, CONNBACK_TO*1000) != 1){
dolog(param, (unsigned char *)"Connect back sending command failed"); dolog(param, (unsigned char *)"Connect back sending command failed");
so._closesocket(param->remsock); so._closesocket(param->remsock);
param->remsock = INVALID_SOCKET; param->remsock = INVALID_SOCKET;
@ -705,7 +713,8 @@ int MODULEMAINFUNC (int argc, char** argv){
usleep(SLEEPTIME); usleep(SLEEPTIME);
continue; continue;
} }
if(sockrecvfrom(new_sock,(struct sockaddr*)&defparam.sincr,buf,1,60) != 1 || *buf!='C') {
if(sockrecvfrom(new_sock,(struct sockaddr*)&defparam.sincr,buf,1,60*1000) != 1 || *buf!='C') {
so._closesocket(new_sock); so._closesocket(new_sock);
new_sock = INVALID_SOCKET; new_sock = INVALID_SOCKET;
usleep(SLEEPTIME); usleep(SLEEPTIME);
@ -763,8 +772,8 @@ int MODULEMAINFUNC (int argc, char** argv){
} }
continue; continue;
} }
setopts(new_sock, srv.clisockopts);
} }
setopts(new_sock, srv.clisockopts);
size = sizeof(defparam.sincl); size = sizeof(defparam.sincl);
if(so._getsockname(new_sock, (struct sockaddr *)&defparam.sincl, &size)){ if(so._getsockname(new_sock, (struct sockaddr *)&defparam.sincl, &size)){
sprintf((char *)buf, "getsockname(): %s", strerror(errno)); sprintf((char *)buf, "getsockname(): %s", strerror(errno));