On 24/04/2007, at 10:59, Henrik Mikael Kristensen wrote:

>
> Anyway, the goal is to prevent this annoying hang at any case. I
> think the proper way would be to remove the port, if the data can't
> be sent back.

I've found an issue with write-io on a dead port in Rugby's write-msg  
function. It's the function to write a response to the client.

If write-io encounters a dead port, it simply hangs.

write-msg: func
   [
    {Does a low-level write of a message.}
     msg
     dest [port!]
     /local length
   ]
   [
     ; this function hangs on console escape on the client
     ; We try to write at least 16000 bytes at a time
     either 16000 > length? msg
     [
       length: write-io dest msg length? msg ; <-- hangs on dead port

       ; Message written, we're done
       either length = length? msg
       [
         return true
       ]
       ; We're not done. Return what we have written
       [
         return length
       ]
     ]
     [
       length: write-io dest msg 16000 ; <--- hangs on dead port
     ]
     ; We're done, port is closed
     if 0 > length [return true]

     return length
   ]

I don't know how WRITE-IO really works, beyond it being an INSERT  
with a length indicator and an advice in the REBOL dictionary on not  
to use it.

I tried with INSERT with the same hang results, so I guess I need to  
check if the port is OK before touching it with WRITE-IO. How does  
one best do that?

Even if there is a check, you still need to use WRITE-IO, so what if  
the port dies between that check and WRITE-IO?

--
Regards,
Henrik Mikael Kristensen


-- 
To unsubscribe from the list, just send an email to 
lists at rebol.com with unsubscribe as the subject.

Reply via email to