From 6dda5f7f98362ae332ba8327ff9762be6eb2dcb9 Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Sat, 3 Sep 2022 22:02:45 +0800 Subject: [PATCH] Revert "udp socket bugfix (#1640)" This reverts commit 2a8c095e387fa5ad4907ee2c8fa350b388fc7139. --- lualib-src/lua-socket.c | 5 ++--- skynet-src/skynet_socket.c | 2 +- skynet-src/skynet_socket.h | 2 +- skynet-src/socket_server.c | 2 +- skynet-src/socket_server.h | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lualib-src/lua-socket.c b/lualib-src/lua-socket.c index 3662e7cd..ea97dce6 100644 --- a/lualib-src/lua-socket.c +++ b/lualib-src/lua-socket.c @@ -648,13 +648,12 @@ ludp(lua_State *L) { host = address_port(L, tmp, addr, 2, &port); } - int id = skynet_socket_udp(ctx, host, &port); + int id = skynet_socket_udp(ctx, host, port); if (id < 0) { return luaL_error(L, "udp init failed"); } lua_pushinteger(L, id); - lua_pushinteger(L, port); - return 2; + return 1; } static int diff --git a/skynet-src/skynet_socket.c b/skynet-src/skynet_socket.c index 00fd7778..31acafc0 100644 --- a/skynet-src/skynet_socket.c +++ b/skynet-src/skynet_socket.c @@ -175,7 +175,7 @@ skynet_socket_nodelay(struct skynet_context *ctx, int id) { } int -skynet_socket_udp(struct skynet_context *ctx, const char * addr, int *port) { +skynet_socket_udp(struct skynet_context *ctx, const char * addr, int port) { uint32_t source = skynet_context_handle(ctx); return socket_server_udp(SOCKET_SERVER, source, addr, port); } diff --git a/skynet-src/skynet_socket.h b/skynet-src/skynet_socket.h index 3a6f263f..59aabb86 100644 --- a/skynet-src/skynet_socket.h +++ b/skynet-src/skynet_socket.h @@ -38,7 +38,7 @@ void skynet_socket_start(struct skynet_context *ctx, int id); void skynet_socket_pause(struct skynet_context *ctx, int id); void skynet_socket_nodelay(struct skynet_context *ctx, int id); -int skynet_socket_udp(struct skynet_context *ctx, const char * addr, int *port); +int skynet_socket_udp(struct skynet_context *ctx, const char * addr, int port); int skynet_socket_udp_connect(struct skynet_context *ctx, int id, const char * addr, int port); int skynet_socket_udp_sendbuffer(struct skynet_context *ctx, const char * address, struct socket_sendbuffer *buffer); const char * skynet_socket_udp_address(struct skynet_socket_message *, int *addrsz); diff --git a/skynet-src/socket_server.c b/skynet-src/socket_server.c index 745a6335..b9da6b97 100644 --- a/skynet-src/socket_server.c +++ b/skynet-src/socket_server.c @@ -2070,7 +2070,7 @@ socket_server_userobject(struct socket_server *ss, struct socket_object_interfac // UDP int -socket_server_udp(struct socket_server *ss, uintptr_t opaque, const char * addr, int *port) { +socket_server_udp(struct socket_server *ss, uintptr_t opaque, const char * addr, int port) { int fd; int family; if (port != 0 || addr != NULL) { diff --git a/skynet-src/socket_server.h b/skynet-src/socket_server.h index c70438c9..ae47c855 100644 --- a/skynet-src/socket_server.h +++ b/skynet-src/socket_server.h @@ -54,7 +54,7 @@ struct socket_udp_address; // create an udp socket handle, attach opaque with it . udp socket don't need call socket_server_start to recv message // if port != 0, bind the socket . if addr == NULL, bind ipv4 0.0.0.0 . If you want to use ipv6, addr can be "::" and port 0. -int socket_server_udp(struct socket_server *, uintptr_t opaque, const char * addr, int *port); +int socket_server_udp(struct socket_server *, uintptr_t opaque, const char * addr, int port); // set default dest address, return 0 when success int socket_server_udp_connect(struct socket_server *, int id, const char * addr, int port); // If the socket_udp_address is NULL, use last call socket_server_udp_connect address instead