Ignore:
Timestamp:
Mar 7, 2011, 7:40:16 PM (10 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Message:

Fix race condition and nesting errors when adding a new subprotocol handler.

This fixes two related issues with adding a new subprotocol handler:

  • Adding a handler when the stream is not yet initialized (authenticated) does not cause connectionMade to be called.
  • Adding a handler in connectionMade, connectionInitialized, or connectionLost modifies the lists of handlers iterated over, causing some methods being called too often.

Author: ff, kandaurovoleg, ralphm.
Fixes: #48.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wokkel/subprotocols.py

    r98 r99  
    186186        # get protocol handler up to speed when a connection has already
    187187        # been established
    188         if self.xmlstream and self._initialized:
     188        if self.xmlstream:
    189189            handler.makeConnection(self.xmlstream)
     190        if self._initialized:
    190191            handler.connectionInitialized()
    191192
     
    211212        self.xmlstream = xs
    212213
    213         for e in self:
     214        for e in list(self):
    214215            e.makeConnection(xs)
    215216
     
    230231        # Notify all child services which implement
    231232        # the IService interface
    232         for e in self:
     233        for e in list(self):
    233234            e.connectionInitialized()
    234235
     
    265266        # Notify all child services which implement
    266267        # the IService interface
    267         for e in self:
     268        for e in list(self):
    268269            e.connectionLost(reason)
    269270
Note: See TracChangeset for help on using the changeset viewer.