mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-23 19:43:09 +00:00
message sequence wrong for queue
When the lua state yield in "more queue" proceeding, "data" comes, it should wait in queue, not immediatly do message process.
This commit is contained in:
@@ -240,12 +240,19 @@ filter_data_(lua_State *L, int fd, uint8_t * buffer, int size) {
|
||||
buffer += need;
|
||||
size -= need;
|
||||
if (size == 0) {
|
||||
lua_pushvalue(L, lua_upvalueindex(TYPE_DATA));
|
||||
lua_pushinteger(L, fd);
|
||||
lua_pushlightuserdata(L, uc->pack.buffer);
|
||||
lua_pushinteger(L, uc->pack.size);
|
||||
skynet_free(uc);
|
||||
return 5;
|
||||
if (q == NULL || q->head == q->tail ) {
|
||||
lua_pushvalue(L, lua_upvalueindex(TYPE_DATA));
|
||||
lua_pushinteger(L, fd);
|
||||
lua_pushlightuserdata(L, uc->pack.buffer);
|
||||
lua_pushinteger(L, uc->pack.size);
|
||||
skynet_free(uc);
|
||||
return 5;
|
||||
}
|
||||
else{
|
||||
push_data(L, fd, uc->pack.buffer, uc->pack.size, 0);
|
||||
skynet_free(uc);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
// more data
|
||||
push_data(L, fd, uc->pack.buffer, uc->pack.size, 0);
|
||||
@@ -274,13 +281,21 @@ filter_data_(lua_State *L, int fd, uint8_t * buffer, int size) {
|
||||
}
|
||||
if (size == pack_size) {
|
||||
// just one package
|
||||
lua_pushvalue(L, lua_upvalueindex(TYPE_DATA));
|
||||
lua_pushinteger(L, fd);
|
||||
void * result = skynet_malloc(pack_size);
|
||||
memcpy(result, buffer, size);
|
||||
lua_pushlightuserdata(L, result);
|
||||
lua_pushinteger(L, size);
|
||||
return 5;
|
||||
if ( q == NULL || q->head == q->tail) {
|
||||
lua_pushvalue(L, lua_upvalueindex(TYPE_DATA));
|
||||
lua_pushinteger(L, fd);
|
||||
void * result = skynet_malloc(pack_size);
|
||||
memcpy(result, buffer, size);
|
||||
lua_pushlightuserdata(L, result);
|
||||
lua_pushinteger(L, size);
|
||||
return 5;
|
||||
}
|
||||
else{
|
||||
push_data(L, fd, buffer, pack_size, 1);
|
||||
buffer += pack_size;
|
||||
size -= pack_size;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
// more data
|
||||
push_data(L, fd, buffer, pack_size, 1);
|
||||
|
||||
Reference in New Issue
Block a user