Skip to content

Store the original path used to open xport stream #11113

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ext/standard/tests/network/socket_get_status_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fclose($server);

?>
--EXPECTF--
array(7) {
array(8) {
["timed_out"]=>
bool(false)
["blocked"]=>
Expand All @@ -32,4 +32,6 @@ array(7) {
int(0)
["seekable"]=>
bool(false)
["uri"]=>
string(21) "tcp://127.0.0.1:%d"
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fclose($tcp_socket);

?>
--EXPECTF--
array(7) {
array(8) {
["timed_out"]=>
bool(false)
["blocked"]=>
Expand All @@ -24,4 +24,6 @@ array(7) {
int(0)
["seekable"]=>
bool(false)
["uri"]=>
string(21) "tcp://127.0.0.1:31330"
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ var_dump(stream_get_meta_data($client));
?>
--EXPECTF--
Write some data:
array(7) {
array(8) {
["timed_out"]=>
bool(false)
["blocked"]=>
Expand All @@ -53,11 +53,13 @@ array(7) {
int(0)
["seekable"]=>
bool(false)
["uri"]=>
string(21) "tcp://127.0.0.1:31331"
}


Read a line from the client, causing data to be buffered:
array(7) {
array(8) {
["timed_out"]=>
bool(false)
["blocked"]=>
Expand All @@ -72,11 +74,13 @@ array(7) {
int(15)
["seekable"]=>
bool(false)
["uri"]=>
string(21) "tcp://127.0.0.1:31331"
}


Read 3 bytes of data from the client:
array(7) {
array(8) {
["timed_out"]=>
bool(false)
["blocked"]=>
Expand All @@ -91,11 +95,13 @@ array(7) {
int(12)
["seekable"]=>
bool(false)
["uri"]=>
string(21) "tcp://127.0.0.1:31331"
}


Close the server side socket and read the remaining data from the client:
array(7) {
array(8) {
["timed_out"]=>
bool(false)
["blocked"]=>
Expand All @@ -110,4 +116,6 @@ array(7) {
int(0)
["seekable"]=>
bool(false)
["uri"]=>
string(21) "tcp://127.0.0.1:31331"
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fclose($server);

?>
--EXPECTF--
array(7) {
array(8) {
["timed_out"]=>
bool(false)
["blocked"]=>
Expand All @@ -51,11 +51,13 @@ array(7) {
int(0)
["seekable"]=>
bool(false)
["uri"]=>
string(21) "tcp://127.0.0.1:31332"
}


Set a timeout on the client and attempt a read:
array(7) {
array(8) {
["timed_out"]=>
bool(true)
["blocked"]=>
Expand All @@ -70,11 +72,13 @@ array(7) {
int(0)
["seekable"]=>
bool(false)
["uri"]=>
string(21) "tcp://127.0.0.1:31332"
}


Write some data from the server:
array(7) {
array(8) {
["timed_out"]=>
bool(true)
["blocked"]=>
Expand All @@ -89,11 +93,13 @@ array(7) {
int(0)
["seekable"]=>
bool(false)
["uri"]=>
string(21) "tcp://127.0.0.1:31332"
}


Read some data from the client:
array(7) {
array(8) {
["timed_out"]=>
bool(false)
["blocked"]=>
Expand All @@ -108,4 +114,6 @@ array(7) {
int(0)
["seekable"]=>
bool(false)
["uri"]=>
string(21) "tcp://127.0.0.1:31332"
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fclose($server);

?>
--EXPECTF--
array(7) {
array(8) {
["timed_out"]=>
bool(false)
["blocked"]=>
Expand All @@ -46,12 +46,14 @@ array(7) {
int(0)
["seekable"]=>
bool(false)
["uri"]=>
string(21) "tcp://127.0.0.1:31333"
}


Set blocking to false:
bool(true)
array(7) {
array(8) {
["timed_out"]=>
bool(false)
["blocked"]=>
Expand All @@ -66,12 +68,14 @@ array(7) {
int(0)
["seekable"]=>
bool(false)
["uri"]=>
string(21) "tcp://127.0.0.1:31333"
}


Set blocking to true:
bool(true)
array(7) {
array(8) {
["timed_out"]=>
bool(false)
["blocked"]=>
Expand All @@ -86,4 +90,6 @@ array(7) {
int(0)
["seekable"]=>
bool(false)
["uri"]=>
string(21) "tcp://127.0.0.1:31333"
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fclose($client);
?>
--EXPECTF--
Write some data:
array(7) {
array(8) {
["timed_out"]=>
bool(false)
["blocked"]=>
Expand All @@ -51,11 +51,13 @@ array(7) {
int(%i)
["seekable"]=>
bool(false)
["uri"]=>
string(21) "tcp://127.0.0.1:31334"
}


Read a line from the client:
array(7) {
array(8) {
["timed_out"]=>
bool(false)
["blocked"]=>
Expand All @@ -70,11 +72,13 @@ array(7) {
int(%i)
["seekable"]=>
bool(false)
["uri"]=>
string(21) "tcp://127.0.0.1:31334"
}


Close the server side socket and read the remaining data from the client:
array(7) {
array(8) {
["timed_out"]=>
bool(false)
["blocked"]=>
Expand All @@ -89,4 +93,6 @@ array(7) {
int(%i)
["seekable"]=>
bool(false)
["uri"]=>
string(21) "tcp://127.0.0.1:31334"
}
4 changes: 3 additions & 1 deletion main/streams/transports.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ PHPAPI php_stream *_php_stream_xport_create(const char *name, size_t namelen, in
{
php_stream *stream = NULL;
php_stream_transport_factory factory = NULL;
const char *p, *protocol = NULL;
const char *p, *protocol, *orig_path = NULL;
size_t n = 0;
bool failed = false;
bool bailout = false;
Expand Down Expand Up @@ -94,6 +94,7 @@ PHPAPI php_stream *_php_stream_xport_create(const char *name, size_t namelen, in
}
}

orig_path = name;
for (p = name; isalnum((int)*p) || *p == '+' || *p == '-' || *p == '.'; p++) {
n++;
}
Expand Down Expand Up @@ -135,6 +136,7 @@ PHPAPI php_stream *_php_stream_xport_create(const char *name, size_t namelen, in
if (stream) {
zend_try {
php_stream_context_set(stream, context);
stream->orig_path = pestrdup(orig_path, persistent_id ? 1 : 0);

if ((flags & STREAM_XPORT_SERVER) == 0) {
/* client */
Expand Down
4 changes: 0 additions & 4 deletions main/streams/xp_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -966,9 +966,5 @@ PHPAPI php_stream *php_stream_generic_socket_factory(const char *proto, size_t p
return NULL;
}

if (flags == 0) {
return stream;
}

return stream;
}