]> git.michaelhowe.org Git - packages/p/paho-mqtt.git/commitdiff
[443964] Fix possible race condition when connecting with TLS.
authorRoger A. Light <roger@atchoo.org>
Fri, 12 Sep 2014 20:34:30 +0000 (21:34 +0100)
committerRoger A. Light <roger@atchoo.org>
Fri, 12 Sep 2014 20:34:30 +0000 (21:34 +0100)
Fix possible race condition when connecting with TLS and publishing at
the same time, which could lead to PUBLISH data being sent before any
other messages and unencrypted. Closes #443964. Thanks to Hiram van
Paassen.

Bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=443964
Change-Id: I3945ed7d470b69fc939343fc21beffcd7315c502

ChangeLog.txt
src/paho/mqtt/client.py

index 5bec8cc979d7dec496c5fcb73ce40b4410b1df34..75d04c0ac355cfd4b4e44efc7a1ddf3d6bacc48d 100644 (file)
@@ -8,6 +8,10 @@ v1.0.2
 - Handle "unicode" type payloads on Python 2.7. Thanks to Luc Milland.
 - Fix reconnecting after sending more QoS>0 messages than inflight messages is
   set to, whilst connecting.  Closes #443935. Thanks to Hiram van Paassen.
+- Fix possible race condition when connecting with TLS and publishing at the
+  same time, which could lead to PUBLISH data being sent before any other
+  messages and unencrypted. Closes #443964. Thanks to Hiram van Paassen.
+
 
 v1.0.1
 ======
index 6b6afedc4a7d04947c8ce14d76859b26451c8505..3a9550928e52f3af53058d92101ddce3cf9f458d 100755 (executable)
@@ -724,16 +724,16 @@ class Client(object):
 
         try:
             if (sys.version_info[0] == 2 and sys.version_info[1] < 7) or (sys.version_info[0] == 3 and sys.version_info[1] < 2):
-                self._sock = socket.create_connection((self._host, self._port))
+                sock = socket.create_connection((self._host, self._port))
             else:
-                self._sock = socket.create_connection((self._host, self._port), source_address=(self._bind_address, 0))
+                sock = socket.create_connection((self._host, self._port), source_address=(self._bind_address, 0))
         except socket.error as err:
             if err.errno != errno.EINPROGRESS and err.errno != errno.EWOULDBLOCK and err.errno != EAGAIN:
                 raise
 
         if self._tls_ca_certs is not None:
             self._ssl = ssl.wrap_socket(
-                self._sock,
+                sock,
                 certfile=self._tls_certfile,
                 keyfile=self._tls_keyfile,
                 ca_certs=self._tls_ca_certs,
@@ -747,6 +747,7 @@ class Client(object):
                 else:
                     ssl.match_hostname(self._ssl.getpeercert(), self._host)
 
+        self._sock = sock
         self._sock.setblocking(0)
 
         return self._send_connect(self._keepalive, self._clean_session)