about summary refs log tree commit diff stats
path: root/092socket.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-10-23 20:06:09 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-10-23 20:07:30 -0700
commit28191d317a46a1aeb3ec2034de2da626c38b6d73 (patch)
treeaad08fe0e1133b7374e247efe29dac4dea47e04e /092socket.mu
parentccfee30398074e2b5276a0ba295464ded4945ec9 (diff)
downloadmu-28191d317a46a1aeb3ec2034de2da626c38b6d73.tar.gz
3571 - make 'read-from-socket' non-blocking
Its interface now mirrors that of 'read-event'.
Diffstat (limited to '092socket.mu')
-rw-r--r--092socket.mu9
1 files changed, 8 insertions, 1 deletions
diff --git a/092socket.mu b/092socket.mu
index 7acaea63..b1c08b6a 100644
--- a/092socket.mu
+++ b/092socket.mu
@@ -166,7 +166,14 @@ def receive-from-socket socket:num, sink:&:sink:char -> sink:&:sink:char [
   local-scope
   load-ingredients
   {
-    req:text, eof?:bool <- $read-from-socket socket, 4096/bytes
+    +next-attempt
+    req:text, found?:bool, eof?:bool, error:num <- $read-from-socket socket, 4096/bytes
+    break-if error
+    {
+      break-if found?
+      switch
+      loop +next-attempt
+    }
     bytes-read:num <- length *req
     i:num <- copy 0
     {