mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-25 12:43:09 +00:00
avoid lua stack overflow
This commit is contained in:
@@ -408,6 +408,7 @@ bson_numstr( char *str, unsigned int i ) {
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
pack_dict(lua_State *L, struct bson *b, bool isarray) {
|
pack_dict(lua_State *L, struct bson *b, bool isarray) {
|
||||||
|
luaL_checkstack(L, 16, NULL); // reserve enough stack space to pack table
|
||||||
int length = reserve_length(b);
|
int length = reserve_length(b);
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
while(lua_next(L,-2) != 0) {
|
while(lua_next(L,-2) != 0) {
|
||||||
@@ -495,6 +496,7 @@ make_object(lua_State *L, int type, const void * ptr, size_t len) {
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
unpack_dict(lua_State *L, struct bson_reader *br, bool array) {
|
unpack_dict(lua_State *L, struct bson_reader *br, bool array) {
|
||||||
|
luaL_checkstack(L, 16, NULL); // reserve enough stack space to unpack table
|
||||||
int sz = read_int32(L, br);
|
int sz = read_int32(L, br);
|
||||||
const void * bytes = read_bytes(L, br, sz-5);
|
const void * bytes = read_bytes(L, br, sz-5);
|
||||||
struct bson_reader t = { bytes, sz-5 };
|
struct bson_reader t = { bytes, sz-5 };
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ timer_create_timer() {
|
|||||||
|
|
||||||
int
|
int
|
||||||
skynet_timeout(uint32_t handle, int time, int session) {
|
skynet_timeout(uint32_t handle, int time, int session) {
|
||||||
if (time == 0) {
|
if (time <= 0) {
|
||||||
struct skynet_message message;
|
struct skynet_message message;
|
||||||
message.source = 0;
|
message.source = 0;
|
||||||
message.session = session;
|
message.session = session;
|
||||||
|
|||||||
Reference in New Issue
Block a user