Skip to content

Experiment with native /internal/shared dir for Playground CLI #2446

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

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
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
11 changes: 10 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
"react-redux": "8.1.3",
"react-transition-group": "4.4.5",
"sha.js": "2.4.11",
"tmp-promise": "3.0.3",
"wasm-feature-detect": "1.8.0",
"xml2js": "0.6.2",
"yargs": "17.7.2"
Expand Down
18 changes: 9 additions & 9 deletions packages/php-wasm/compile/php/php_wasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ EM_JS(int, wasm_poll_socket, (php_socket_t socketd, int events, int timeout), {
if (stream.stream_ops?.poll) {
mask = stream.stream_ops.poll(stream, -1);
}

mask &= events | POLLERR | POLLHUP;
if (mask) {
return mask;
Expand Down Expand Up @@ -418,7 +418,7 @@ EM_JS(__wasi_errno_t, js_fd_read, (__wasi_fd_t fd, const __wasi_iovec_t *iov, si
HEAPU32[pnum >> 2] = num;
return wakeUp(returnCode);
}

// It's a blocking stream and we Blocking stream with no data available yet.
// Let's poll up to a timeout.
await new Promise(resolve => setTimeout(resolve, interval));
Expand Down Expand Up @@ -1026,8 +1026,8 @@ int main(int argc, char *argv[]);
int run_cli()
{
// See wasm_sapi_request_init() for details on why we need to redirect stdout and stderr.
stdout_replacement = redirect_stream_to_file(stdout, "/internal/stdout");
stderr_replacement = redirect_stream_to_file(stderr, "/internal/stderr");
stdout_replacement = redirect_stream_to_file(stdout, "/request/stdout");
stderr_replacement = redirect_stream_to_file(stderr, "/request/stderr");
if (stdout_replacement == -1 || stderr_replacement == -1)
{
return -1;
Expand Down Expand Up @@ -1337,7 +1337,7 @@ void wasm_set_request_port(int port)
*
* stream: The stream to redirect, e.g. stdout or stderr.
*
* path: The path to the file to redirect to, e.g. "/internal/stdout".
* path: The path to the file to redirect to, e.g. "/request/stdout".
*
* returns: The exit code: 0 on success, -1 on failure.
*/
Expand Down Expand Up @@ -1559,11 +1559,11 @@ int wasm_sapi_request_init()
// Write to files instead of stdout and stderr because Emscripten truncates null
// bytes from stdout and stderr, and null bytes are a valid output when streaming
// binary data.
// We use our custom Emscripten-defined /internal/std* devices and handle the output in JavaScript.
// We use our custom Emscripten-defined /request/std* devices and handle the output in JavaScript.
// These /internal devices are not thread-safe and should always stay in per-process MEMFS space.
// Sharing them between PHP instances may cause intertwined output.
stdout_replacement = redirect_stream_to_file(stdout, "/internal/stdout");
stderr_replacement = redirect_stream_to_file(stderr, "/internal/stderr");
stdout_replacement = redirect_stream_to_file(stdout, "/request/stdout");
stderr_replacement = redirect_stream_to_file(stderr, "/request/stderr");
if (stdout_replacement == -1 || stderr_replacement == -1)
{
return -1;
Expand Down Expand Up @@ -1821,7 +1821,7 @@ FILE *headers_file;
*/
static int wasm_sapi_send_headers(sapi_headers_struct *sapi_headers TSRMLS_DC)
{
headers_file = fopen("/internal/headers", "w");
headers_file = fopen("/request/headers", "w");
if (headers_file == NULL)
{
return FAILURE;
Expand Down
Loading
Loading