Browse Source

net: sockets: socket_dispatcher: Fix close function type

Socket dispatcher (and offloaded implementations in tests) register
fd as ZVFS_MODE_IFSOCK therefore they should register a  close2(
function instead of close().

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
pull/91526/merge
Robert Lubos 6 days ago committed by Daniel DeGrasse
parent
commit
aa4a8789d5
  1. 6
      subsys/net/lib/sockets/socket_dispatcher.c
  2. 8
      tests/net/socket/offload_dispatcher/src/main.c

6
subsys/net/lib/sockets/socket_dispatcher.c

@ -393,8 +393,10 @@ static int sock_dispatch_setsockopt_vmeth(void *obj, int level, int optname,
return zsock_setsockopt(fd, level, optname, optval, optlen); return zsock_setsockopt(fd, level, optname, optval, optlen);
} }
static int sock_dispatch_close_vmeth(void *obj) static int sock_dispatch_close_vmeth(void *obj, int fd)
{ {
ARG_UNUSED(fd);
dispatcher_ctx_free(obj); dispatcher_ctx_free(obj);
return 0; return 0;
@ -428,7 +430,7 @@ static const struct socket_op_vtable sock_dispatch_fd_op_vtable = {
.fd_vtable = { .fd_vtable = {
.read = sock_dispatch_read_vmeth, .read = sock_dispatch_read_vmeth,
.write = sock_dispatch_write_vmeth, .write = sock_dispatch_write_vmeth,
.close = sock_dispatch_close_vmeth, .close2 = sock_dispatch_close_vmeth,
.ioctl = sock_dispatch_ioctl_vmeth, .ioctl = sock_dispatch_ioctl_vmeth,
}, },
.shutdown = sock_dispatch_shutdown_vmeth, .shutdown = sock_dispatch_shutdown_vmeth,

8
tests/net/socket/offload_dispatcher/src/main.c

@ -61,10 +61,12 @@ static ssize_t offload_write(void *obj, const void *buffer, size_t count)
return 0; return 0;
} }
static int offload_close(void *obj) static int offload_close(void *obj, int fd)
{ {
struct test_socket_calls *ctx = obj; struct test_socket_calls *ctx = obj;
ARG_UNUSED(fd);
ctx->close_called = true; ctx->close_called = true;
return 0; return 0;
@ -252,7 +254,7 @@ static const struct socket_op_vtable offload_1_socket_fd_op_vtable = {
.fd_vtable = { .fd_vtable = {
.read = offload_read, .read = offload_read,
.write = offload_write, .write = offload_write,
.close = offload_close, .close2 = offload_close,
.ioctl = offload_ioctl, .ioctl = offload_ioctl,
}, },
.shutdown = offload_shutdown, .shutdown = offload_shutdown,
@ -314,7 +316,7 @@ static const struct socket_op_vtable offload_2_socket_fd_op_vtable = {
.fd_vtable = { .fd_vtable = {
.read = offload_read, .read = offload_read,
.write = offload_write, .write = offload_write,
.close = offload_close, .close2 = offload_close,
.ioctl = offload_ioctl, .ioctl = offload_ioctl,
}, },
.shutdown = offload_shutdown, .shutdown = offload_shutdown,

Loading…
Cancel
Save