[tor-commits] [flashproxy/master] Store references to proxy pairs to avoid garbage collection.

dcf at torproject.org dcf at torproject.org
Mon Jul 18 04:01:01 UTC 2011


commit 01d2047a74a61e1748361f5eaf3257b17b09f776
Author: David Fifield <david at bamsoftware.com>
Date:   Fri Jul 15 21:03:35 2011 +0000

    Store references to proxy pairs to avoid garbage collection.
    
    Adding an event listener is not enough to keep a proxy pair alive. Pairs
    could be garbage-collected at unpredictable times. We were able to
    provoke this by running more than one pair at a time with servers on
    localhost; perhaps it was the greater memory pressure (64 KB blocks at a
    time) that exposed it.
---
 swfcat.as |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/swfcat.as b/swfcat.as
index 4dea237..9f0a4f7 100644
--- a/swfcat.as
+++ b/swfcat.as
@@ -50,6 +50,9 @@ package
         /* Number of proxy pairs currently connected (up to
            MAX_NUM_PROXY_PAIRS). */
         private var num_proxy_pairs:int = 0;
+        /* References to active proxy pairs, to prevent them from being
+           garbage collected. */
+        private var proxy_pairs:Array;
 
         private var fac_addr:Object;
         
@@ -73,6 +76,8 @@ package
 
             badge = new Badge();
 
+            proxy_pairs = [];
+
             if (RATE_LIMIT)
                 rate_limit = new BucketRateLimit(RATE_LIMIT * RATE_LIMIT_HISTORY, RATE_LIMIT_HISTORY);
             else
@@ -189,9 +194,12 @@ package
                 puts("Error: " + e);
                 return;
             }
+            proxy_pairs.push(proxy_pair);
             proxy_pair.addEventListener(Event.COMPLETE, function(e:Event):void {
                 proxy_pair.log("Complete.");
                 num_proxy_pairs--;
+                /* Delete from the list of active proxy pairs. */
+                proxy_pairs.splice(proxy_pairs.indexOf(proxy_pair), 1);
                 badge.proxy_end();
             });
             proxy_pair.connect();





More information about the tor-commits mailing list