Send - buffer overrun

Ulf Wiger (AL/EAB) ulf.wiger@REDACTED
Wed Apr 5 09:49:58 CEST 2006


Claes Wikstrom wrote:
> 
> Ulf Wiger (AL/EAB) wrote:
> 
> > Not that I've used it myself, but the BIFs
> > 
> > erlang:send_nosuspend(Dest, Msg), and
> > erlang:send(Dest, Msg, [nosuspend)
> 
> Wow,
> 
> I wonder what kind of code would use that.

I thought I would find it in the code for 
rpc:abcast/2, but it had another obscure construct:

abcast(Name, Mess) ->
    abcast([node() | nodes()], Name, Mess).
abcast([Node|Tail], Name, Mess) ->
    Dest = {Name,Node},
    case catch erlang:send(Dest, Mess, [noconnect]) of
        noconnect -> spawn(erlang, send, [Dest,Mess]);
        _ -> ok
    end,
    abcast(Tail, Name, Mess);
abcast([], _,_) -> abcast.


I recall the reason for this. We were using rpc:abcast/2
for doing event broadcast, but in the event of comm
problems, each send operation could suspend for as much
as 10 seconds. While this was fine, we had rather that 
it didn't suspend the unsuspecting caller, who 
specifically didn't care about the result (hence abcast).

An obvious alternative would have been to spawn a 
process for each send operation in abcast. AFAIR,
this was considered unattractive at the time, but 
processes were a precious commodity back then. (:

BR,
Ulf W



More information about the erlang-questions mailing list