mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-25 04:33:05 +00:00
trace throw error instead of assert in C
This commit is contained in:
@@ -399,6 +399,9 @@ static int
|
|||||||
_trace_new(lua_State *L) {
|
_trace_new(lua_State *L) {
|
||||||
struct trace_pool *p = lua_touserdata(L,1);
|
struct trace_pool *p = lua_touserdata(L,1);
|
||||||
struct trace_info *t = trace_new(p);
|
struct trace_info *t = trace_new(p);
|
||||||
|
if (t==NULL) {
|
||||||
|
return luaL_error(L, "Last trace didn't close");
|
||||||
|
}
|
||||||
lua_pushlightuserdata(L,t);
|
lua_pushlightuserdata(L,t);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,7 +81,9 @@ trace_release(struct trace_pool *p) {
|
|||||||
|
|
||||||
struct trace_info *
|
struct trace_info *
|
||||||
trace_new(struct trace_pool *p) {
|
trace_new(struct trace_pool *p) {
|
||||||
assert(p->current == NULL);
|
if (p->current) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
struct trace_info *t = malloc(sizeof(*t));
|
struct trace_info *t = malloc(sizeof(*t));
|
||||||
p->current = t;
|
p->current = t;
|
||||||
t->session = 0;
|
t->session = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user