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

fix(core): Use a copy of auth data when reconnecting #509

Merged
merged 2 commits into from
Oct 6, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions kazoo/protocol/connection.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Zookeeper Protocol Connection Handler"""
from binascii import hexlify
from contextlib import contextmanager
import copy
import logging
import random
import select
Expand Down Expand Up @@ -687,9 +688,14 @@ def _connect(self, host, port):
self._ro_mode = iter(self._server_pinger())
else:
self._ro_mode = None

# Get a copy of the auth data before iterating, in case it is
# changed.
client_auth_data_copy = copy.copy(client.auth_data)

if client.use_sasl and self.sasl_cli is None:
if PURESASL_AVAILABLE:
for scheme, auth in client.auth_data:
for scheme, auth in client_auth_data_copy:
if scheme == 'sasl':
username, password = auth.split(":")
self.sasl_cli = SASLClient(
Expand Down Expand Up @@ -717,7 +723,7 @@ def _connect(self, host, port):
client._session_callback(KeeperState.CONNECTED)
else:
client._session_callback(KeeperState.CONNECTED)
for scheme, auth in client.auth_data:
for scheme, auth in client_auth_data_copy:
if scheme == "digest":
ap = Auth(0, scheme, auth)
zxid = self._invoke(
Expand Down