<div dir="ltr"><div><div>Hi,<br><br></div>In the netconf_client.erl code, The user-defined "Timeout" is passed down until it is used in "receive ... after Timeout" expression in netconf_transport:receive_data/2<br>
<br></div><div>However during the XML processing step, the continuation_fun called cont/3 uses netconf_transport:receive_data/1 once again, but with "receive ... after infinity"<br><br></div><div>Does it mean that the Timeout which user has entered is not used in the continuation_fun? What happens if the netconf_transport:receive_data/1 takes longer than the "Timeout"?<br>
</div><div><br></div><div>Here is the code snippet:<br><br></div><div>%%%%%%%%%%%%% netconf_client.erl %%%%%%%%%%%%%<br><br>get_result(Connection, Timeout) -><br>    case <b>netconf_transport:receive_data(Connection, Timeout)</b> of<br>
    {ok, Data} -><br>        case to_simple_xml(Data, Connection) of<br>        {'rpc-reply',_Attrs,Result} -><br>            Result;<br>        {'nc:rpc-reply',_Attrs,Result} -><br>            Result;<br>
        OtherReply -><br>            OtherReply<br>        end;<br>    {error, Reason} -><br>        {error, Reason}<br>    end.<br><br>to_simple_xml(Bin, Connection) when is_binary(Bin) -><br>    {SimpleXml,_Rest} = xmerl_scan:string("",<br>
                    [{<b>continuation_fun, fun cont/3,</b><br>                      {Bin, false, Connection}},<br>                     {acc_fun,fun acc_simple_xml/3},<br>                     {space,normalize},<br>                     {hook_fun, fun hook_simple_xml/2}]),<br>
    SimpleXml.<br><br>cont(Continue, Exception, GlobalState) -><br>    {OldTail, Found, Connection} = xmerl_scan:cont_state(GlobalState),<br>    if <br>    Found -><br>        Continue(Exception,GlobalState);<br>    true -><br>
        case split_at_marker_or_last_whitespace(OldTail) of<br>        false -><br>            <b>%% Need more data.<br>            {ok, Data} = netconf_transport:receive_data(Connection),</b><br>            NewGlobalState = <br>
            xmerl_scan:cont_state(<br>              {<<OldTail/binary,Data/binary>>, false, Connection},<br>              GlobalState),<br>            cont(Continue, Exception, NewGlobalState);<br>        {Marker, NewData, NewTail} -><br>
            NewGlobalState = <br>            xmerl_scan:cont_state({NewTail, Marker, Connection},<br>                          GlobalState),<br>            netconf_transport:adjust_window(Connection, length(NewData) +<br>
                            case Marker of<br>                            true -><br>                                6;<br>                            _ -><br>                                0<br>                            end),<br>
            Continue(NewData, NewGlobalState)<br>        end<br>    end.<br><br>%%%%%%%%%%%%% netconf_transport.erl %%%%%%%%%%%%%<br>receive_data(Connection) -><br>    receive_data(Connection, <b>infinity</b>).<br>receive_data(#connection{transport = ssh}, Timeout) -><br>
    receive<br>    {ssh_cm, _Cm, {data, _Ch, _Type, Data}} -><br>        {ok, Data};<br>        {ssh_cm, _Cm, {Closed, _Ch}} when Closed == closed; Closed == eof -><br>            exit(closed);<br>        {'DOWN',_,_,_,_} -><br>
            exit(normal)<br>    after <b>Timeout</b> -><br>        {error, timeout}<br>    end;<br><br><br></div><br></div>