From 102b2c2b5d33b31ee7660e77fcbacac9bc5677a4 Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 7 Apr 2022 23:05:34 +0800 Subject: fix stream recv --- xmake/core/base/bytes.lua | 8 +++++--- xmake/modules/private/service/server/server.lua | 2 +- xmake/modules/private/service/stream.lua | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/xmake/core/base/bytes.lua b/xmake/core/base/bytes.lua index 48a93cde8..daf51bc81 100644 --- a/xmake/core/base/bytes.lua +++ b/xmake/core/base/bytes.lua @@ -310,11 +310,13 @@ function _instance:clone() end -- dump whole bytes data -function _instance:dump() +function _instance:dump(start, last) + start = start or 1 + last = last or self:size() local i = 0 local n = 147 - local p = 0 - local e = self:size() + local p = start - 1 + local e = last local line = nil while p < e do line = "" diff --git a/xmake/modules/private/service/server/server.lua b/xmake/modules/private/service/server/server.lua index 95db2f5a5..534a2da15 100644 --- a/xmake/modules/private/service/server/server.lua +++ b/xmake/modules/private/service/server/server.lua @@ -124,7 +124,7 @@ function server:_handle_session(sock) while true do local data = rstream:recv_string() if data then - print("|%s|", data) + print("%s", data) else break end diff --git a/xmake/modules/private/service/stream.lua b/xmake/modules/private/service/stream.lua index 5460a7cb9..226ee22e0 100644 --- a/xmake/modules/private/service/stream.lua +++ b/xmake/modules/private/service/stream.lua @@ -144,7 +144,7 @@ function stream:recv(buff, size) -- move left cache to head cache_size = real - leftsize if cache_size > 0 then - cache:move(leftsize, cache_size) + cache:move(leftsize + 1, real) end self._RCACHE_SIZE = cache_size return buff:slice(1, buffsize) -- cgit v1.3.1