aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2010-08-05 17:37:48 +0200
committerHarald Welte <laforge@gnumonks.org>2010-08-05 17:37:48 +0200
commit53e428eae0fe524dd9e70d353e738bdd7297bafa (patch)
tree05114dd035fd68820b7cd770fc0ff39cf2fde60d
parente79c320b655149b25bc202ca691a2ed1663a9825 (diff)
[IPA] make sure ipa_proto:connect() returns {ok, Socket}
-rw-r--r--src/ipa_proto.erl8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/ipa_proto.erl b/src/ipa_proto.erl
index 7386297..a7ff081 100644
--- a/src/ipa_proto.erl
+++ b/src/ipa_proto.erl
@@ -210,7 +210,13 @@ connect(Address, Port, Options) ->
connect(Address, Port, Options, Timeout) ->
case gen_tcp:connect(Address, Port, ?IPA_SOCKOPTS ++ Options, Timeout) of
{ok, Socket} ->
- ipa_proto:register_socket(Socket);
+ case ipa_proto:register_socket(Socket) of
+ {ok, _} ->
+ {ok, Socket};
+ {error, Reason} ->
+ gen_tcp:close(Socket),
+ {error, Reason}
+ end;
{error, Reason} ->
{error, Reason}
end.