Parcourir la source

[hl] Ignore WANT_READ/WANT_WRITE errors when the socket is known to be blocking. (#11655)

Zeta il y a 1 an
Parent
commit
8149e5e664
1 fichiers modifiés avec 8 ajouts et 2 suppressions
  1. 8 2
      std/hl/_std/sys/ssl/Socket.hx

+ 8 - 2
std/hl/_std/sys/ssl/Socket.hx

@@ -50,7 +50,10 @@ private class SocketInput extends haxe.io.Input {
 		__s.handshake();
 		var r = @:privateAccess __s.ssl.recv(buf, pos, len);
 		if (r == -1)
-			throw haxe.io.Error.Blocked;
+			if (@:privateAccess __s.isBlocking)
+				return 0
+			else
+				throw haxe.io.Error.Blocked;
 		else if (r <= 0)
 			throw new haxe.io.Eof();
 		return r;
@@ -85,7 +88,10 @@ private class SocketOutput extends haxe.io.Output {
 		__s.handshake();
 		var r = @:privateAccess __s.ssl.send(buf, pos, len);
 		if (r == -1)
-			throw haxe.io.Error.Blocked;
+			if (@:privateAccess __s.isBlocking)
+				return 0
+			else
+				throw haxe.io.Error.Blocked;
 		else if (r < 0)
 			throw new haxe.io.Eof();
 		return r;