changeset 42:b8c9ddf320f8

Thread safety for bot.close_xmpp_connection(). Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Mon, 24 Aug 2009 18:06:37 +0200
parents 4c4f4ee72e17
children 9f72353e4064
files bot.py
diffstat 1 files changed, 2 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/bot.py
+++ b/bot.py
@@ -454,12 +454,14 @@ class bot(Thread):
 		if not self.xmpp_connections.has_key(nickname):
 			return
 		c = self.xmpp_connections[nickname]
+		c.lock.acquire()
 		c.used_by -= 1
 		if c.used_by < 1:
 			self.error('===> Debug: closing XMPP connection for "'+nickname+'"', debug=True)
 			self.xmpp_connections.pop(nickname)
 			del c
 		else:
+			c.lock.release()
 			self.error('===> Debug: XMPP connection for "'+nickname+'" is now used by '+str(c.used_by)+' bridges', debug=True)