Mailing List Archive

Add error handling so that disconnecting from a console
ChangeSet 1.1327.2.10, 2005/04/27 15:42:44+01:00, mjw@wray-m-3.hpl.hp.com

Add error handling so that disconnecting from a console
producing fast output doesn't cause an error loop.

Signed-off-by: Mike Wray <mike.wray@hp.com>



console.py | 18 ++++++++++++------
1 files changed, 12 insertions(+), 6 deletions(-)


diff -Nru a/tools/python/xen/xend/server/console.py b/tools/python/xen/xend/server/console.py
--- a/tools/python/xen/xend/server/console.py 2005-05-13 16:04:28 -04:00
+++ b/tools/python/xen/xend/server/console.py 2005-05-13 16:04:28 -04:00
@@ -2,7 +2,8 @@

import socket
import threading
-
+from errno import EAGAIN, EINTR, EWOULDBLOCK
+
from xen.web import reactor, protocol

from xen.lowlevel import xu
@@ -278,15 +279,20 @@
self.lock.acquire()
if self.closed():
return -1
- if not self.conn:
- return 0
- while not self.obuf.empty():
+ writes = 0
+ while self.conn and (writes < 100) and (not self.obuf.empty()):
try:
+ writes += 1
bytes = self.conn.write(self.obuf.peek())
if bytes > 0:
self.obuf.discard(bytes)
- except socket.error:
- pass
+ except socket.error, err:
+ if err.args[0] in (EWOULDBLOCK, EAGAIN, EINTR):
+ pass
+ else:
+ self.disconnect()
+ break
+
finally:
self.lock.release()
return 0

_______________________________________________
Xen-changelog mailing list
Xen-changelog@lists.xensource.com
http://lists.xensource.com/xen-changelog