Skip to content

Commit

Permalink
fix(luasocket): return the partial results read
Browse files Browse the repository at this point in the history
  • Loading branch information
Tieske committed Jul 20, 2024
1 parent bd7d6a6 commit 2df1392
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions mqtt/connector/base/buffered_base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ end
-- is no data to read. If there is no data, then it MUST return
-- `nil, self.signal_idle` to indicate it no data was there and we need to retry later.
--
-- If there is partial data, it should return that data (less than the requested
-- number of bytes), with no error/signal.
--
-- If the receive errors, because of a closed connection it should return
-- `nil, self.signal_closed` to indicate this. Any other errors can be returned
-- as a regular `nil, err`.
Expand Down
6 changes: 4 additions & 2 deletions mqtt/connector/luasocket.lua
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,10 @@ function luasocket:plain_receive(size)

sock:settimeout(0)

local data, err = sock:receive(size)
if data then
local data, err, partial = sock:receive(size)

data = data or partial or ""
if #data > 0 then
return data
end

Expand Down

0 comments on commit 2df1392

Please sign in to comment.