Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ipa-replica-conncheck: fix race condition #309

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 11 additions & 6 deletions install/tools/ipa-replica-conncheck
Expand Up @@ -297,16 +297,18 @@ class PortResponder(threading.Thread):
self._close = False
self._close_lock = threading.Lock()
self.responder_data = 'FreeIPA'
self.ports_open = threading.Condition()
self.ports_opened = False
self.ports_open_cond = threading.Condition()

def run(self):
root_logger.debug('Starting listening thread.')

for port in self.ports:
self._bind_to_port(port.port, port.port_type)
with self.ports_open:
with self.ports_open_cond:
self.ports_opened = True
root_logger.debug('Ports opened, notify original thread')
self.ports_open.notify()
self.ports_open_cond.notify()

while not self._is_closing():
ready_socks, _socks1, _socks2 = select.select(
Expand Down Expand Up @@ -462,9 +464,12 @@ def main():

RESPONDER = PortResponder(required_ports)
RESPONDER.start()
with RESPONDER.ports_open:
RESPONDER.ports_open.wait()
root_logger.debug('Original thread resumed')

with RESPONDER.ports_open_cond:
if not RESPONDER.ports_opened:
root_logger.debug('Original thread stopped')
RESPONDER.ports_open_cond.wait()
root_logger.debug('Original thread resumed')

remote_check_opts = ['--replica %s' % options.hostname]

Expand Down