Skip to content
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
6 changes: 5 additions & 1 deletion src/lib/libcore.js
Original file line number Diff line number Diff line change
Expand Up @@ -2617,7 +2617,11 @@ function wrapSyscallFunction(x, library, isWasi) {
post = handler + post;

if (pre || post) {
t = modifyJSFunction(t, (args, body) => `function (${args}) {\n${pre}${body}${post}}\n`);
if (library[x + '__async']) {
t = modifyJSFunction(t, (args, body) => `async function (${args}) {\n${pre}${body}${post}}\n`);
} else {
t = modifyJSFunction(t, (args, body) => `function (${args}) {\n${pre}${body}${post}}\n`);
}
}

library[x] = eval('(' + t + ')');
Expand Down
6 changes: 3 additions & 3 deletions src/lib/libsockfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ addToLibrary({
},
// node and stream ops are backend agnostic
stream_ops: {
poll(stream) {
poll(stream, timeout) {
var sock = stream.node.sock;
return sock.sock_ops.poll(sock);
return sock.sock_ops.poll(sock, timeout);
},
ioctl(stream, request, varargs) {
var sock = stream.node.sock;
Expand Down Expand Up @@ -375,7 +375,7 @@ addToLibrary({
//
// actual sock ops
//
poll(sock) {
poll(sock, timeout) {
if (sock.type === {{{ cDefs.SOCK_STREAM }}} && sock.server) {
// listen sockets should only say they're available for reading
// if there are pending clients.
Expand Down
13 changes: 12 additions & 1 deletion src/lib/libsyscall.js
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,13 @@ var SyscallsLibrary = {
return 0;
},
__syscall__newselect__i53abi: true,
__syscall__newselect: (nfds, readfds, writefds, exceptfds, timeoutInMillis) => {
#if ASYNCIFY
__syscall__newselect__async: true,
__syscall__newselect: async (nfds, readfds, writefds, exceptfds, timeoutInMillis) =>
#else
__syscall__newselect: (nfds, readfds, writefds, exceptfds, timeoutInMillis) =>
#endif
{
// readfds are supported,
// writefds checks socket open status
// exceptfds are supported, although on web, such exceptional conditions never arise in web sockets
Expand Down Expand Up @@ -586,6 +592,11 @@ var SyscallsLibrary = {

if (stream.stream_ops.poll) {
flags = stream.stream_ops.poll(stream, timeoutInMillis);

#if ASYNCIFY
/* poll is possibly a promise */
flags = await flags;
#endif
} else {
#if ASSERTIONS
if (timeoutInMillis != 0) warnOnce('non-zero select() timeout not supported: ' + timeoutInMillis)
Expand Down