[Freeswitch-dev] Freeswitch locking up after reply for ERLang sofia.conf is sent
Andrew Thompson
andrew at hijacked.us
Mon Sep 21 12:21:00 PDT 2009
On Mon, Sep 21, 2009 at 12:58:57PM -0400, Andrew Thompson wrote:
> I'll try to look at this later today - it's probably a bug (although I
> do quite a bit of XML config serving myself without having seen this
> issue).
>
Okay, I just tested this, and it didn't hang for me. I don't think I had
all the required code to actually run your example though so I
refactored it to be a single process (removing the Pid argument to
start()).
Can you test with the attached version and see if you still see the
failure? I tested by starting the module and then running 'reload
mod_sofia' from the freeswitch console. How were you testing it?
Andrew
-------------- next part --------------
%% Author: mark
%% Created: Sep 15, 2009
%% Description: TODO: Add description to freeswitch_callback
-module(freeswitch_callback).
-behaviour(gen_server).
-record(st, {fsnode, pbxpid}).
-export([start/2, terminate/2, code_change/3, init/1,
handle_call/3, handle_cast/2, handle_info/2,
xml_fetch/1]).
start(Node, Section) ->
gen_server:start(?MODULE, [Node, Section], []).
init([Node, Section]) ->
io:format( "freeswitch_callback:init( [Node=~w, Section=~w])~n", [Node, Section] ),
{api, Node} ! {bind, Section},
{ok, #st{fsnode=Node}}.
terminate(_Reason, _State) ->
ok.
code_change(_OldVsn, State, _Extra) ->
{ok, State}.
dumpParams( Params ) ->
case Params of
[] ->
ok;
[ H | T ] ->
case H of
undefined ->
io:format( " undefined~n" );
{ Key, Value } ->
io:format( " ~s=~s~n", [Key, Value ] )
end,
dumpParams( T )
end.
%%
%% Configuration handler for mod_sofia.
%%
xml_fetch({fetch, configuration, "configuration", "name", "sofia.conf", Params}) ->
io:format( "freeswitch_callback:handle_call( {fetch, configuration, Tag=\"configuration\", Key=\"name\", Value=\"sofia.conf\", Params=...} )~n"),
dumpParams( Params ),
Xml =
"<document type=\"freeswitch/xml\">
<section name=\"configuration\">
<configuration name=\"sofia.conf\" description=\"sofia Endpoint\">
<global_settings>
<param name=\"log-level\" value=\"0\" />
<param name=\"auto-restart\" value=\"false\" />
<param name=\"debug-presence\" value=\"0\" />
</glogal_settings>
<settings>
<!-- ADD parameters here -->
</settings>
<profiles>
<profile name=\"external\">
<gateways>
<!-- Add gateways here -->
<gateway name=\"asterlink.com\">
<param name=\"\" value=\"\" />
<param name=\"\" value=\"\" />
<param name=\"\" value=\"\" />
<param name=\"\" value=\"\" />
<param name=\"\" value=\"\" />
<param name=\"\" value=\"\" />
<param name=\"\" value=\"\" />
</gateway>
</gateways>
<aliases>
<alias name=\"outbound\" />
<alias name=\"nat\" />
</aliases>
<domains>
<domain name=\"all\" alias=\"false\" parse=\"true\" />
</domains>
<settings>
<param name=\"debug\" value=\"0\" />
<param name=\"sip-trace\" value=\"no\" />
<param name=\"rfc2833-pt\" value=\"101\" />
<param name=\"sip-port\" value=\"6080\" />
<param name=\"dialplan\" value=\"XML\" />
<param name=\"context\" value=\"public\" />
<param name=\"dtmf-duration\" value=\"100\" />
<param name=\"codec-prefs\" value=\"PCMU,PCMA,GSM\" />
<param name=\"hold-music\" value=\"local_stream://moh\" />
<param name=\"rtp-timer-name\" value=\"soft\" />
<!--param name=\"enable-100rel\" value=\"true\" / -->
<param name=\"manage-presence\" value=\"false\" />
<!-- param name=\"dbname\" value=\"share_presence\" / -->
<!-- param name=\"presence-hosts\" value=\"10.77.0.254\" / -->
<!-- param name=\"force-register-domain\" value=\"10.77.0.254\" / -->
<!-- param name=\"force-register-db-domain\" value=\"10.77.0.254\" / -->
<!-- param name=\"aggressive-nat-detection\" value=\"true\" / -->
<param name=\"inbound-codec-negotiation\" value=\"generous\" />
<param name=\"nonce-ttl\" value=\"60\" />
<param name=\"auth-calls\" value=\"false\" />
<param name=\"rtp-timeout-sec\" value=\"1800\" />
<param name=\"rtp-ip\" value=\"10.77.0.254\" />
<param name=\"sip-ip\" value=\"10.77.0.254\" />
<param name=\"ext-rtp-ip\" value=\"stun:stun.freeswitch.org\" />
<param name=\"ext-sip-ip\" value=\"stun:stun.freeswitch.org\" />
<param name=\"rtp-timout-sec\" value=\"300\" />
<param name=\"rtp-hold-timeout-sec\" value=\"1800\" />
<!-- param name=\"enable-3pcc\" value=\"true\" / -->
<param name=\"tls-bind-params\" value=\"transport=tls\" />
<param name=\"tls-sip-port\" value=\"6081\" />
<param name=\"tls-cert-dir\" value=\"/opt/freeswitch/conf/ssl\" />
<param name=\"tls-version\" value=\"tlsv1\" />
<!-- param name=\"rtp-autoflush-during-bridge\" value=\"false\" / -->
<!-- param name=\"rtp-rewrite-timestamp\" value=\"true\" / -->
<!-- param name=\"pass-rfc2833\" value=\"true\" / -->
<!-- param name=\"odbc-dsn\" value=\"dsn:user:pass\" / -->
<!-- param name=\"inbound-bypass-media\" value=\"true\" / -->
<!-- param name=\"inbound-proxy-media\" value=\"true\" / -->
<!-- param name=\"inbound-late-negotiation\" value=\"true\" / -->
<!-- param name=\"accept-blind-reg\" value=\"true\" / -->
<!-- param name=\"accept-blind-auth\" value=\"true\" / -->
<!-- param name=\"suppress-cng\" value=\"true\" / -->
<param name=\"nonce-ttl\" value=\"60\" />
<!-- param name=\"disable-transcoding\" value=\"true\" / -->
<!-- param name=\"disable-transfer\" value=\"true\" / -->
<!-- param name=\"NDLB-broken-auth-hash\" value=\"true\" / -->
<!-- param name=\"NDLB-received-in-nat-reg-contact\" value=\"true\" / -->
<param name=\"auth-calls\" value=\"true\" />
<param name=\"inbound-reg-force-matching-username\" value=\"true\" />
<param name=\"auth-all-packets\" value=\"false\" />
<!-- param name=\"ext-rtp-ip\" value=\"stun.freeswitch.org\" / -->
<!-- param name=\"ext-sip-ip\" value=\"stun.freeswitch.org\" / -->
<param name=\"rtp-timeout-sec\" value=\"300\" />
<param name=\"rtp-hold-timeout-sec\" value=\"1800\" />
<!-- param name=\"vad\" value=\"in\" / -->
<!-- param name=\"vad\" value=\"out\" / -->
<!-- param name=\"vad\" value=\"both\" / -->
<!-- param name=\"alias\" value=\"sip:10.77.0.231:5555\" / -->
<param name=\"force-register-domain\" value=\"10.77.0.231\" />
<param name=\"force-register-db-domain\" value=\"10.77.0.231\" />
<!-- param name=\"force-subscription-expires\" value=\"60\" / -->
<!-- param name=\"disable-transfer\" value=\"true\" / -->
<!-- param name=\"disable-register\" value=\"true\" / -->
<!-- param name=\"enable-3pcc\" value=\"true\" / -->
<!-- param name=\"NDLB-force-rport\" value=\"true\" / -->
<param name=\"challenge-realm\" value=\"auto_from\" />
<!-- param name=\"disable-rtp-auto-adjust\" value=\"true\" / -->
<!-- param name=\"inbound-use-callid-as-uuid\" value=\"true\" / -->
<!-- param name=\"outbound-use-uuid-as-callid\" value=\"true\" / -->
<!-- param name=\"rtp-autofix-timing\" value=\"false\" / -->
<!-- param name=\"auto-rtp-bugs\" data=\"clear\" / -->
<!-- param name=\"disable-srv\" value=\"false\" / -->
<!-- param name=\"disable-naptr\" value=\"false\" / -->
<!-- param name=\"timer-T1\" value=\"800\" / -->
<!-- param name=\"timer-T1X64\" value=\"32000\" / -->
<!-- param name=\"timer-T2\" value=\"4000\" / -->
<!-- param name=\"timer-T4\" value=\"4000\" / -->
</settings>
</profile>
</profiles>
</configuration>
</section>
</document>",
{ok, Xml };
%%
%% Configuration handler replies that the requested document section, tag, and key are not
%% found.
%%
xml_fetch({fetch, configuration, Tag, Key, Value, Params}) ->
io:format( "freeswitch_callback:handle_call( {fetch, configuration, Tag=~s, Key=~s, Value=~s, Params=...} )~n",
[Tag, Key, Value]),
dumpParams( Params ),
Xml =
"<document type=\"freeswitch/xml\">
<section name=\"result\">
<result status=\"not found\" />
</section>
</document>",
{ok, Xml };
%%
%% Directory handler replies that the requested document section, tag, and key are not
%% found.
%%
xml_fetch({fetch, directory, Tag, Key, Value, Params}) ->
io:format( "freeswitch_callback:xml_fetch( {fetch, directory, Tag=~s, Key=~s, Value=~s, Params=...} )~n",
[Tag, Key, Value]),
dumpParams( Params ),
Xml =
"<document type=\"freeswitch/xml\">
<section name=\"result\">
<result status=\"not found\" />
</section>
</document>",
{ok, Xml };
%%
%% Dialplan handler replies that the requested document section, tag, and key are not
%% found.
%%
xml_fetch({fetch, dialplan, Tag, Key, Value, Params}) ->
io:format( "freeswitch_callback:xml_fetch( {fetch, dialplan, Tag=~s, Key=~s, Value=~s, Params=...} )~n",
[Tag, Key, Value]),
dumpParams( Params ),
Xml =
"<document type=\"freeswitch/xml\">
<section name=\"result\">
<result status=\"not found\" />
</section>
</document>",
{ok, Xml };
%%
%% Default handler replies that the requested document section, tag, and key are not
%% found.
%%
xml_fetch({fetch, Section, Tag, Key, Value, Params}) ->
io:format( "freeswitch_callback:xml_fetch( {fetch, Section=~w, Tag=~s, Key=~s, Value=~s, Params=...} )~n",
[Section, Tag, Key, Value]),
dumpParams( Params ),
Xml =
"<document type=\"freeswitch/xml\">
<section name=\"result\">
<result status=\"not found\" />
</section>
</document>",
{ok, Xml };
%%
%% If the request isn't recognized, just log it.
%%
xml_fetch( Request ) ->
io:format( "freeswitch_callback:xml_fetch( Request=~w ) not recognized~n",
[Request]),
Xml =
"<document type=\"freeswitch/xml\">
<section name=\"result\">
<result status=\"not found\" />
</section>
</document>",
{ok, Xml }.
%%
%% If the request isn't recognized, just log it and do nothing.
%%
handle_call(Request, _From, State) ->
io:format("freeswitch_callback:handle_call( ~w, _From, State) unrecognized request~n",
[Request]),
{reply, {error, unrecognized_request}, State}.
handle_cast(Message, State) ->
error_logger:error_msg("~p received unrecognized cast ~p~n",
[self(), Message]),
{noreply, State}.
handle_info({fetch, Section, Tag, Key, Value, FetchID, Params}, #st{fsnode=Node}=State) ->
{ok, XML} = xml_fetch({fetch, Section, Tag, Key, Value, Params}),
{api, Node} ! {fetch_reply, FetchID, XML},
receive
ok ->
{noreply, State};
{error, Reason} ->
{stop, {error, Reason}, State}
end;
handle_info(Info, State) ->
io:format( "freeswitch_callback:handle_info() Info=~w~n", [Info]),
{noreply, State}.
More information about the FreeSWITCH-dev
mailing list