summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2013-06-20 09:19:53 -0700
committerLance Stout <lancestout@gmail.com>2013-06-20 09:19:53 -0700
commitf4c69d4045156bdc2ae5dfad86a4247a3833a3e0 (patch)
tree1e3d06b33822a46f1db44a9107ab3e8df08da8c2
parentbaf9aaf26c80c87e770cdf35b1fa4fe231663246 (diff)
parent1776e2edccf5f26d1d869791e19442ea35876bb1 (diff)
downloadslixmpp-f4c69d4045156bdc2ae5dfad86a4247a3833a3e0.tar.gz
slixmpp-f4c69d4045156bdc2ae5dfad86a4247a3833a3e0.tar.bz2
slixmpp-f4c69d4045156bdc2ae5dfad86a4247a3833a3e0.tar.xz
slixmpp-f4c69d4045156bdc2ae5dfad86a4247a3833a3e0.zip
Merge pull request #243 from anton-ryzhov/skip_eintr
Skip EINTR errors on raw sockets
-rw-r--r--sleekxmpp/xmlstream/filesocket.py9
-rw-r--r--sleekxmpp/xmlstream/xmlstream.py6
2 files changed, 14 insertions, 1 deletions
diff --git a/sleekxmpp/xmlstream/filesocket.py b/sleekxmpp/xmlstream/filesocket.py
index d4537998..53b83bc7 100644
--- a/sleekxmpp/xmlstream/filesocket.py
+++ b/sleekxmpp/xmlstream/filesocket.py
@@ -13,6 +13,7 @@
"""
from socket import _fileobject
+import errno
import socket
@@ -29,7 +30,13 @@ class FileSocket(_fileobject):
"""Read data from the socket as if it were a file."""
if self._sock is None:
return None
- data = self._sock.recv(size)
+ while True:
+ try:
+ data = self._sock.recv(size)
+ break
+ except socket.error as serr:
+ if serr.errno != errno.EINTR:
+ raise
if data is not None:
return data
diff --git a/sleekxmpp/xmlstream/xmlstream.py b/sleekxmpp/xmlstream/xmlstream.py
index 478bd9c0..6de19482 100644
--- a/sleekxmpp/xmlstream/xmlstream.py
+++ b/sleekxmpp/xmlstream/xmlstream.py
@@ -1294,6 +1294,9 @@ class XMLStream(object):
try:
sent += self.socket.send(data[sent:])
count += 1
+ except Socket.error as serr:
+ if serr.errno != errno.EINTR:
+ raise
except ssl.SSLError as serr:
if tries >= self.ssl_retry_max:
log.debug('SSL error: max retries reached')
@@ -1715,6 +1718,9 @@ class XMLStream(object):
try:
sent += self.socket.send(enc_data[sent:])
count += 1
+ except Socket.error as serr:
+ if serr.errno != errno.EINTR:
+ raise
except ssl.SSLError as serr:
if tries >= self.ssl_retry_max:
log.debug('SSL error: max retries reached')