From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ken Brown Newsgroups: gmane.emacs.bugs Subject: bug#23615: 25.1.50; Which platforms can safely use getsockopt(,,SO_ERROR,,)? Date: Tue, 24 May 2016 20:26:13 -0400 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1464136051 7423 80.91.229.3 (25 May 2016 00:27:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 25 May 2016 00:27:31 +0000 (UTC) To: 23615@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed May 25 02:27:19 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1b5MfO-0006p4-SQ for geb-bug-gnu-emacs@m.gmane.org; Wed, 25 May 2016 02:27:19 +0200 Original-Received: from localhost ([::1]:56041 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5MfK-0005K7-NC for geb-bug-gnu-emacs@m.gmane.org; Tue, 24 May 2016 20:27:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37005) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5MfE-0005Jo-19 for bug-gnu-emacs@gnu.org; Tue, 24 May 2016 20:27:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5Mf9-00046w-1V for bug-gnu-emacs@gnu.org; Tue, 24 May 2016 20:27:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:52761) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5Mf8-00046s-TF for bug-gnu-emacs@gnu.org; Tue, 24 May 2016 20:27:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1b5Mf8-000183-MA for bug-gnu-emacs@gnu.org; Tue, 24 May 2016 20:27:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ken Brown Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 25 May 2016 00:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 23615 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.14641359914301 (code B ref -1); Wed, 25 May 2016 00:27:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 25 May 2016 00:26:31 +0000 Original-Received: from localhost ([127.0.0.1]:36865 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b5Mec-00017J-S7 for submit@debbugs.gnu.org; Tue, 24 May 2016 20:26:31 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:45903) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b5Meb-000176-JD for submit@debbugs.gnu.org; Tue, 24 May 2016 20:26:29 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5MeV-000428-I4 for submit@debbugs.gnu.org; Tue, 24 May 2016 20:26:24 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:41874) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5MeV-00041z-Eu for submit@debbugs.gnu.org; Tue, 24 May 2016 20:26:23 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36857) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5MeT-0004xu-8j for bug-gnu-emacs@gnu.org; Tue, 24 May 2016 20:26:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5MeO-00041B-7Q for bug-gnu-emacs@gnu.org; Tue, 24 May 2016 20:26:20 -0400 Original-Received: from limerock01.mail.cornell.edu ([128.84.13.241]:58814) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5MeO-000416-1U for bug-gnu-emacs@gnu.org; Tue, 24 May 2016 20:26:16 -0400 X-CornellRouted: This message has been Routed already. Original-Received: from authusersmtp.mail.cornell.edu (granite4.serverfarm.cornell.edu [10.16.197.9]) by limerock01.mail.cornell.edu (8.14.4/8.14.4_cu) with ESMTP id u4P0QEZo020039 for ; Tue, 24 May 2016 20:26:14 -0400 Original-Received: from [192.168.1.3] (mta-68-175-148-36.twcny.rr.com [68.175.148.36] (may be forged)) (authenticated bits=0) by authusersmtp.mail.cornell.edu (8.14.4/8.12.10) with ESMTP id u4P0QDPk020886 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT) for ; Tue, 24 May 2016 20:26:14 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 X-PMX-Cornell-Gauge: Gauge=XXXXX X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:118645 Archived-At: 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