From: Weston Andros Adamson <dros@primarydata.com>
To: bfields@fieldses.org
Cc: linux-nfs@vger.kernel.org, Weston Andros Adamson <dros@primarydata.com>
Subject: [PATCH pynfs v2 15/16] rpc: on socket error, close and mark pipe inactive
Date: Thu, 5 Jun 2014 09:55:43 -0400 [thread overview]
Message-ID: <1401976544-36374-16-git-send-email-dros@primarydata.com> (raw)
In-Reply-To: <1401976544-36374-1-git-send-email-dros@primarydata.com>
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 <dros@primarydata.com>
---
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]
--
1.8.5.2 (Apple Git-48)
next prev parent reply other threads:[~2014-06-05 13:56 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-05 13:55 [PATCH pynfs v2 00/16] prep for flex file layout server Weston Andros Adamson
2014-06-05 13:55 ` [PATCH pynfs v2 01/16] dataserver: reclaim_complete after create_session Weston Andros Adamson
2014-06-05 13:55 ` [PATCH pynfs v2 02/16] dataserver: only catch connection error Weston Andros Adamson
2014-06-05 13:55 ` [PATCH pynfs v2 03/16] 4.1 server: avoid traceback in DS disconnect() Weston Andros Adamson
2014-06-05 13:55 ` [PATCH pynfs v2 04/16] move .x files to subdir 'xdrdef' Weston Andros Adamson
2014-06-05 13:55 ` [PATCH pynfs v2 05/16] 4.1 client: remove unused imports Weston Andros Adamson
2014-06-05 13:55 ` [PATCH pynfs v2 06/16] 4.1 server: add -v flag & silence random output Weston Andros Adamson
2014-06-05 13:55 ` [PATCH pynfs v2 07/16] 4.1 server: add -s option to print summary of ops Weston Andros Adamson
2014-06-05 13:55 ` [PATCH pynfs v2 08/16] dataserver: make generic interface to ops Weston Andros Adamson
2014-06-05 13:55 ` [PATCH pynfs v2 09/16] dataserver: don't import * from nfs4 specific mods Weston Andros Adamson
2014-06-05 13:55 ` [PATCH pynfs v2 10/16] 4.1 server: move nfs4_ops.py to nfs_ops.py Weston Andros Adamson
2014-06-05 13:55 ` [PATCH pynfs v2 11/16] add mntv3, portmapv2 and nfsv3 .x files Weston Andros Adamson
2014-06-05 13:55 ` [PATCH pynfs v2 12/16] dataserver: separate generic and 4.1 code Weston Andros Adamson
2014-06-05 13:55 ` [PATCH pynfs v2 13/16] 4.1 server: add support for NFSv3 data servers Weston Andros Adamson
2014-06-05 13:55 ` [PATCH pynfs v2 14/16] 4.1 server: get rid of old op_getdeviceinfo Weston Andros Adamson
2014-06-05 13:55 ` Weston Andros Adamson [this message]
2014-06-05 13:55 ` [PATCH pynfs v2 16/16] nfs3clnt: reconnect when sending on inactive pipe Weston Andros Adamson
2014-06-05 14:19 ` [PATCH pynfs v2 00/16] prep for flex file layout server J. Bruce Fields
2014-06-05 14:22 ` Weston Andros Adamson
2014-06-05 14:24 ` J. Bruce Fields
2014-06-09 21:25 ` J. Bruce Fields
2014-06-10 1:41 ` Weston Andros Adamson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1401976544-36374-16-git-send-email-dros@primarydata.com \
--to=dros@primarydata.com \
--cc=bfields@fieldses.org \
--cc=linux-nfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).