Anonymous avatar Anonymous committed 4a129a3

bug fixes. explicitly close socket to prevent stale fd

Comments (0)

Files changed (1)

 
       sock = new TCPClient(host, port);
       sock.onWriteComplete = callback(on_socket_write_done);
+      sock.onError = callback(on_socket_error);
 	}
 
 	public function setHeader( header : String, value : String ) {
 	function customRequest( post : Bool, ?method : String  ) {
 
         var host = url_regexp.matched(2);
-		var portString = url_regexp.matched(3);
+		var port_s = url_regexp.matched(3);
 		var request = url_regexp.matched(4);
 		if( request == "" ) request = "/";
 
 
         if( secure ) throw "Https is not supported";
 
-		var port = if ( portString == null || portString == "" ) secure ? 443 : 80 else Std.parseInt(portString.substr(1, portString.length - 1));
+		var port = if ( port_s == null || port_s == "" ) secure ? 443 : 80 else Std.parseInt(port_s.substr(1, port_s.length - 1));
 		var data;
 
 		var multipart = (file != null);
       catch( e : haxe.io.Eof ) return;
 
       sock.pauseRead();
-      sock.onDataReady = null;
+      sock.close();
+      sock = null;
       api.out.close();
 
       if( chunked && (chunk_size != null || chunk_buf != null) )
 
       api.out = null;
 
+
       return;
 
 	}
     function on_socket_write_done() { sock.read(); }
     function on_socket_error( ecode:Int, emsg:String ) {
       switch( ecode ) {
-        case 1: onClose();
+        case 1:
+          sock.close();
+          sock = null;
+          onClose();
         default:
           onErrorFull(ecode,emsg);
       }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.