add assert

This commit is contained in:
云风
2012-09-17 21:43:53 +08:00
parent e8104199de
commit 1aa89d8672
2 changed files with 8 additions and 2 deletions

View File

@@ -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;
}

View File

@@ -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) {