mirror of
https://github.com/php/php-src.git
synced 2026-04-25 08:58:28 +02:00
d59aac58b3
The php_stream_read() and php_stream_write() functions now return an ssize_t value, with negative results indicating failure. Functions like fread() and fwrite() will return false in that case. As a special case, EWOULDBLOCK and EAGAIN on non-blocking streams should not be regarded as error conditions, and be reported as successful zero-length reads/writes instead. The handling of EINTR remains unclear and is internally inconsistent (e.g. some code-paths will automatically retry on EINTR, while some won't). I'm landing this now to make sure the stream wrapper ops API changes make it into 7.4 -- however, if the user-facing changes turn out to be problematic we have the option of clamping negative returns to zero in php_stream_read() and php_stream_write() to restore the old behavior in a relatively non-intrusive manner.
25 lines
514 B
PHP
25 lines
514 B
PHP
--TEST--
|
|
Bug #20134 (UDP reads from invalid ports)
|
|
--FILE--
|
|
<?php
|
|
|
|
$fp = fsockopen("udp://localhost", 65534, $errno, $errstr);
|
|
if (!$fp) {
|
|
/* UDP will never cause a connection error, as it is
|
|
* a connection-LESS protocol */
|
|
echo "ERROR: $errno - $errstr<br>\n";
|
|
}
|
|
else {
|
|
/* Likewise, writes will always appear to succeed */
|
|
$x = fwrite($fp,"\n");
|
|
var_dump($x);
|
|
/* But reads should always fail */
|
|
$content = fread($fp, 40);
|
|
var_dump($content);
|
|
fclose($fp);
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
int(1)
|
|
bool(false)
|