From patchwork Thu Jun 5 13:55:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Weston Andros Adamson X-Patchwork-Id: 4305651 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0F343BEEAA for ; Thu, 5 Jun 2014 13:56:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2DF982018B for ; Thu, 5 Jun 2014 13:56:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5822E20117 for ; Thu, 5 Jun 2014 13:56:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751810AbaFEN4F (ORCPT ); Thu, 5 Jun 2014 09:56:05 -0400 Received: from mail-ie0-f178.google.com ([209.85.223.178]:57018 "EHLO mail-ie0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751894AbaFEN4C (ORCPT ); Thu, 5 Jun 2014 09:56:02 -0400 Received: by mail-ie0-f178.google.com with SMTP id rl12so870381iec.23 for ; Thu, 05 Jun 2014 06:56:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=TU41baPVj35XAO0h3HmnYfDUhHDYbZk9kTygGxZbFK4=; b=O0mF9L/lczSBhnV3TL3U8DNKhj/CvIptcXPt5yusBrd3GgyHykzFigiH2Ncr14IPjB R6jvHqiKRe9ePtNnsf7Np6D8vHHBJBF3tWmHfnS7Y4eG56Nh9yha+1ybWTR9jVY3q0o4 veUrCCvoiXxTMQZDw+kVRDSoE1MsIakUXVSZjM2oTZcz7jZGrn5zd4NNRP8hUt/W95XB Lv3cXJb0msUuTRSc3k/B7jwo4rthOWZ1ClAvv4ZEY7h4DDO5gLDuNQseXHif78Vunw+G MPpLaGUCBTChkvPmAHQmqfgilHVLUsQWVMSCFrvtq/QVa8zp+UT9Hg0PhFz+uYNXejWK F/cQ== X-Gm-Message-State: ALoCoQkzJcjZX56sVqUfca7uanJUE1Ef/tH+ZU5swQ2qoKWqhmTSE0fEcORVdOmIXNOYWX91S66d X-Received: by 10.50.43.225 with SMTP id z1mr20055630igl.24.1401976562125; Thu, 05 Jun 2014 06:56:02 -0700 (PDT) Received: from gavrio-wifi.robotsandstuff.fake (c-98-209-19-144.hsd1.mi.comcast.net. [98.209.19.144]) by mx.google.com with ESMTPSA id c8sm30697482igx.8.2014.06.05.06.56.01 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 05 Jun 2014 06:56:01 -0700 (PDT) From: Weston Andros Adamson To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org, Weston Andros Adamson Subject: [PATCH pynfs v2 15/16] rpc: on socket error, close and mark pipe inactive Date: Thu, 5 Jun 2014 09:55:43 -0400 Message-Id: <1401976544-36374-16-git-send-email-dros@primarydata.com> X-Mailer: git-send-email 1.8.5.2 (Apple Git-48) In-Reply-To: <1401976544-36374-1-git-send-email-dros@primarydata.com> References: <1401976544-36374-1-git-send-email-dros@primarydata.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP call _event_close() on socket errors instead of tracing back and mark the pipe as inactive so callers can reconnect as needed. Signed-off-by: Weston Andros Adamson --- rpc/rpc.py | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/rpc/rpc.py b/rpc/rpc.py index 250e945..4801883 100644 --- a/rpc/rpc.py +++ b/rpc/rpc.py @@ -351,6 +351,7 @@ class RpcPipe(Pipe): self._pending = {} # {xid:defer} self._lock = threading.Lock() # Protects fields below self._xid = 0 + self.set_active() def _get_xid(self): with self._lock: @@ -358,6 +359,15 @@ class RpcPipe(Pipe): self._xid = inc_u32(out) return out + def set_active(self): + self._active = True + + def clear_active(self): + self._active = False + + def is_active(self): + return self._active + def listen(self, xid, timeout=None): """Wait for a reply to a CALL.""" self._pending[xid].wait(timeout) @@ -500,15 +510,24 @@ class ConnectionHandler(object): log_p.warn(1, "polling error from %i" % fd) # STUB - now what? for fd in w: - self._event_write(fd) + try: + self._event_write(fd) + except socket.error, e: + self._event_close(fd) for fd in r: if fd in self.listeners: - self._event_connect_incoming(fd) + try: + self._event_connect_incoming(fd) + except socket.error, e: + self._event_close(fd) elif fd == self._alarm_poll.fileno(): commands = self._alarm_poll.recv(self.rsize) for c in commands: data = self._alarm.pop() - switch[c](data) + try: + switch[c](data) + except socket.error, e: + self._event_close(fd) else: try: data = self.sockets[fd].recv_records(self.rsize) @@ -557,6 +576,7 @@ class ConnectionHandler(object): self.writelist -= temp self.readlist -= temp self.errlist -= temp + self.sockets[fd].clear_active() self.sockets[fd].close() del self.sockets[fd]