summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRobey Pointer <robey@lag.net>2005-12-02 12:42:42 -0800
committerRobey Pointer <robey@lag.net>2005-12-02 12:42:42 -0800
commite7a45fee600489abdfe171cde7d393ad1b308af4 (patch)
tree88ecaade8c59df0ef7844b8637713ea29d4505eb
parentee8a4e4b2b4b9dff1dd43b1a5836400d7822fa2e (diff)
[project @ robey@lag.net-20051202204242-1fb4a6438ba50969]
nail down select() on EOF: occasionally a channel would be closed remotely but select() wouldn't trigger. when a channel gets EOF or is closed, set the pipe FOREVER.
-rw-r--r--paramiko/channel.py4
-rw-r--r--paramiko/pipe.py14
2 files changed, 15 insertions, 3 deletions
diff --git a/paramiko/channel.py b/paramiko/channel.py
index 97c7df5f..c4e8540c 100644
--- a/paramiko/channel.py
+++ b/paramiko/channel.py
@@ -996,7 +996,7 @@ class Channel (object):
self.in_buffer_cv.notifyAll()
self.in_stderr_buffer_cv.notifyAll()
if self.pipe is not None:
- self.pipe.set()
+ self.pipe.set_forever()
finally:
self.lock.release()
self._log(DEBUG, 'EOF received')
@@ -1022,6 +1022,8 @@ class Channel (object):
self.in_buffer_cv.notifyAll()
self.in_stderr_buffer_cv.notifyAll()
self.out_buffer_cv.notifyAll()
+ if self.pipe is not None:
+ self.pipe.set_forever()
def _send_eof(self):
# you are holding the lock.
diff --git a/paramiko/pipe.py b/paramiko/pipe.py
index 8c539877..cc28f43a 100644
--- a/paramiko/pipe.py
+++ b/paramiko/pipe.py
@@ -36,6 +36,7 @@ class PosixPipe (object):
def __init__ (self):
self._rfd, self._wfd = os.pipe()
self._set = False
+ self._forever = False
def close (self):
os.close(self._rfd)
@@ -45,7 +46,7 @@ class PosixPipe (object):
return self._rfd
def clear (self):
- if not self._set:
+ if not self._set or self._forever:
return
os.read(self._rfd, 1)
self._set = False
@@ -55,6 +56,10 @@ class PosixPipe (object):
return
self._set = True
os.write(self._wfd, '*')
+
+ def set_forever (self):
+ self._forever = True
+ self.set()
class WindowsPipe (object):
@@ -74,6 +79,7 @@ class WindowsPipe (object):
self._wsock, addr = serv.accept()
serv.close()
self._set = False
+ self._forever = False
def close (self):
self._rsock.close()
@@ -83,7 +89,7 @@ class WindowsPipe (object):
return self._rsock.fileno()
def clear (self):
- if not self._set:
+ if not self._set or self._forever:
return
self._rsock.recv(1)
self._set = False
@@ -93,3 +99,7 @@ class WindowsPipe (object):
return
self._set = True
self._wsock.send('*')
+
+ def set_forever (self):
+ self._forever = True
+ self.set()