Merged in default: bug 656054 production-0.8 FENNEC_6_0_1_BUILD1 FENNEC_6_0_1_RELEASE FENNEC_6_0_2_BUILD1 FENNEC_6_0_2_BUILD2 FENNEC_6_0_2_RELEASE FENNEC_6_0_BUILD1 FENNEC_6_0_RELEASE FENNEC_6_0b2_BUILD1 FENNEC_6_0b2_RELEASE FENNEC_6_0b3_BUILD1 FENNEC_6_0b3_BUILD2 FENNEC_6_0b3_RELEASE FENNEC_6_0b4_BUILD1 FENNEC_6_0b4_RELEASE FENNEC_6_0b5_BUILD1 FENNEC_6_0b5_RELEASE FENNEC_6_0b6_BUILD1 FENNEC_6_0b6_RELEASE FENNEC_7_0b1_BUILD1 FENNEC_7_0b1_RELEASE FENNEC_7_0b2_BUILD1 FENNEC_7_0b2_RELEASE FENNEC_7_0b3_BUILD1 FENNEC_7_0b3_RELEASE FENNEC_7_0b4_BUILD1 FENNEC_7_0b4_BUILD2 FENNEC_7_0b4_RELEASE FENNEC_7_0b5_BUILD1 FENNEC_7_0b5_RELEASE FENNEC_7_0b6_BUILD1 FENNEC_7_0b6_RELEASE FIREFOX_3_6_18_BUILD1 FIREFOX_3_6_18_BUILD2 FIREFOX_3_6_18_RELEASE FIREFOX_3_6_19_BUILD1 FIREFOX_3_6_19_RELEASE FIREFOX_3_6_20_BUILD1 FIREFOX_3_6_20_RELEASE FIREFOX_3_6_21_BUILD1 FIREFOX_3_6_21_RELEASE FIREFOX_3_6_22_BUILD1 FIREFOX_3_6_22_BUILD2 FIREFOX_3_6_22_RELEASE FIREFOX_3_6_23_BUILD1 FIREFOX_3_6_23_RELEASE FIREFOX_5_0_1_BUILD1 FIREFOX_5_0_1_RELEASE FIREFOX_5_0_BUILD1 FIREFOX_5_0_RELEASE FIREFOX_5_0b2_BUILD1 FIREFOX_5_0b2_RELEASE FIREFOX_5_0b3_BUILD1 FIREFOX_5_0b3_RELEASE FIREFOX_5_0b4_BUILD1 FIREFOX_5_0b4_RELEASE FIREFOX_5_0b5_BUILD1 FIREFOX_5_0b5_RELEASE FIREFOX_5_0b6_BUILD1 FIREFOX_5_0b6_RELEASE FIREFOX_5_0b7_BUILD1 FIREFOX_5_0b7_RELEASE FIREFOX_6_0_1_BUILD1 FIREFOX_6_0_1_RELEASE FIREFOX_6_0_2_BUILD1 FIREFOX_6_0_2_BUILD2 FIREFOX_6_0_2_RELEASE FIREFOX_6_0_BUILD1 FIREFOX_6_0_RELEASE FIREFOX_6_0b1_BUILD1 FIREFOX_6_0b1_RELEASE FIREFOX_6_0b2_BUILD1 FIREFOX_6_0b2_RELEASE FIREFOX_6_0b3_BUILD1 FIREFOX_6_0b3_BUILD2 FIREFOX_6_0b3_RELEASE FIREFOX_6_0b4_BUILD1 FIREFOX_6_0b4_RELEASE FIREFOX_6_0b5_BUILD1 FIREFOX_6_0b5_RELEASE FIREFOX_7_0b1_BUILD1 FIREFOX_7_0b1_RELEASE FIREFOX_7_0b2_BUILD1 FIREFOX_7_0b2_RELEASE FIREFOX_7_0b3_BUILD1 FIREFOX_7_0b3_RELEASE FIREFOX_7_0b4_BUILD1 FIREFOX_7_0b4_BUILD2 FIREFOX_7_0b4_RELEASE FIREFOX_7_0b5_BUILD1 FIREFOX_7_0b5_RELEASE FIREFOX_7_0b6_BUILD1 FIREFOX_7_0b6_RELEASE
authorChris AtLee <catlee@mozilla.com>
Sat, 14 May 2011 12:18:15 -0400
branchproduction-0.8
changeset 195 3dc678eecd11a2adc1e51221887eb7cdc45b4b6d
parent 193 90b06b7447aeee2e53fc9fa36c67c38a14df316c (current diff)
parent 194 17c53d0c29a4160d3331348660fb20327ff28609 (diff)
child 303 aeaa057e9df6f7453ae745bf73d245a19764a5ba
push id86
push usercatlee@mozilla.com
push dateSat, 14 May 2011 16:18:42 +0000
bugs656054
Merged in default: bug 656054 changeset: 226:17c53d0c29a4 tag: tip parent: 219:ed19e0d5b2e5 user: Chris AtLee <catlee@mozilla.com> date: Fri May 13 17:02:59 2011 -0400 summary: Bug 656054: Monkey patch for leaking twisted RemoteReference. r=dustin
--- a/master/buildbot/master.py
+++ b/master/buildbot/master.py
@@ -552,16 +552,20 @@ class BuildMaster(service.MultiService):
             self.loadDatabase(db_spec)
 
         self.readConfig = False
         
         # create log_rotation object and set default parameters (used by WebStatus)
         self.log_rotation = LogRotation()
 
     def startService(self):
+        # Do our monkeying around first
+        import buildbot.monkey
+        buildbot.monkey.monkeypatch_twisted_cbLogin()
+
         service.MultiService.startService(self)
         if not self.readConfig:
             # TODO: consider catching exceptions during this call to
             # loadTheConfigFile and bailing (reactor.stop) if it fails,
             # since without a config file we can't do anything except reload
             # the config file, and it would be nice for the user to discover
             # this quickly.
             self.loadTheConfigFile()
new file mode 100644
--- /dev/null
+++ b/master/buildbot/monkey.py
@@ -0,0 +1,48 @@
+from twisted.python import log
+def monkeypatch_twisted_cbLogin():
+    """
+    Work around for http://twistedmatrix.com/trac/ticket/5079, which results in
+    leaking one RemoteReference every time a slave disconnects.
+    """
+    import twisted
+    from twisted.python.versions import Version
+
+    # This patch is known to work in versions 8.2.0 -> 11.0.0
+    # If your version is outside this range, but this monkey patch still
+    # applies, please update this version check!
+    # If your version of twisted doesn't need this, returning early is the
+    # right thing to do.
+    assert Version('twisted', 8, 2, 0) <= twisted.version <= \
+            Version('twisted', 11, 0, 0), \
+            "monkeypatch failed version check; see note in monkey.py"
+
+    import twisted.spread.pb
+    from twisted.spread.interfaces import IJellyable
+    from twisted.spread.pb import AsReferenceable
+
+    def monkeyed_cbLogin(self, (interface, avatar, logout)):
+        """
+        Ensure that the avatar to be returned to the client is jellyable and
+        set up disconnection notification to call the realm's logout object.
+        """
+        if not IJellyable.providedBy(avatar):
+            avatar = AsReferenceable(avatar, "perspective")
+
+        puid = avatar.processUniqueID()
+
+        # only call logout once, whether the connection is dropped (disconnect)
+        # or a logout occurs (cleanup), and be careful to drop the reference to
+        # it in either case 
+        logout = [ logout ]
+        def maybeLogout():
+            if not logout: return
+            fn = logout[0]
+            del logout[0]
+            fn()
+        self.broker._localCleanup[puid] = maybeLogout
+        self.broker.notifyOnDisconnect(maybeLogout)
+
+        return avatar
+
+    twisted.spread.pb._JellyableAvatarMixin._cbLogin = monkeyed_cbLogin
+    log.msg("monkeypatch_twisted_cbLogin applied")