summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOlle Lundberg <geek@nerd.sh>2014-08-15 21:00:25 +0200
committerOlle Lundberg <geek@nerd.sh>2014-08-15 21:22:14 +0200
commitf8bc6dcc588bb48828b8b6b8bfdb0bd30b2c4fd4 (patch)
tree4161c24f1190cb773f4b11fa3674b8a86d41e6c2
parent3ee78214809f76181907808f9f27ed33a110be44 (diff)
Use new _send method.
-rw-r--r--paramiko/channel.py53
1 files changed, 12 insertions, 41 deletions
diff --git a/paramiko/channel.py b/paramiko/channel.py
index f5f86d7a..6ccdeea4 100644
--- a/paramiko/channel.py
+++ b/paramiko/channel.py
@@ -679,26 +679,11 @@ class Channel (object):
:raises socket.timeout: if no data could be sent before the timeout set
by `settimeout`.
"""
- size = len(s)
- self.lock.acquire()
- try:
- size = self._wait_for_send_window(size)
- # Instead of returning 0 here when the channel is closed, we might
- # want to raise EOFError or similar. Should we just do as in the
- # send_all method, raise a socket.error?
- if size == 0:
- # eof or similar
- return 0
- m = Message()
- m.add_byte(cMSG_CHANNEL_DATA)
- m.add_int(self.remote_chanid)
- m.add_string(s[:size])
- finally:
- self.lock.release()
- # Note: We release self.lock before calling _send_user_message.
- # Otherwise, we can deadlock during re-keying.
- self.transport._send_user_message(m)
- return size
+
+ m = Message()
+ m.add_byte(cMSG_CHANNEL_DATA)
+ m.add_int(self.remote_chanid)
+ return self._send(s, m)
def send_stderr(self, s):
"""
@@ -717,27 +702,13 @@ class Channel (object):
.. versionadded:: 1.1
"""
- size = len(s)
- self.lock.acquire()
- try:
- size = self._wait_for_send_window(size)
- # Instead of returning 0 here when the channel is closed, we might
- # want to raise EOFError or similar. Should we just do as in the
- # send_all method, raise a socket.error?
- if size == 0:
- # eof or similar
- return 0
- m = Message()
- m.add_byte(cMSG_CHANNEL_EXTENDED_DATA)
- m.add_int(self.remote_chanid)
- m.add_int(1)
- m.add_string(s[:size])
- finally:
- self.lock.release()
- # Note: We release self.lock before calling _send_user_message.
- # Otherwise, we can deadlock during re-keying.
- self.transport._send_user_message(m)
- return size
+
+ m = Message()
+ m.add_byte(cMSG_CHANNEL_EXTENDED_DATA)
+ m.add_int(self.remote_chanid)
+ m.add_int(1)
+ return self._send(s, m)
+
def sendall(self, s):
"""