Ticket #3561: reuse_incoming_conn.patch

File reuse_incoming_conn.patch, 0.9 kB (added by datallah@…, 12 months ago)

Patch to identify connection origin for correct connection caching & reuse

  • src/common/zeroconf/client_zeroconf.py

     
    7979        def pollin(self): 
    8080                ''' accept a new incomming connection and notify queue''' 
    8181                sock = self.accept_conn() 
    82                 P2PClient(sock[0], sock[1][0], sock[1][1], self.conn_holder) 
     82                ''' loop through roster to find who has connected to us''' 
     83                from_jid = None 
     84                nameinfo = socket.getnameinfo(sock[1], 0) 
     85                ipaddr = socket.gethostbyname(nameinfo[0]) 
     86                for jid in self.conn_holder.getRoster().keys(): 
     87                        entry = self.conn_holder.getRoster().getItem(jid) 
     88                        if (entry['address'] == ipaddr): 
     89                                from_jid = jid 
     90                                break; 
     91                P2PClient(sock[0], sock[1][0], sock[1][1], self.conn_holder, [], from_jid) 
    8392         
    8493        def disconnect(self): 
    8594                ''' free all resources, we are not listening anymore '''