Skip to content

Commit

Permalink
compile
Browse files Browse the repository at this point in the history
  • Loading branch information
HereAdvertise authored Jul 13, 2024
1 parent 789a38e commit 7d126f2
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions pgmoon/redbean.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,18 @@ do
if events[self.unix_socket] & CANWRITE == 0 then
return nil, "close"
end
local sent, err = unix.send(self.unix_socket, data)
if not sent and err:name() == "EAGAIN" then
return nil, "timeout"
local size = 0
while size < #data do
local sent, err = unix.send(self.unix_socket, string.sub(data, size + 1))
if not sent and err:name() == "EAGAIN" then
return nil, "timeout"
end
if not sent then
return nil, err:doc()
end
size = size + sent
end
return sent, err
return size
end,
receive = function(self, pattern)
local CANREAD = unix.POLLIN | unix.POLLRDNORM | unix.POLLRDBAND
Expand All @@ -58,7 +65,7 @@ do
return nil, "close"
end
while #buf < size do
local rec = unix.recv(self.unix_socket, size - #buf)
local rec = assert(unix.recv(self.unix_socket, size - #buf))
if #rec == 0 then
break
else
Expand Down

0 comments on commit 7d126f2

Please sign in to comment.