added more os2 code to handle connect() timeout
This commit is contained in:
parent
6ad0670eb3
commit
3021fd0a82
@ -115,6 +115,9 @@
|
|||||||
/* Define to 1 if you have the `gethostbyname' function. */
|
/* Define to 1 if you have the `gethostbyname' function. */
|
||||||
#undef HAVE_GETHOSTBYNAME
|
#undef HAVE_GETHOSTBYNAME
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `gettid' function. */
|
||||||
|
#undef HAVE_GETTID
|
||||||
|
|
||||||
/* Define to 1 if you have the `if_indextoname' function. */
|
/* Define to 1 if you have the `if_indextoname' function. */
|
||||||
#undef HAVE_IF_INDEXTONAME
|
#undef HAVE_IF_INDEXTONAME
|
||||||
|
|
||||||
|
@ -283,7 +283,7 @@ static int wait_for_data (qse_nwio_t* nwio, int tmout, int what)
|
|||||||
count[what]++;
|
count[what]++;
|
||||||
|
|
||||||
xret = select (&nwio->handle, count[0], count[1], 0, tmout);
|
xret = select (&nwio->handle, count[0], count[1], 0, tmout);
|
||||||
if (xret == -1)
|
if (xret <= -1)
|
||||||
{
|
{
|
||||||
nwio->errnum = syserr_to_errnum (sock_errno());
|
nwio->errnum = syserr_to_errnum (sock_errno());
|
||||||
return -1;
|
return -1;
|
||||||
@ -472,13 +472,11 @@ int qse_nwio_init (
|
|||||||
if (nwio->tmout.c >= 0 && (flags & QSE_NWIO_TCP))
|
if (nwio->tmout.c >= 0 && (flags & QSE_NWIO_TCP))
|
||||||
{
|
{
|
||||||
unsigned long cmd = 0;
|
unsigned long cmd = 0;
|
||||||
int wsaerr;
|
|
||||||
|
|
||||||
wsaerr = WSAGetLastError ();
|
if ((xret == SOCKET_ERROR && WSAGetLastError() != WSAEWOULDBLOCK) ||
|
||||||
if (ioctlsocket (nwio->handle, FIONBIO, &cmd) == SOCKET_ERROR ||
|
ioctlsocket (nwio->handle, FIONBIO, &cmd) == SOCKET_ERROR)
|
||||||
(xret == SOCKET_ERROR && wsaerr != WSAEWOULDBLOCK))
|
|
||||||
{
|
{
|
||||||
nwio->errnum = syserr_to_errnum (wsaerr);
|
nwio->errnum = syserr_to_errnum (WSAGetLastError());
|
||||||
goto oops;
|
goto oops;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -488,7 +486,7 @@ int qse_nwio_init (
|
|||||||
int xlen;
|
int xlen;
|
||||||
DWORD xerr;
|
DWORD xerr;
|
||||||
|
|
||||||
xlen = QSE_SIZEOF(xret);
|
xlen = QSE_SIZEOF(xerr);
|
||||||
if (getsockopt (nwio->handle, SOL_SOCKET, SO_ERROR, (char*)&xerr, &xlen) == SOCKET_ERROR)
|
if (getsockopt (nwio->handle, SOL_SOCKET, SO_ERROR, (char*)&xerr, &xlen) == SOCKET_ERROR)
|
||||||
{
|
{
|
||||||
nwio->errnum = syserr_to_errnum (WSAGetLastError());
|
nwio->errnum = syserr_to_errnum (WSAGetLastError());
|
||||||
@ -569,10 +567,57 @@ int qse_nwio_init (
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (connect (nwio->handle, (struct sockaddr*)&addr, addrlen) <= -1)
|
int xret;
|
||||||
|
|
||||||
|
if (nwio->tmout.c >= 0 && (flags & QSE_NWIO_TCP))
|
||||||
{
|
{
|
||||||
nwio->errnum = syserr_to_errnum (sock_errno());
|
int noblk = 1;
|
||||||
goto oops;
|
|
||||||
|
if (ioctl (nwio->handle, FIONBIO, &noblk, QSE_SIZEOF(noblk)) <= -1)
|
||||||
|
{
|
||||||
|
nwio->errnum = syserr_to_errnum (sock_errno());
|
||||||
|
goto oops;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
xret = connect (nwio->handle, (struct sockaddr*)&addr, addrlen);
|
||||||
|
|
||||||
|
if (nwio->tmout.c >= 0 && (flags & QSE_NWIO_TCP))
|
||||||
|
{
|
||||||
|
int noblk = 0;
|
||||||
|
|
||||||
|
if ((xret <= -1 && sock_errno() != SOCEWOULDBLOCK) ||
|
||||||
|
ioctl (nwio->handle, FIONBIO, &noblk, QSE_SIZEOF(noblk)) <= -1)
|
||||||
|
{
|
||||||
|
nwio->errnum = syserr_to_errnum (sock_errno());
|
||||||
|
goto oops;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wait_for_data (nwio, nwio->tmout.c, 1) <= -1) goto oops;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int xlen, xerr;
|
||||||
|
|
||||||
|
xlen = QSE_SIZEOF(xerr);
|
||||||
|
if (getsockopt (nwio->handle, SOL_SOCKET, SO_ERROR, (char*)&xerr, &xlen) <= -1)
|
||||||
|
{
|
||||||
|
nwio->errnum = syserr_to_errnum (sock_errno());
|
||||||
|
goto oops;
|
||||||
|
}
|
||||||
|
else if (xerr != 0)
|
||||||
|
{
|
||||||
|
nwio->errnum = syserr_to_errnum (xerr);
|
||||||
|
goto oops;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (xret <= -1)
|
||||||
|
{
|
||||||
|
nwio->errnum = syserr_to_errnum (sock_errno());
|
||||||
|
goto oops;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user