Skip to content
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

wasi: add wasi sock_accept stub #46434

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mhdawson
Copy link
Member

@mhdawson mhdawson commented Jan 31, 2023

Refs: nodejs/uvwasi#185

Add stub for sock_accept so that we have stubs
for all of the sock methods in wasi_snapshot_preview1.
Its a bit awkward as the method was added after the
initial definitial of wasi_snapshot-preview1 but I
think it should be semver minor at most to add
the method.

Depends on nodejs/uvwasi#185
being landed in uvwasi first and an updated version
of uvwasi that includes that being pulled into
Node.js

Signed-off-by: Michael Dawson mdawson@devrus.com

@nodejs-github-bot
Copy link
Contributor

Review requested:

  • @nodejs/wasi

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. wasi Issues and PRs related to the WebAssembly System Interface. labels Jan 31, 2023
@mhdawson mhdawson removed the wasi Issues and PRs related to the WebAssembly System Interface. label Jan 31, 2023
@mhdawson mhdawson added the wasi Issues and PRs related to the WebAssembly System Interface. label Jan 31, 2023
@mhdawson mhdawson changed the title Wasi sockets2 wasi: add wasi sock_accept stub Jan 31, 2023
Refs: nodejs/uvwasi#185

Add stub for sock_accept so that we have stubs
for all of the sock methods in wasi_snapshot_preview1.
Its a bit awkward as the method was added after the
initial definitial of wasi_snapshot-preview1 but I
think it should be semver minor at most to add
the method.

Depends on nodejs/uvwasi#185
being landed in uvwasi first and an updated version
of uvwasi that includes that being pulled into
Node.js

Signed-off-by: Michael Dawson <mdawson@devrus.com>
Copy link
Contributor

@cjihrig cjihrig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with minor comments.

@@ -1234,6 +1234,21 @@ uint32_t WASI::SockShutdown(WASI& wasi,
return uvwasi_sock_shutdown(&wasi.uvw_, sock, how);
}

uint32_t WASI::SockAccept(WASI& wasi,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the WASI functions are sorted alphabetically in this file. Can you move this?

@@ -1306,6 +1321,7 @@ static void Initialize(Local<Object> target,
V(SockRecv, "sock_recv")
V(SockSend, "sock_send")
V(SockShutdown, "sock_shutdown")
V(SockAccept, "sock_accept")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment about sorting here.

@@ -142,6 +142,7 @@ class WASI : public BaseObject,
static uint32_t SockSend(
WASI&, WasmMemory, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t);
static uint32_t SockShutdown(WASI&, WasmMemory, uint32_t, uint32_t);
static uint32_t SockAccept(WASI&, WasmMemory, uint32_t, uint32_t, uint32_t);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment about sorting.

int flags = 0;
int ret = accept(0, NULL, &addrlen);
assert(ret == -1);
assert(errno == 58);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to compare against error codes here. [example]

#include <stdio.h>

int main(void) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this file will need to be updated when there is a full implementation of sock_accept(), could you leave a TODO comment.

Nit: blank line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. wasi Issues and PRs related to the WebAssembly System Interface.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants