From 52ebd98ff4e66a61c63c6c7c385d9fc7759e98ef Mon Sep 17 00:00:00 2001 From: dongsheng28849455 <68947925+dongsheng28849455@users.noreply.github.com> Date: Thu, 3 Nov 2022 16:29:58 +0800 Subject: [PATCH] Fix a build failure error on nuttx (#1675) NuttX doesn't have SO_REUSEPORT. --- .../sandboxed-system-primitives/src/posix.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c b/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c index 487db655..a1e3e373 100644 --- a/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c +++ b/core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c @@ -3220,7 +3220,13 @@ wasi_ssp_sock_get_reuse_port( int optval; socklen_t optlen = sizeof(optval); +#if defined(SO_REUSEPORT) /* NuttX doesn't have SO_REUSEPORT */ ret = getsockopt(fd_number(fo), SOL_SOCKET, SO_REUSEPORT, &optval, &optlen); +#else + errno = ENOTSUP; + ret = BHT_ERROR; +#endif /* defined(SO_REUSEPORT) */ + fd_object_release(fo); if (BHT_OK != ret) { return convert_errno(errno); @@ -3393,8 +3399,14 @@ wasi_ssp_sock_set_reuse_port( int optval = reuse; +#if defined(SO_REUSEPORT) /* NuttX doesn't have SO_REUSEPORT */ ret = setsockopt(fd_number(fo), SOL_SOCKET, SO_REUSEPORT, &optval, sizeof(optval)); +#else + errno = ENOTSUP; + ret = BHT_ERROR; +#endif /* defined(SO_REUSEPORT) */ + fd_object_release(fo); if (BHT_OK != ret) { return convert_errno(errno); @@ -3420,6 +3432,7 @@ wasi_ssp_sock_set_send_buf_size( ret = setsockopt(fd_number(fo), SOL_SOCKET, SO_SNDBUF, &optval, sizeof(optval)); + fd_object_release(fo); if (BHT_OK != ret) { return convert_errno(errno);