From 1dfddc0d848d82cbcf756c21e79487e50d4e0873 Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Fri, 16 Oct 2020 13:06:01 +0800 Subject: [PATCH] add reading and writing into netstat --- lualib-src/lua-socket.c | 4 ++++ skynet-src/socket_info.h | 2 ++ skynet-src/socket_server.c | 2 ++ 3 files changed, 8 insertions(+) diff --git a/lualib-src/lua-socket.c b/lualib-src/lua-socket.c index 593dd7ad..0da565a9 100644 --- a/lualib-src/lua-socket.c +++ b/lualib-src/lua-socket.c @@ -758,6 +758,10 @@ getinfo(lua_State *L, struct socket_info *si) { lua_setfield(L, -2, "rtime"); lua_pushinteger(L, si->wtime); lua_setfield(L, -2, "wtime"); + lua_pushboolean(L, si->reading); + lua_setfield(L, -2, "reading"); + lua_pushboolean(L, si->writing); + lua_setfield(L, -2, "writing"); if (si->name[0]) { lua_pushstring(L, si->name); lua_setfield(L, -2, "peer"); diff --git a/skynet-src/socket_info.h b/skynet-src/socket_info.h index 78facf6c..739536e8 100644 --- a/skynet-src/socket_info.h +++ b/skynet-src/socket_info.h @@ -18,6 +18,8 @@ struct socket_info { uint64_t rtime; uint64_t wtime; int64_t wbuffer; + uint8_t reading; + uint8_t writing; char name[128]; struct socket_info *next; }; diff --git a/skynet-src/socket_server.c b/skynet-src/socket_server.c index f317ecc8..7bd50dfc 100644 --- a/skynet-src/socket_server.c +++ b/skynet-src/socket_server.c @@ -2185,6 +2185,8 @@ query_info(struct socket *s, struct socket_info *si) { si->rtime = s->stat.rtime; si->wtime = s->stat.wtime; si->wbuffer = s->wb_size; + si->reading = s->reading; + si->writing = s->writing; return 1; }