unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#23615: 25.1.50; Which platforms can safely use getsockopt(,,SO_ERROR,,)?
@ 2016-05-25  0:26 Ken Brown
  2016-05-25 16:24 ` Eli Zaretskii
  2016-06-02 16:00 ` Paul Eggert
  0 siblings, 2 replies; 12+ messages in thread
From: Ken Brown @ 2016-05-25  0:26 UTC (permalink / raw)
  To: 23615

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





^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2016-06-10 17:48 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-25  0:26 bug#23615: 25.1.50; Which platforms can safely use getsockopt(,,SO_ERROR,,)? Ken Brown
2016-05-25 16:24 ` Eli Zaretskii
2016-05-25 19:21   ` Ken Brown
2016-05-28 12:57     ` Eli Zaretskii
2016-05-28 17:18       ` Ken Brown
2016-05-28 17:48         ` Eli Zaretskii
2016-06-02 16:00 ` Paul Eggert
2016-06-02 17:17   ` Ken Brown
2016-06-02 17:55     ` Ken Brown
2016-06-02 18:55       ` Ken Brown
2016-06-10 12:38         ` Ken Brown
2016-06-10 17:48           ` Paul Eggert

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).