From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 02EDE1395E2 for ; Tue, 15 Nov 2016 01:16:42 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 8A2E9E0B5B; Tue, 15 Nov 2016 01:16:39 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 708F7E0B5B for ; Tue, 15 Nov 2016 01:16:39 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 99D6334169F for ; Tue, 15 Nov 2016 01:16:38 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 0B311308 for ; Tue, 15 Nov 2016 01:16:37 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1479108199.613bb0efeebe6461b37df6baa862f4a3e67c94c7.zmedico@gentoo> Subject: [gentoo-commits] proj/mirrorselect:master commit in: mirrorselect/ X-VCS-Repository: proj/mirrorselect X-VCS-Files: mirrorselect/selectors.py X-VCS-Directories: mirrorselect/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 613bb0efeebe6461b37df6baa862f4a3e67c94c7 X-VCS-Branch: master Date: Tue, 15 Nov 2016 01:16:37 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 6e788e0e-caf6-4f7e-a254-4b2fe2e95c23 X-Archives-Hash: acf918c2424a8d867c840c041b1ce8fd commit: 613bb0efeebe6461b37df6baa862f4a3e67c94c7 Author: Zac Medico gentoo org> AuthorDate: Mon Nov 14 07:16:51 2016 +0000 Commit: Zac Medico gentoo org> CommitDate: Mon Nov 14 07:23:19 2016 +0000 URL: https://gitweb.gentoo.org/proj/mirrorselect.git/commit/?id=613bb0ef deeptime: cancel alarm signal before handling socket.error (bug 523312) In order to avoid a race condition, the alarm signal must be cancelled before socket.error is handled. X-Gentoo-Bug: 523312 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=523312 mirrorselect/selectors.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/mirrorselect/selectors.py b/mirrorselect/selectors.py index 1aa5f11..cf70b21 100644 --- a/mirrorselect/selectors.py +++ b/mirrorselect/selectors.py @@ -300,22 +300,24 @@ class Deep(object): ips = [] for addr_family in self._addr_families: try: - signal.alarm(self._dns_timeout) - for result in socket.getaddrinfo(url_parts.hostname, None, - addr_family, socket.SOCK_STREAM, 0, socket.AI_ADDRCONFIG): - family, _, __, ___, sockaddr = result - ip = sockaddr[0] - if family == socket.AF_INET6: - ip = "[%s]" % ip - ips.append(ip) + try: + signal.alarm(self._dns_timeout) + for result in socket.getaddrinfo( + url_parts.hostname, None, addr_family, + socket.SOCK_STREAM, 0, socket.AI_ADDRCONFIG): + family, _, __, ___, sockaddr = result + ip = sockaddr[0] + if family == socket.AF_INET6: + ip = "[%s]" % ip + ips.append(ip) + finally: + signal.alarm(0) except socket.error as e: self.output.write('deeptime(): dns error for host %s: %s\n' % (url_parts.hostname, e), 2) except TimeoutException: self.output.write('deeptime(): dns timeout for host %s\n' % url_parts.hostname, 2) - finally: - signal.alarm(0) if not ips: self.output.write('deeptime(): unable to resolve ip for host %s\n'