From 7dd8a27b399560dbea49f4782f66e1281bef2356 Mon Sep 17 00:00:00 2001 From: Stefan Bethge Date: Fri, 27 Jul 2007 18:19:09 +0000 Subject: [PATCH] fix #3186 (thanks dkirov) --- src/common/zeroconf/client_zeroconf.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/common/zeroconf/client_zeroconf.py b/src/common/zeroconf/client_zeroconf.py index e9d9f452d..66d5a28d0 100644 --- a/src/common/zeroconf/client_zeroconf.py +++ b/src/common/zeroconf/client_zeroconf.py @@ -121,6 +121,7 @@ class P2PClient(IdleObject): self.sock_type = TYPE_SERVER else: self.sock_type = TYPE_CLIENT + self.fd = -1 conn = P2PConnection('', _sock, host, port, self._caller, self.on_connect, self) self.sock_hash = conn._sock.__hash__ self.fd = conn.fd @@ -129,10 +130,14 @@ class P2PClient(IdleObject): for val in self.stanzaqueue: stanza, is_message = val if is_message: - if self.conn_holder.number_of_awaiting_messages.has_key(self.fd): - self.conn_holder.number_of_awaiting_messages[self.fd]+=1 + if self.fd == -1: + self._caller.dispatch('MSGERROR',[unicode(self.to), -1, \ + _('Connection to host could not be established'), None, None]) else: - self.conn_holder.number_of_awaiting_messages[self.fd]=1 + if self.conn_holder.number_of_awaiting_messages.has_key(self.fd): + self.conn_holder.number_of_awaiting_messages[self.fd]+=1 + else: + self.conn_holder.number_of_awaiting_messages[self.fd]=1 def add_stanza(self, stanza, is_message = False): if self.Connection: @@ -207,11 +212,11 @@ class P2PClient(IdleObject): def on_disconnect(self): if self.conn_holder: - if self.conn_holder.number_of_awaiting_messages.has_key(self.fd): - if self.conn_holder.number_of_awaiting_messages[self.fd] > 0: + if self.conn_holder.number_of_awaiting_messages.has_key(self.conn_holder.fd): + if self.conn_holder.number_of_awaiting_messages[self.conn_holder.fd] > 0: self._caller.dispatch('MSGERROR',[unicode(self.to), -1, \ _('Connection to host could not be established'), None, None]) - del self.conn_holder.number_of_awaiting_messages[self.fd] + del self.conn_holder.number_of_awaiting_messages[self.conn_holder.fd] self.conn_holder.remove_connection(self.sock_hash) if self.__dict__.has_key('Dispatcher'): self.Dispatcher.PlugOut()