[ejabberd] blocking send and latency

Evgeniy Khramtsov xramtsov at gmail.com
Tue Oct 28 05:39:24 MSK 2008


Jack Moffitt wrote:

>I discovered that gen_tcp:send is blocking and that a non-blocking version does not exist.
>  
>

prim_inet:send/2 is not blocking in general. It hangs when there is a 
lot of data in the sndbuf to be sent (this happens for example when a 
receiver is too slow to read its socket). In this situation inet_drv.c 
is unable to dequeue sndbuf and forces prim_inet:send/2 to hang to avoid 
memory overflow. However, memory overflow problem lays on the shoulders 
of prim_inet:send/2 caller due to mailbox overflow. To avoid this 
situation {send_timeout, Integer} option was introduced in Elang R11-B4: 
if prim_inet:send/2 hangs more than Integer milliseconds, gen_tcp:send/2 
returns {error, timeout}.

>The solution to this is just to use another process and send it messages, but I
>noticed that ejabberd does not seem to do this.
>

I don't think this is a solution really, since you can easily overflow 
mailbox of sending process.

-- 
Regards,
Evgeniy Khramtsov, ProcessOne.
xmpp:xram at jabber.ru.



More information about the ejabberd mailing list