[tor-commits] [Git][tpo/applications/tor-browser][tor-browser-102.9.0esr-12.5-1] fixup! Bug 10760: Integrate TorButton to TorBrowser core

Pier Angelo Vendrame (@pierov) git at gitlab.torproject.org
Fri Mar 31 15:53:18 UTC 2023



Pier Angelo Vendrame pushed to branch tor-browser-102.9.0esr-12.5-1 at The Tor Project / Applications / Tor Browser


Commits:
50201d24 by Pier Angelo Vendrame at 2023-03-31T17:43:49+02:00
fixup! Bug 10760: Integrate TorButton to TorBrowser core

Bug 40501: High CPU load after tor exits unexpectedly

When a peers (tor) disconnects, Firefox seems to keep the stream open,
and return 0 on available, rather than throwing.
So, as a matter of fact, we had a while trying to read 0 bytes without
any pause in _readLine, hence the 100% CPU usage.

- - - - -


1 changed file:

- toolkit/torbutton/modules/tor-control-port.js


Changes:

=====================================
toolkit/torbutton/modules/tor-control-port.js
=====================================
@@ -135,6 +135,18 @@ class AsyncSocket {
       this.inputQueue.push({
         onInputStreamReady: stream => {
           try {
+            if (!this.scriptableInputStream.available()) {
+              // This means EOF, but not closed yet. However, arriving at EOF
+              // should be an error condition for us, since we are in a socket,
+              // and EOF should mean peer disconnected.
+              // If the stream has been closed, this function itself should
+              // throw.
+              reject(
+                new Error("onInputStreamReady called without available bytes.")
+              );
+              return;
+            }
+
             // read our string from input stream
             let str = this.scriptableInputStream.read(
               this.scriptableInputStream.available()



View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/50201d244e436f88d49472861990a5371d5584f6

-- 
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/commit/50201d244e436f88d49472861990a5371d5584f6
You're receiving this email because of your account on gitlab.torproject.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.torproject.org/pipermail/tor-commits/attachments/20230331/0396e071/attachment-0001.htm>


More information about the tor-commits mailing list