aboutsummaryrefslogtreecommitdiff
path: root/src/extauth.erl
diff options
context:
space:
mode:
authorBadlop <badlop@process-one.net>2009-10-20 15:28:48 +0000
committerBadlop <badlop@process-one.net>2009-10-20 15:28:48 +0000
commit04545f2668a09c5a235007d663a2de0897dd9d18 (patch)
treebe39dbe996ef704c8a121263e107093f710faa90 /src/extauth.erl
parentadd release_notes_2.0.1 (diff)
parentdoes not use slash as default separator in nodename (EJAB-667) (diff)
Create branch for ejabberd 2.1.x release line.
SVN Revision: 2688
Diffstat (limited to 'src/extauth.erl')
-rw-r--r--src/extauth.erl23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/extauth.erl b/src/extauth.erl
index 052e95d7a..b363b8016 100644
--- a/src/extauth.erl
+++ b/src/extauth.erl
@@ -5,7 +5,7 @@
%%% Created : 30 Jul 2004 by Leif Johansson <leifj@it.su.se>
%%%
%%%
-%%% ejabberd, Copyright (C) 2002-2008 Process-one
+%%% ejabberd, Copyright (C) 2002-2009 ProcessOne
%%%
%%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as
@@ -16,7 +16,7 @@
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
%%% General Public License for more details.
-%%%
+%%%
%%% You should have received a copy of the GNU General Public License
%%% along with this program; if not, write to the Free Software
%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
@@ -32,6 +32,9 @@
-include("ejabberd.hrl").
+-define(INIT_TIMEOUT, 60000). % Timeout is in milliseconds: 60 seconds == 60000
+-define(CALL_TIMEOUT, 10000). % Timeout is in milliseconds: 10 seconds == 10000
+
start(Host, ExtPrg) ->
spawn(?MODULE, init, [Host, ExtPrg]).
@@ -39,7 +42,7 @@ init(Host, ExtPrg) ->
register(gen_mod:get_module_proc(Host, eauth), self()),
process_flag(trap_exit,true),
Port = open_port({spawn, ExtPrg}, [{packet,2}]),
- loop(Port).
+ loop(Port, ?INIT_TIMEOUT).
stop(Host) ->
gen_mod:get_module_proc(Host, eauth) ! stop.
@@ -61,15 +64,23 @@ call_port(Server, Msg) ->
Result
end.
-loop(Port) ->
+loop(Port, Timeout) ->
receive
{call, Caller, Msg} ->
Port ! {self(), {command, encode(Msg)}},
receive
{Port, {data, Data}} ->
- Caller ! {eauth, decode(Data)}
+ ?DEBUG("extauth call '~p' received data response:~n~p", [Msg, Data]),
+ Caller ! {eauth, decode(Data)};
+ {Port, Other} ->
+ ?ERROR_MSG("extauth call '~p' received strange response:~n~p", [Msg, Other]),
+ Caller ! {eauth, false}
+ after
+ Timeout ->
+ ?ERROR_MSG("extauth call '~p' didn't receive response", [Msg]),
+ Caller ! {eauth, false}
end,
- loop(Port);
+ loop(Port, ?CALL_TIMEOUT);
stop ->
Port ! {self(), close},
receive