GNU bug report logs - #23615
25.1.50; Which platforms can safely use getsockopt(,,SO_ERROR,,)?

Previous Next

Package: emacs;

Reported by: Ken Brown <kbrown <at> cornell.edu>

Date: Wed, 25 May 2016 00:27:02 UTC

Severity: wishlist

Found in version 25.1.50

Done: Ken Brown <kbrown <at> cornell.edu>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Ken Brown <kbrown <at> cornell.edu>
Subject: bug#23615: closed (Re: bug#23615: 25.1.50; Which platforms can
 safely use getsockopt(,,SO_ERROR,,)?)
Date: Fri, 10 Jun 2016 12:39:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#23615: 25.1.50; Which platforms can safely use getsockopt(,,SO_ERROR,,)?

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 23615 <at> debbugs.gnu.org.

-- 
23615: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=23615
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Ken Brown <kbrown <at> cornell.edu>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 23615-done <at> debbugs.gnu.org
Subject: Re: bug#23615: 25.1.50; Which platforms can safely use
 getsockopt(,,SO_ERROR,,)?
Date: Fri, 10 Jun 2016 08:38:36 -0400
I see that you've made the change I suggested, so my test program is no 
longer relevant.  I'm closing the bug.

Ken

[Message part 3 (message/rfc822, inline)]
From: Ken Brown <kbrown <at> cornell.edu>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.1.50; Which platforms can safely use getsockopt(,,SO_ERROR,,)?
Date: Tue, 24 May 2016 20:26:13 -0400
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



This bug report was last modified 8 years and 351 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.