fixed ipv6/ipv4 switchover when ipv6 node is not reachable
All checks were successful
Altlinux build / build-alt (push) Successful in 2m38s
Archlinux build / build-arch (push) Successful in 3m0s
Archlinux build / make-test (push) Successful in 58s
Debian build / build-ubuntu (push) Successful in 3m48s

This commit is contained in:
Alexey Khromov 2025-04-22 23:30:59 +03:00
parent ccd0e13c05
commit c5dc00c084
2 changed files with 30 additions and 16 deletions

View File

@ -55,14 +55,25 @@ static int tcpip_connect2(struct addrinfo *ai)
{
DEB((D_INFO, "tcpip_connect2: socket error"));
}
else break;
else
{
DEB((D_INFO, "tcpip_connect2: socket opened - breaking"));
if( connect(fd, rai->ai_addr, rai->ai_addrlen) == -1 )
{
DEB((D_INFO, "tcpip_connect2: can't connect %s", hbuf));
logerr("can't connect to %s", hbuf);
close(fd);
} else
break;
}
DEB((D_INFO, "tcpip_connect2: socket not opened - returning"));
hbuf[0]='\0';
sbuf[0]='\0';
}
DEB((D_INFO, "tcpip_connect2: socket success: %d", fd));
if (fd < 0 )
{
DEB((D_INFO, "tcpip_connect2: can't create socket"));
logerr("can't create socket");
return(1);
}
@ -73,6 +84,7 @@ static int tcpip_connect2(struct addrinfo *ai)
(void)close(0);
if( dup(fd) != 0 )
{
DEB((D_INFO, "tcpip_connect2: can't dup socket to stdin"));
logerr("cannot dup socket to stdin");
return(1);
}
@ -92,7 +104,7 @@ static int tcpip_connect2(struct addrinfo *ai)
logerr("cannot dup stdin to stderr");
return(1);
}
DEB((D_INFO, "tcpip_connect2: stdin|out|err are connected"));
if( fd > 2 ) (void)close(fd);
/* switch off stdio buffering */
@ -103,22 +115,24 @@ static int tcpip_connect2(struct addrinfo *ai)
clearerr(stdin);
clearerr(stdout);
clearerr(stderr);
if( connect(0, rai->ai_addr, rai->ai_addrlen) == -1 )
{
logerr("can't connect to %s", hbuf);
close(0);
close(1);
close(2);
return 1;
}
DEB((D_INFO, "tcpip_connect2: start connecting"));
//if( connect(0, rai->ai_addr, rai->ai_addrlen) == -1 )
//{
// DEB((D_INFO, "tcpip_connect2: can't connect %s", hbuf));
// logerr("can't connect to %s", hbuf);
//
// close(0);
// close(1);
// close(2);
// return 1;
//}
if( tcpip_init() )
{
tcpip_shutdown();
return 1;
}
DEB((D_INFO, "tcpip_connect2: TCP/IP connect success to %s on service %s", hbuf, sbuf));
(void)log("TCP/IP connect success to %s on service %s", hbuf, sbuf);
return(0);

View File

@ -56,17 +56,17 @@ function testcomm() {
# Variant 3 works with sockets and pipes - not pty
case ${1} in
"PSTN")
socat -ly -Wlock EXEC:"${CURDIR}/runbfB.sh ${BFBIN} ${BFCFGB}" EXEC:"${CURDIR}/runbfA.sh ${BFBIN} ${BFCFGA}"
socat -T5 -ly -Wlock EXEC:"${CURDIR}/runbfB.sh ${BFBIN} ${BFCFGB}" EXEC:"${CURDIR}/runbfA.sh ${BFBIN} ${BFCFGA}"
sleep 2
;;
"IFC")
${CURDIR}/runbfC.sh ${BFBIN} ${BFCFGA} &
socat -ly -Wlock TCP4-LISTEN:59999 EXEC:"${CURDIR}/runbfD.sh ${BFBIN} ${BFCFGB}"
socat -ly -Wlock TCP4-LISTEN:59999,accept-timeout=3 EXEC:"${CURDIR}/runbfD.sh ${BFBIN} ${BFCFGB}"
sleep 2
;;
"BKP")
${CURDIR}/runbfE.sh ${BFBIN} ${BFCFGA} &
socat -ly -Wlock TCP4-LISTEN:59999 EXEC:"${CURDIR}/runbfF.sh ${BFBIN} ${BFCFGB}"
socat -ly -Wlock TCP4-LISTEN:59999,accept-timeout=3 EXEC:"${CURDIR}/runbfF.sh ${BFBIN} ${BFCFGB}"
sleep 2
;;
esac