-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Return immediately when FD_SETSIZE is exceeded #9602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
--TEST-- | ||
Bug GH-9602 (stream_select does not abort upon exception or empty valid fd set) | ||
--SKIPIF-- | ||
<?php | ||
require_once('skipif.inc'); | ||
require_once('connect.inc'); | ||
require_once('skipifconnectfailure.inc'); | ||
|
||
if (!$IS_MYSQLND) | ||
die("skip mysqlnd only feature, compile PHP using --with-mysqli=mysqlnd"); | ||
|
||
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) | ||
die("skip cannot connect"); | ||
|
||
if (mysqli_get_server_version($link) < 50012) | ||
die("skip Test needs SQL function SLEEP() available as of MySQL 5.0.12"); | ||
|
||
if (!function_exists('posix_setrlimit') || !posix_setrlimit(POSIX_RLIMIT_NOFILE, 2048, -1)) | ||
die('skip Failed to set POSIX_RLIMIT_NOFILE'); | ||
?> | ||
--FILE-- | ||
<?php | ||
posix_setrlimit(POSIX_RLIMIT_NOFILE, 2048, -1); | ||
|
||
$fds = []; | ||
for ($i = 0; $i < 1023; $i++) { | ||
$fds[] = @fopen(__DIR__ . "/GH-9590-tmpfile.$i", 'w'); | ||
} | ||
|
||
require_once('connect.inc'); | ||
|
||
function get_connection() { | ||
global $host, $user, $passwd, $db, $port, $socket; | ||
|
||
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) | ||
printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error()); | ||
return $link; | ||
} | ||
|
||
|
||
$mysqli1 = get_connection(); | ||
$mysqli2 = get_connection(); | ||
|
||
var_dump(mysqli_query($mysqli1, "SELECT SLEEP(0.10)", MYSQLI_ASYNC | MYSQLI_USE_RESULT)); | ||
var_dump(mysqli_query($mysqli2, "SELECT SLEEP(0.20)", MYSQLI_ASYNC | MYSQLI_USE_RESULT)); | ||
|
||
$links = $errors = $reject = array($mysqli1, $mysqli2); | ||
var_dump(mysqli_poll($links, $errors, $reject, 0, 50000)); | ||
|
||
mysqli_close($mysqli1); | ||
mysqli_close($mysqli2); | ||
|
||
print "done!"; | ||
?> | ||
--EXPECTF-- | ||
bool(true) | ||
bool(true) | ||
|
||
Warning: mysqli_poll(): You MUST recompile PHP with a larger value of FD_SETSIZE. | ||
It is set to 1024, but you have descriptors numbered at least as high as %d. | ||
--enable-fd-setsize=%d is recommended, but you may want to set it | ||
to equal the maximum number of open files supported by your system, | ||
in order to avoid seeing this error again at a later date. in %s on line %d | ||
bool(false) | ||
done! | ||
--CLEAN-- | ||
<?php | ||
for ($i = 0; $i < 1023; $i++) { | ||
@unlink(__DIR__ . "/GH-9590-tmpfile.$i"); | ||
} | ||
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--TEST-- | ||
Bug GH-9590 001 (stream_select does not abort upon exception or empty valid fd set) | ||
--SKIPIF-- | ||
<?php | ||
if (!function_exists('posix_setrlimit') || !posix_setrlimit(POSIX_RLIMIT_NOFILE, 2048, -1)) { | ||
die('skip Failed to set POSIX_RLIMIT_NOFILE'); | ||
} | ||
?> | ||
--FILE-- | ||
<?php | ||
|
||
posix_setrlimit(POSIX_RLIMIT_NOFILE, 2048, -1); | ||
|
||
$fds = []; | ||
for ($i = 0; $i < 1023; $i++) { | ||
$fds[] = @fopen(__DIR__ . "/GH-9590-001-tmpfile.$i", 'w'); | ||
} | ||
|
||
list($a, $b) = stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP); | ||
|
||
$r = [$a]; | ||
$w = $e = []; | ||
var_dump(stream_select($r, $w, $e, PHP_INT_MAX)); | ||
|
||
?> | ||
--EXPECTF-- | ||
Warning: stream_select(): You MUST recompile PHP with a larger value of FD_SETSIZE. | ||
It is set to 1024, but you have descriptors numbered at least as high as %d. | ||
--enable-fd-setsize=%d is recommended, but you may want to set it | ||
to equal the maximum number of open files supported by your system, | ||
in order to avoid seeing this error again at a later date. in %s on line %d | ||
bool(false) | ||
--CLEAN-- | ||
<?php | ||
for ($i = 0; $i < 1023; $i++) { | ||
@unlink(__DIR__ . "/GH-9590-001-tmpfile.$i"); | ||
} | ||
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--TEST-- | ||
Bug GH-9590 002 (stream_select does not abort upon exception or empty valid fd set) | ||
--SKIPIF-- | ||
<?php | ||
if (!function_exists('posix_setrlimit') || !posix_setrlimit(POSIX_RLIMIT_NOFILE, 2048, -1)) { | ||
die('skip Failed to set POSIX_RLIMIT_NOFILE'); | ||
} | ||
?> | ||
--FILE-- | ||
<?php | ||
|
||
posix_setrlimit(POSIX_RLIMIT_NOFILE, 2048, -1); | ||
|
||
$fds = []; | ||
for ($i = 0; $i < 1023; $i++) { | ||
$fds[] = @fopen(__DIR__ . "/GH-9590-002-tmpfile.$i", 'w'); | ||
} | ||
|
||
list($a, $b) = stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP); | ||
|
||
set_error_handler(function($errno, $errstr) { throw new \Exception($errstr); }); | ||
|
||
$r = [$a]; | ||
$w = $e = []; | ||
var_dump(stream_select($r, $w, $e, PHP_INT_MAX)); | ||
|
||
?> | ||
--EXPECTF-- | ||
Fatal error: Uncaught Exception: stream_select(): You MUST recompile PHP with a larger value of FD_SETSIZE. | ||
It is set to 1024, but you have descriptors numbered at least as high as %d. | ||
--enable-fd-setsize=%d is recommended, but you may want to set it | ||
to equal the maximum number of open files supported by your system, | ||
in order to avoid seeing this error again at a later date. in %s:%d | ||
Stack trace:%a | ||
--CLEAN-- | ||
<?php | ||
for ($i = 0; $i < 1023; $i++) { | ||
@unlink(__DIR__ . "/GH-9590-002-tmpfile.$i"); | ||
} | ||
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: extra indent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many tests in this directory are like that, I tried to keep the existing style