Permalink
Browse files

Fix crash when pool option is a process name

The gen_tcp:controlling_process/2 and ssl:controlling_process/2
functions only accept PIDs, so if the pool is a registered process
name (atom) we need to get its PID.
  • Loading branch information...
1 parent 0b52278 commit 9c7252971d17aeff92bf7d08782f8e91241dc3cd @fdmanana fdmanana committed Apr 9, 2012
Showing with 5 additions and 3 deletions.
  1. +5 −3 src/lhttpc_sock.erl
View
@@ -115,16 +115,18 @@ send(Socket, Request, true) ->
send(Socket, Request, false) ->
gen_tcp:send(Socket, Request).
-%% @spec (Socket, Pid, SslFlag) -> ok | {error, Reason}
+%% @spec (Socket, Process, SslFlag) -> ok | {error, Reason}
%% Socket = socket()
-%% Pid = pid()
+%% Process = pid() | atom()
%% SslFlag = boolean()
%% Reason = atom()
%% @doc
%% Sets the controlling proces for the `Socket'.
%% @end
--spec controlling_process(socket(), pid(), boolean()) ->
+-spec controlling_process(socket(), pid() | atom(), boolean()) ->
ok | {error, atom()}.
+controlling_process(Socket, Controller, IsSsl) when is_atom(Controller) ->
+ controlling_process(Socket, whereis(Controller), IsSsl);
controlling_process(Socket, Pid, true) ->
ssl:controlling_process(Socket, Pid);
controlling_process(Socket, Pid, false) ->

0 comments on commit 9c72529

Please sign in to comment.