[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [torbutton/master] Bug 10804: Relocate event queue draining inside control port call.



commit bc58adf6e2ba152cca0d92f5f828e3b8b2d06798
Author: Agent Smith <smith007@xxxxxxx>
Date:   Fri Sep 19 18:28:40 2014 +0200

    Bug 10804: Relocate event queue draining inside control port call.
    
    This patch relocates the event queue draining hack from bug #9531 from New
    Identity to all control port commands. This should help address hangs at
    startup due to HTTPS activity (and other usage of the control port while the
    TLS stack is live).
---
 src/chrome/content/torbutton.js |   25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js
index 4cd9c3d..9ded64b 100644
--- a/src/chrome/content/torbutton.js
+++ b/src/chrome/content/torbutton.js
@@ -1428,6 +1428,19 @@ function torbutton_array_to_hexdigits(array) {
 // Executes a command on the control port.
 // Return a string response upon success and null upon error.
 function torbutton_send_ctrl_cmd(command) {
+
+  // We spin the event queue until it is empty and we can be sure that sending
+  // NEWNYM is not leading to a deadlock (see bug 9531 comment 23 for an
+  // invstigation on why and when this may happen). This is surrounded by
+  // suppressing/unsuppressing user initiated events in a window's document to
+  // be sure that these events are not interfering with processing events being
+  // in the event queue.
+  var thread = Cc["@mozilla.org/thread-manager;1"].
+               getService(Ci.nsIThreadManager).currentThread;
+  m_tb_domWindowUtils.suppressEventHandling(true);
+  while (thread.processNextEvent(false)) {}
+  m_tb_domWindowUtils.suppressEventHandling(false);
+
   try {
     var socketTransportService = Components.classes["@mozilla.org/network/socket-transport-service;1"]
         .getService(Components.interfaces.nsISocketTransportService);
@@ -1700,18 +1713,6 @@ function torbutton_do_new_identity() {
            getService(Ci.nsIPermissionManager);
   pm.removeAll();
 
-  // We spin the event queue until it is empty and we can be sure that sending
-  // NEWNYM is not leading to a deadlock (see bug 9531 comment 23 for an
-  // invstigation on why and when this may happen). This is surrounded by
-  // suppressing/unsuppressing user initiated events in a window's document to
-  // be sure that these events are not interfering with processing events being
-  // in the event queue.
-  var thread = Cc["@mozilla.org/thread-manager;1"].
-               getService(Ci.nsIThreadManager).currentThread;
-  m_tb_domWindowUtils.suppressEventHandling(true);
-  while (thread.processNextEvent(false)) {}
-  m_tb_domWindowUtils.suppressEventHandling(false);
-
   torbutton_log(3, "New Identity: Sending NEWNYM");
 
   // We only support TBB for newnym.



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits