serialcon: Fix tracebacks when we get EOF on stream

This commit is contained in:
Cole Robinson 2013-06-12 21:10:52 -04:00
parent 4201ef9e68
commit 436a5bfc8b

View File

@ -147,6 +147,7 @@ class LibvirtConsoleConnection(ConsoleConnection):
events & libvirt.VIR_EVENT_HANDLE_HANGUP):
logging.debug("Received stream ERROR/HANGUP, closing console")
self.close()
return
if events & libvirt.VIR_EVENT_HANDLE_READABLE:
try:
@ -157,9 +158,12 @@ class LibvirtConsoleConnection(ConsoleConnection):
return
if got == -2:
# This is basically EAGAIN
return
if len(got) == 0:
logging.debug("Received EOF from stream, closing")
self.close()
return
queued_text = bool(self.streamToTerminal)
self.streamToTerminal += got
@ -177,6 +181,7 @@ class LibvirtConsoleConnection(ConsoleConnection):
return
if done == -2:
# This is basically EAGAIN
return
self.terminalToStream = self.terminalToStream[done:]