From 29917efad7ee100f6628fca85e69b773bbd42905 Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Tue, 13 May 2014 11:09:15 +0800 Subject: [PATCH 1/7] add MAX_SLOT_SIZE limit --- skynet-src/skynet_handle.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/skynet-src/skynet_handle.c b/skynet-src/skynet_handle.c index dea99e4f..58cabc0b 100644 --- a/skynet-src/skynet_handle.c +++ b/skynet-src/skynet_handle.c @@ -9,6 +9,7 @@ #include #define DEFAULT_SLOT_SIZE 4 +#define MAX_SLOT_SIZE 0x40000000 struct handle_name { char * name; @@ -168,6 +169,7 @@ static void _insert_name_before(struct handle_storage *s, char *name, uint32_t handle, int before) { if (s->name_count >= s->name_cap) { s->name_cap *= 2; + assert(s->name_cap <= MAX_SLOT_SIZE); struct handle_name * n = skynet_malloc(s->name_cap * sizeof(struct handle_name)); int i; for (i=0;i Date: Tue, 13 May 2014 13:35:37 +0800 Subject: [PATCH 2/7] Fix issue #109 --- skynet-src/socket_server.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/skynet-src/socket_server.c b/skynet-src/socket_server.c index b3ea5e0a..f013fd1b 100644 --- a/skynet-src/socket_server.c +++ b/skynet-src/socket_server.c @@ -815,6 +815,22 @@ report_accept(struct socket_server *ss, struct socket *s, struct socket_message return 1; } +static inline void +clear_closed_event(struct socket_server *ss, struct socket_message * result, int type) { + if (type == SOCKET_CLOSE || type == SOCKET_ERROR) { + int id = result->id; + int i; + for (i=ss->event_index; ievent_n; i++) { + struct event *e = &ss->ev[i]; + struct socket *s = e->s; + if (s) { + if (s->type == SOCKET_TYPE_INVALID && s->id == id) { + e->s = NULL; + } + } + } + } +} // return type int @@ -823,9 +839,10 @@ socket_server_poll(struct socket_server *ss, struct socket_message * result, int if (ss->checkctrl) { if (has_cmd(ss)) { int type = ctrl_cmd(ss, result); - if (type != -1) + if (type != -1) { + clear_closed_event(ss, result, type); return type; - else + } else continue; } else { ss->checkctrl = 0; @@ -865,12 +882,14 @@ socket_server_poll(struct socket_server *ss, struct socket_message * result, int int type = send_buffer(ss, s, result); if (type == -1) break; + clear_closed_event(ss, result, type); return type; } if (e->read) { int type = forward_message(ss, s, result); if (type == -1) break; + clear_closed_event(ss, result, type); return type; } break; From b397c70c34f9c1ebdf2a2bbc0ee414f6e5f1abf7 Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Tue, 13 May 2014 17:00:43 +0800 Subject: [PATCH 3/7] remove unused pingqueue --- test/pingqueue.lua | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 test/pingqueue.lua diff --git a/test/pingqueue.lua b/test/pingqueue.lua deleted file mode 100644 index eca240f8..00000000 --- a/test/pingqueue.lua +++ /dev/null @@ -1,12 +0,0 @@ -local skynet = require "skynet" -local mqueue = require "mqueue" - -skynet.start(function() - local id = 0 - local pingserver = skynet.newservice "pingserver" - mqueue.register(function(str) - id = id + 1 - str = string.format("id = %d , %s",id, str) - return skynet.call(pingserver, "lua", "PING", str) - end) -end) From ff155c623ec2bdbfc15c5701df558c09243d5b1c Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Fri, 16 May 2014 14:31:27 +0800 Subject: [PATCH 4/7] bugfix: stdin is 0 --- lualib/socket.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lualib/socket.lua b/lualib/socket.lua index 4ed8c769..93b9bf4c 100644 --- a/lualib/socket.lua +++ b/lualib/socket.lua @@ -151,7 +151,7 @@ function socket.bind(os_fd) end function socket.stdin() - return socket.bind(1) + return socket.bind(0) end function socket.start(id, func) From a2ad158dbc32dbf2d330e3bcc1285d68602109d3 Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Fri, 16 May 2014 15:01:25 +0800 Subject: [PATCH 5/7] update PTYPE_* macro --- HISTORY.md | 7 +++++++ skynet-src/skynet.h | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 9136e32b..028f5d85 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,10 @@ +v0.2.1 +----------- +* Bugfix: check all the events already read after socket close +* Bugfix: socket data in gate service +* Bugfix: boundary problem in harbor service +* Bugfix: stdin handle is 0 + v0.2.0 (2014-5-12) ----------- diff --git a/skynet-src/skynet.h b/skynet-src/skynet.h index 0df5ca9c..9ae1759c 100644 --- a/skynet-src/skynet.h +++ b/skynet-src/skynet.h @@ -13,12 +13,13 @@ #define PTYPE_SYSTEM 4 #define PTYPE_HARBOR 5 #define PTYPE_SOCKET 6 -// read lualib/skynet.lua lualib/simplemonitor.lua +// read lualib/skynet.lua examples/simplemonitor.lua #define PTYPE_ERROR 7 -// read lualib/skynet.lua lualib/mqueue.lua +// read lualib/skynet.lua lualib/mqueue.lua lualib/snax.lua #define PTYPE_RESERVED_QUEUE 8 #define PTYPE_RESERVED_DEBUG 9 #define PTYPE_RESERVED_LUA 10 +#define PTYPE_RESERVED_SNAX 11 #define PTYPE_TAG_DONTCOPY 0x10000 #define PTYPE_TAG_ALLOCSESSION 0x20000 From a5df196e92624eb996547c6b9fbaa6c0aad928be Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Fri, 16 May 2014 17:36:49 +0800 Subject: [PATCH 6/7] use skynet_error for memory dump --- skynet-src/malloc_hook.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/skynet-src/malloc_hook.c b/skynet-src/malloc_hook.c index 61c07392..9b3949a6 100644 --- a/skynet-src/malloc_hook.c +++ b/skynet-src/malloc_hook.c @@ -106,7 +106,7 @@ mallctl_int64(const char* name, size_t* newval) { } else { je_mallctl(name, &v, &len, NULL, 0); } - // printf("name: %s, value: %zd\n", name, v); + // skynet_error(NULL, "name: %s, value: %zd\n", name, v); return v; } @@ -117,9 +117,9 @@ mallctl_opt(const char* name, int* newval) { if(newval) { int ret = je_mallctl(name, &v, &len, newval, sizeof(int)); if(ret == 0) { - printf("set new value(%d) for (%s) succeed\n", *newval, name); + skynet_error(NULL, "set new value(%d) for (%s) succeed\n", *newval, name); } else { - printf("set new value(%d) for (%s) failed: error -> %d\n", *newval, name, ret); + skynet_error(NULL, "set new value(%d) for (%s) failed: error -> %d\n", *newval, name, ret); } } else { je_mallctl(name, &v, &len, NULL, 0); @@ -196,15 +196,15 @@ void dump_c_mem() { int i; size_t total = 0; - printf("dump all service mem:\n"); + skynet_error(NULL, "dump all service mem:"); for(i=0; ihandle != 0 && data->allocated != 0) { total += data->allocated; - printf("0x%x -> %zdkb\n", data->handle, data->allocated >> 10); + skynet_error(NULL, "0x%x -> %zdkb", data->handle, data->allocated >> 10); } } - printf("+total: %zdkb\n",total >> 10); + skynet_error(NULL, "+total: %zdkb",total >> 10); } char * From 84e8abc09cda3ca1d57580952e66b2a931b78f08 Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Mon, 19 May 2014 10:51:20 +0800 Subject: [PATCH 7/7] update history --- HISTORY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index 028f5d85..76e7dc61 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,4 +1,4 @@ -v0.2.1 +v0.2.1 (2014-5-19) ----------- * Bugfix: check all the events already read after socket close * Bugfix: socket data in gate service