From 1aa89d8672ccb836d0fa6b2bd64042cd3e821e77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=91=E9=A3=8E?= Date: Mon, 17 Sep 2012 21:43:53 +0800 Subject: [PATCH] add assert --- lualib-src/lua-skynet.c | 6 ++++++ lualib-src/trace_service.c | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lualib-src/lua-skynet.c b/lualib-src/lua-skynet.c index 4999b5db..138234d4 100644 --- a/lualib-src/lua-skynet.c +++ b/lualib-src/lua-skynet.c @@ -198,6 +198,9 @@ _sendname(lua_State *L, struct skynet_context * context, const char * dest) { default: luaL_error(L, "skynet.send invalid param %s", lua_type(L,4)); } + if (session < 0) { + luaL_error(L, "skynet.send session (%d) < 0", session); + } lua_pushinteger(L,session); return 1; } @@ -266,6 +269,9 @@ _send(lua_State *L) { default: luaL_error(L, "skynet.send invalid param %s", lua_type(L,4)); } + if (session < 0) { + luaL_error(L, "skynet.send session (%d) < 0", session); + } lua_pushinteger(L,session); return 1; } diff --git a/lualib-src/trace_service.c b/lualib-src/trace_service.c index acd8401f..7c3c8653 100644 --- a/lualib-src/trace_service.c +++ b/lualib-src/trace_service.c @@ -87,7 +87,7 @@ trace_register(struct trace_pool *p, int session) { return; } int hash = session % HASH_SIZE; - assert(t->session == 0 && session !=0); + assert(t->session == 0 && session > 0); t->session = session; t->prev = NULL; t->next = p->slot[hash]; @@ -114,7 +114,7 @@ trace_yield(struct trace_pool *p) { void trace_switch(struct trace_pool *p, int session) { - assert(p->current == NULL); + assert(p->current == NULL && session > 0); struct trace_info *t = p->slot[session % HASH_SIZE]; struct trace_info *prev = NULL; while (t) {