From 1726fe4c6ecea53abea0807d80acf107539de350 Mon Sep 17 00:00:00 2001 From: HereAdvertise <162376972+HereAdvertise@users.noreply.github.com> Date: Sat, 13 Jul 2024 15:08:27 -0300 Subject: [PATCH] update receive --- pgmoon/redbean.moon | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pgmoon/redbean.moon b/pgmoon/redbean.moon index 05c28cf..6f2dedb 100644 --- a/pgmoon/redbean.moon +++ b/pgmoon/redbean.moon @@ -40,12 +40,18 @@ class RedbeanSocket receive: (pattern) => CANREAD = unix.POLLIN | unix.POLLRDNORM | unix.POLLRDBAND size = tonumber(pattern) + buf = "" if size events = assert unix.poll @unix_socket: unix.POLLIN, @timeout return nil, "timeout" unless events[@unix_socket] return nil, "close" if events[@unix_socket] & CANREAD == 0 - return unix.recv @unix_socket, size - "" + while #buf < size + rec = unix.recv @unix_socket, size - #buf + if #rec == 0 + break + else + buf ..= rec + buf close: => assert unix.close @unix_socket