From 71cedd4e4a882765862496d77c7f04173ab4712a Mon Sep 17 00:00:00 2001 From: kali Date: Thu, 13 Sep 2012 16:38:22 +0900 Subject: fix race condition on app init still fragile; sometimes the qt app inits faster and make the send command miss the not yet created managemente socket. --- src/leap/baseapp/eip.py | 9 +++++++-- src/leap/baseapp/leap_app.py | 2 +- src/leap/eip/openvpnconnection.py | 19 +++++++++---------- 3 files changed, 17 insertions(+), 13 deletions(-) (limited to 'src/leap') diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py index 515ae58d..68bd2f24 100644 --- a/src/leap/baseapp/eip.py +++ b/src/leap/baseapp/eip.py @@ -151,13 +151,18 @@ class EIPConductorAppMixin(object): # from openvpn manager) if not self.eip_service_started: + # there is a race condition + # going on here. Depending on how long we take + # to init the qt app, the management socket + # is not ready yet. return if self.conductor.with_errors: #XXX how to wait on pkexec??? #something better that this workaround, plz!! - time.sleep(5) - logger.debug('timeout') + #I removed the pkexec pass authentication at all. + #time.sleep(5) + #logger.debug('timeout') logger.error('errors. disconnect') self.start_or_stopVPN() # is stop diff --git a/src/leap/baseapp/leap_app.py b/src/leap/baseapp/leap_app.py index f91b2329..f861f945 100644 --- a/src/leap/baseapp/leap_app.py +++ b/src/leap/baseapp/leap_app.py @@ -45,7 +45,7 @@ class MainWindowMixin(object): self.headerLabelSub = QtGui.QLabel("trust your \ technolust") - pixmap = QtGui.QPixmap(':/images/leapfrog.jpg') + pixmap = QtGui.QPixmap(':/images/leap-color-small.png') frog_lbl = QtGui.QLabel() frog_lbl.setPixmap(pixmap) diff --git a/src/leap/eip/openvpnconnection.py b/src/leap/eip/openvpnconnection.py index c280f70d..b679a544 100644 --- a/src/leap/eip/openvpnconnection.py +++ b/src/leap/eip/openvpnconnection.py @@ -99,12 +99,9 @@ to be triggered for each one of them. ovpn_verbosity=self.ovpn_verbosity) except eip_exceptions.EIPNoPolkitAuthAgentAvailable: command = args = None - # XXX deprecate - #self.missing_auth_agent = True raise except eip_exceptions.EIPNoPkexecAvailable: command = args = None - #self.missing_pkexec = True raise # XXX if not command, signal error. @@ -159,7 +156,7 @@ to be triggered for each one of them. if self.command is None: raise eip_exceptions.EIPNoCommandError if self.subp is not None: - print('cowardly refusing to launch subprocess again') + logger.debug('cowardly refusing to launch subprocess again') return self._launch_openvpn() @@ -234,16 +231,17 @@ to be triggered for each one of them. """ Send a command to openvpn and return response as list """ - #logger.debug('connected? %s' % self.connected()) if not self.connected(): try: - #logger.debug('try to connect') self.connect_to_management() except eip_exceptions.MissingSocketError: - #XXX capture more helpful error - return self.make_error() - except: - raise + logger.warning('missing management socket') + # This should only happen briefly during + # the first invocation. Race condition make + # the polling begin before management socket + # is ready + return [] + #return self.make_error() try: if hasattr(self, 'tn'): self.tn.write(cmd + "\n") @@ -311,6 +309,7 @@ to be triggered for each one of them. """ OpenVPN command: status """ + #logger.debug('status called') status = self._send_command("status") return status -- cgit v1.2.3