Skip to content

Commit 2df1392

Browse files
committed
fix(luasocket): return the partial results read
1 parent bd7d6a6 commit 2df1392

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

mqtt/connector/base/buffered_base.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ end
7676
-- is no data to read. If there is no data, then it MUST return
7777
-- `nil, self.signal_idle` to indicate it no data was there and we need to retry later.
7878
--
79+
-- If there is partial data, it should return that data (less than the requested
80+
-- number of bytes), with no error/signal.
81+
--
7982
-- If the receive errors, because of a closed connection it should return
8083
-- `nil, self.signal_closed` to indicate this. Any other errors can be returned
8184
-- as a regular `nil, err`.

mqtt/connector/luasocket.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,10 @@ function luasocket:plain_receive(size)
118118

119119
sock:settimeout(0)
120120

121-
local data, err = sock:receive(size)
122-
if data then
121+
local data, err, partial = sock:receive(size)
122+
123+
data = data or partial or ""
124+
if #data > 0 then
123125
return data
124126
end
125127

0 commit comments

Comments
 (0)