Skip to content

Commit

Permalink
Errors in fsm should not crash server
Browse files Browse the repository at this point in the history
Problems starting or sending data to the client fsm should not crash the
main seds server.
  • Loading branch information
msantos committed Mar 10, 2015
1 parent 49a6cb9 commit e23e5ef
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/seds.erl
Expand Up @@ -98,15 +98,23 @@ handle_call({send, {IP, Port, #dns_rec{} = Rec,
Session = session(Query, State),
case dict:find(Session, Proxies) of
error when Sum == 0 ->
{ok, Proxy} = proxy(Session, State),
ok = seds_proxy:send(Proxy, IP, Port, Rec, Dir, 0, Data),
{reply, ok, State#state{
p = dict:store(Session, Proxy, Proxies)
}};
P = try
{ok, Proxy} = proxy(Session, State),
ok = seds_proxy:send(Proxy, IP, Port, Rec, Dir, 0, Data),
dict:store(Session, Proxy, Proxies)
catch
_:_ ->
Proxies
end,
{reply, ok, State#state{p = P}};
error ->
{reply, ok, State};
{ok, Proxy} ->
ok = seds_proxy:send(Proxy, IP, Port, Rec, Dir, Sum, Data),
try
ok = seds_proxy:send(Proxy, IP, Port, Rec, Dir, Sum, Data)
catch
_:_ -> ok
end,
{reply, ok, State}
end;

Expand Down

0 comments on commit e23e5ef

Please sign in to comment.