2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-26 03:19:48 +00:00

Fix race condition on console connect

When data was coming in during logon, it was possible for
the handler to be called before rcpts member was initialized.
Correct by initializing rcpts prior to taking any other action.
This commit is contained in:
Jarrod Johnson 2014-02-01 09:39:57 -05:00
parent 086c18c641
commit dae131d40f
3 changed files with 17 additions and 2 deletions

View File

@ -16,11 +16,11 @@ _handled_consoles = {}
class _ConsoleHandler(object):
def __init__(self, node, configmanager):
self.rcpts = {}
self._console = plugin.handle_path("/node/%s/_console/session" % node,
"create", configmanager)
self.buffer = bytearray()
self._console.connect(self.get_console_output)
self.rcpts = {}
def unregister_rcpt(self, handle):
if handle in self.rcpts:

View File

@ -1,3 +1,11 @@
class ConsoleEvent(object):
"""This represents a number of specific events to be sent between
consoleserver and console objects. Disconnect indicates that the console
object has lost connection. The response to this will be to dispose of the
Console object and try to request a new one, rather than requesting
reconnect or anything like that. Break is a serial break."""
Disconnect, Break = range(2)
class Console(object):
"""This is the class defining the interface a console plugin must return
for the _console/session element"""

View File

@ -123,10 +123,17 @@ class IpmiConsole(confluent.interface.console.Console):
self.port = connparams['port']
# Cannot actually create console until 'connect', when we get callback
def handle_data(self, data):
if type(data) == dict:
#TODO: convert dict into a confluent.interface.console.ConsoleEvent
else:
self.datacallback(data)
def connect(self,callback):
global _ipmithread
global pullchain
global chainpulled
self.datacallback = callback
if _ipmithread is None:
pullchain = os.pipe()
_ipmithread = eventlet.spawn(_ipmi_evtloop)
@ -137,7 +144,7 @@ class IpmiConsole(confluent.interface.console.Console):
'password': self.password,
'kg': self.kg,
'force': True,
'iohandler': callback}, self.got_consobject))
'iohandler': self.handle_data}, self.got_consobject))
if not chainpulled:
chainpulled = True
os.write(pullchain[1],'1')