[tor-commits] [meek/master] close socket after finished

dcf at torproject.org dcf at torproject.org
Thu May 8 21:14:04 UTC 2014


commit 60129453352687685eda4b1498be2fe43ae8cb79
Author: Chang Lan <clan at eecs.berkeley.edu>
Date:   Thu Apr 24 15:02:51 2014 -0700

    close socket after finished
    
    otherwise Chrome will run out of file descriptors
---
 chrome/app/background.js |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/chrome/app/background.js b/chrome/app/background.js
index e9d7711..e26ab1b 100644
--- a/chrome/app/background.js
+++ b/chrome/app/background.js
@@ -1,7 +1,11 @@
 const DEBUG = false;
 
 function debug(str) {
-  if (DEBUG) { console.info(str); }
+  if (DEBUG) { console.debug(str); }
+}
+
+function info(str) {
+  console.info(str);
 }
 
 const IP = "127.0.0.1";
@@ -27,7 +31,7 @@ chrome.runtime.onMessageExternal.addListener(
 );
 
 function listenAndAccept(socketId) {
-  debug("listenAndAccept " + socketId);
+  info("listenAndAccept " + socketId);
   chrome.sockets.tcpServer.listen(socketId,
     IP, PORT, function(resultCode) {
       onListenCallback(socketId, resultCode)
@@ -48,6 +52,7 @@ function onListenCallback(socketId, resultCode) {
   });
   chrome.sockets.tcp.onReceive.addListener(onReceive);
   chrome.sockets.tcp.onReceiveError.addListener(function(info) {
+    chrome.sockets.tcp.close(info.socketId);
     debug("onReceiveError " + JSON.stringify(info));
   });
 }





More information about the tor-commits mailing list