You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# socket_read returns "" or false when the peer closes the connection.
1928
+
if ($result === false || $result === '') {
1929
+
$buff = false;
1930
+
} else {
1931
+
$buff .= $result;
1932
+
}
1928
1933
}
1929
1934
break;
1930
1935
case'stream':
1931
-
global$msgsock;
1932
1936
# Calling select here should ensure that we never try to read from a socket
1933
1937
# or pipe that doesn't currently have data. If that ever happens, the
1934
1938
# whole php process will block waiting for data that may never come.
@@ -1972,13 +1976,22 @@ function read($resource, $len=null) {
1972
1976
} else {
1973
1977
$tmp = fread($resource, $len);
1974
1978
$last_requested_len = $len;
1979
+
# An empty fread on a stream that stream_select reported as readable
1980
+
# means the peer has closed the connection (EOF). feof() may not return
1981
+
# true immediately on all stream types (e.g. SSL), so treat "" as EOF.
1982
+
if ($tmp === false || $tmp === '') {
1983
+
if (empty($buff)) {
1984
+
$buff = false;
1985
+
}
1986
+
break;
1987
+
}
1975
1988
$buff .= $tmp;
1976
1989
if (strlen($tmp) < $len) {
1977
1990
break;
1978
1991
}
1979
1992
}
1980
1993
1981
-
if ($resource != $msgsock) { my_print("buff: '$buff'"); }
1994
+
my_print("buff: '$buff'");
1982
1995
$r = Array($resource);
1983
1996
}
1984
1997
my_print(sprintf("Done with the big read loop on %s, got %d bytes, asked for %d bytes", get_resource_map_id($resource), strlen($buff), $last_requested_len));
0 commit comments