From patchwork Wed Jan 26 22:37:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 80563 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 95204B713C for ; Thu, 27 Jan 2011 09:37:32 +1100 (EST) Received: (qmail 2386 invoked by alias); 26 Jan 2011 22:37:31 -0000 Received: (qmail 2296 invoked by uid 22791); 26 Jan 2011 22:37:30 -0000 X-SWARE-Spam-Status: No, hits=-3.1 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_LOW, SPF_HELO_PASS, TW_CC, T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (74.125.121.67) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 26 Jan 2011 22:37:22 +0000 Received: from kpbe13.cbf.corp.google.com (kpbe13.cbf.corp.google.com [172.25.105.77]) by smtp-out.google.com with ESMTP id p0QMbIZP004087 for ; Wed, 26 Jan 2011 14:37:19 -0800 Received: from pzk27 (pzk27.prod.google.com [10.243.19.155]) by kpbe13.cbf.corp.google.com with ESMTP id p0QMbAfW030741 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NOT) for ; Wed, 26 Jan 2011 14:37:17 -0800 Received: by pzk27 with SMTP id 27so220356pzk.37 for ; Wed, 26 Jan 2011 14:37:17 -0800 (PST) Received: by 10.143.158.17 with SMTP id k17mr1028593wfo.95.1296081437390; Wed, 26 Jan 2011 14:37:17 -0800 (PST) Received: from coign.google.com (dhcp-172-22-124-221.mtv.corp.google.com [172.22.124.221]) by mx.google.com with ESMTPS id b11sm20829883wff.21.2011.01.26.14.37.16 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 26 Jan 2011 14:37:16 -0800 (PST) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: libgo patch committed: Check for EINTR in network code Date: Wed, 26 Jan 2011 14:37:15 -0800 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Since gccgo uses signals to manage garbage collection, having a system call return EINTR most likely just means that the garbage collector ran. This patch fixes the networking code in libgo to just retry after getting EINTR. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian diff -r 03b7a29fede7 libgo/go/net/fd.go --- a/libgo/go/net/fd.go Wed Jan 26 11:49:54 2011 -0800 +++ b/libgo/go/net/fd.go Wed Jan 26 14:35:06 2011 -0800 @@ -350,7 +350,7 @@ for { var errno int n, errno = syscall.Read(fd.sysfile.Fd(), p) - if errno == syscall.EAGAIN && fd.rdeadline >= 0 { + if (errno == syscall.EAGAIN || errno == syscall.EINTR) && fd.rdeadline >= 0 { pollserver.WaitRead(fd) continue } @@ -385,7 +385,7 @@ for { var errno int n, sa, errno = syscall.Recvfrom(fd.sysfd, p, 0) - if errno == syscall.EAGAIN && fd.rdeadline >= 0 { + if (errno == syscall.EAGAIN || errno == syscall.EINTR) && fd.rdeadline >= 0 { pollserver.WaitRead(fd) continue } @@ -418,7 +418,7 @@ for { var errno int n, oobn, flags, sa, errno = syscall.Recvmsg(fd.sysfd, p, oob, 0) - if errno == syscall.EAGAIN && fd.rdeadline >= 0 { + if (errno == syscall.EAGAIN || errno == syscall.EINTR) && fd.rdeadline >= 0 { pollserver.WaitRead(fd) continue } @@ -464,7 +464,7 @@ if nn == len(p) { break } - if errno == syscall.EAGAIN && fd.wdeadline >= 0 { + if (errno == syscall.EAGAIN || errno == syscall.EINTR) && fd.wdeadline >= 0 { pollserver.WaitWrite(fd) continue } @@ -500,7 +500,7 @@ var oserr os.Error for { errno := syscall.Sendto(fd.sysfd, p, 0, sa) - if errno == syscall.EAGAIN && fd.wdeadline >= 0 { + if (errno == syscall.EAGAIN || errno == syscall.EINTR) && fd.wdeadline >= 0 { pollserver.WaitWrite(fd) continue } @@ -534,7 +534,7 @@ for { var errno int errno = syscall.Sendmsg(fd.sysfd, p, oob, sa, 0) - if errno == syscall.EAGAIN && fd.wdeadline >= 0 { + if (errno == syscall.EAGAIN || errno == syscall.EINTR) && fd.wdeadline >= 0 { pollserver.WaitWrite(fd) continue } @@ -572,7 +572,7 @@ return nil, os.EINVAL } s, sa, e = syscall.Accept(fd.sysfd) - if e != syscall.EAGAIN { + if e != syscall.EAGAIN && e != syscall.EINTR { break } syscall.ForkLock.RUnlock()