[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#23615: 25.1.50; Which platforms can safely use getsockopt(,,SO_ERROR
From: |
Ken Brown |
Subject: |
bug#23615: 25.1.50; Which platforms can safely use getsockopt(,,SO_ERROR,,)? |
Date: |
Tue, 24 May 2016 20:26:13 -0400 |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 |
There are two places in process.c where getsockopt(,,SO_ERROR,,) is
used to check the status of a socket connection attempt. The first is
at line 3289, where it is done on all platforms except MS Windows. The
second is at line 5500, where it is done only on GNU/Linux:
#ifdef GNU_LINUX
/* getsockopt(,,SO_ERROR,,) is said to hang on some systems.
So only use it on systems where it is known to work. */
{
socklen_t xlen = sizeof (xerrno);
if (getsockopt (channel, SOL_SOCKET, SO_ERROR, &xerrno, &xlen))
xerrno = errno;
}
#else
{
struct sockaddr pname;
socklen_t pnamelen = sizeof (pname);
/* If connection failed, getpeername will fail. */
xerrno = 0;
if (getpeername (channel, &pname, &pnamelen) < 0)
{
/* Obtain connect failure code through error slippage. */
char dummy;
xerrno = errno;
if (errno == ENOTCONN && read (channel, &dummy, 1) < 0)
xerrno = errno;
}
}
#endif
It would be better to use it on as many platforms as possible, since
it's much more likely to give the real reason for a connection failure
than the "error slippage" method.
Ken
- bug#23615: 25.1.50; Which platforms can safely use getsockopt(,,SO_ERROR,,)?,
Ken Brown <=
- bug#23615: 25.1.50; Which platforms can safely use getsockopt(,,SO_ERROR,,)?, Eli Zaretskii, 2016/05/25
- bug#23615: 25.1.50; Which platforms can safely use getsockopt(,,SO_ERROR,,)?, Ken Brown, 2016/05/25
- bug#23615: 25.1.50; Which platforms can safely use getsockopt(,,SO_ERROR,,)?, Eli Zaretskii, 2016/05/28
- bug#23615: 25.1.50; Which platforms can safely use getsockopt(,,SO_ERROR,,)?, Ken Brown, 2016/05/28
- bug#23615: 25.1.50; Which platforms can safely use getsockopt(,,SO_ERROR,,)?, Eli Zaretskii, 2016/05/28