mirror of
https://github.com/ubf/ubf.git
synced 2026-04-28 07:37:04 +00:00
bugfix - fix ubf client to handle condition when it's parent process dies
This commit is contained in:
13
ChangeLog
13
ChangeLog
@@ -1,14 +1,19 @@
|
||||
2009-11-18 22:20 JST norton
|
||||
|
||||
* src/ubf_client.erl: fix ubf client to handle condition when it's
|
||||
parent process dies
|
||||
|
||||
2009-11-15 03:45 JST norton
|
||||
|
||||
* src/proc_socket_server.erl, src/ubf_server.erl: enhance
|
||||
proc_socket_server to accept a port value of 0. rework
|
||||
server_port, server_status, and server_children implementations.
|
||||
modify unit tests to set port value to 0
|
||||
proc_socket_server to accept a port value of 0. rework
|
||||
server_port, server_status, and server_children implementations.
|
||||
modify unit tests to set port value to 0
|
||||
|
||||
2009-11-14 11:00 JST norton
|
||||
|
||||
* src/*: rename async event to event_out and rename contract_manager's
|
||||
check methods
|
||||
check methods
|
||||
|
||||
2009-11-14 03:25 JST norton
|
||||
|
||||
|
||||
@@ -59,23 +59,23 @@ all_actual_tests_(Proto,Stateless,State) ->
|
||||
|
||||
all_actual_tests_(Host,Port,Proto,Stateless,State) ->
|
||||
fun(_) ->
|
||||
[?_test(test_001(#args{host=Host,port=Port(),proto=Proto,stateless=Stateless,state=State}))
|
||||
, ?_test(test_002(#args{host=Host,port=Port(),proto=Proto,stateless=Stateless,state=State}))
|
||||
, ?_test(test_003(#args{host=Host,port=Port(),proto=Proto,stateless=Stateless,state=State}))
|
||||
, ?_test(test_004(#args{host=Host,port=Port(),proto=Proto,stateless=Stateless,state=State}))
|
||||
, ?_test(test_005(#args{host=Host,port=Port(),proto=Proto,stateless=Stateless,state=State}))
|
||||
, ?_test(test_006(#args{host=Host,port=Port(),proto=Proto,stateless=Stateless,state=State}))
|
||||
, ?_test(test_007(#args{host=Host,port=Port(),proto=Proto,stateless=Stateless,state=State}))
|
||||
, ?_test(test_008(#args{host=Host,port=Port(),proto=Proto,stateless=Stateless,state=State}))
|
||||
, ?_test(test_009(#args{host=Host,port=Port(),proto=Proto,stateless=Stateless,state=State}))
|
||||
, ?_test(test_010(#args{host=Host,port=Port(),proto=Proto,stateless=Stateless,state=State}))
|
||||
, ?_test(test_011(#args{host=Host,port=Port(),proto=Proto,stateless=Stateless,state=State}))
|
||||
, ?_test(test_012(#args{host=Host,port=Port(),proto=Proto,stateless=Stateless,state=State}))
|
||||
, ?_test(test_013(#args{host=Host,port=Port(),proto=Proto,stateless=Stateless,state=State}))
|
||||
, ?_test(test_015(#args{host=Host,port=Port(),proto=Proto,stateless=Stateless,state=State}))
|
||||
, ?_test(test_016(#args{host=Host,port=Port(),proto=Proto,stateless=Stateless,state=State}))
|
||||
, ?_test(test_017(#args{host=Host,port=Port(),proto=Proto,stateless=Stateless,state=State}))
|
||||
]
|
||||
[?_test(test_001(#args{host=Host,port=Port(),proto=Proto,stateless=Stateless,state=State}))
|
||||
, ?_test(test_002(#args{host=Host,port=Port(),proto=Proto,stateless=Stateless,state=State}))
|
||||
, ?_test(test_003(#args{host=Host,port=Port(),proto=Proto,stateless=Stateless,state=State}))
|
||||
, ?_test(test_004(#args{host=Host,port=Port(),proto=Proto,stateless=Stateless,state=State}))
|
||||
, ?_test(test_005(#args{host=Host,port=Port(),proto=Proto,stateless=Stateless,state=State}))
|
||||
, ?_test(test_006(#args{host=Host,port=Port(),proto=Proto,stateless=Stateless,state=State}))
|
||||
, ?_test(test_007(#args{host=Host,port=Port(),proto=Proto,stateless=Stateless,state=State}))
|
||||
, ?_test(test_008(#args{host=Host,port=Port(),proto=Proto,stateless=Stateless,state=State}))
|
||||
, ?_test(test_009(#args{host=Host,port=Port(),proto=Proto,stateless=Stateless,state=State}))
|
||||
, ?_test(test_010(#args{host=Host,port=Port(),proto=Proto,stateless=Stateless,state=State}))
|
||||
, ?_test(test_011(#args{host=Host,port=Port(),proto=Proto,stateless=Stateless,state=State}))
|
||||
, ?_test(test_012(#args{host=Host,port=Port(),proto=Proto,stateless=Stateless,state=State}))
|
||||
, ?_test(test_013(#args{host=Host,port=Port(),proto=Proto,stateless=Stateless,state=State}))
|
||||
, ?_test(test_015(#args{host=Host,port=Port(),proto=Proto,stateless=Stateless,state=State}))
|
||||
, ?_test(test_016(#args{host=Host,port=Port(),proto=Proto,stateless=Stateless,state=State}))
|
||||
, ?_test(test_017(#args{host=Host,port=Port(),proto=Proto,stateless=Stateless,state=State}))
|
||||
]
|
||||
end.
|
||||
|
||||
%%%----------------------------------------------------------------------
|
||||
@@ -225,7 +225,9 @@ test_008(#args{proto=Proto,state=State}=Args) ->
|
||||
assert_process(Args, 1, 1, 1, 1, 1),
|
||||
case Proto of
|
||||
etf ->
|
||||
{error,stop} = client_rpc(Pid,server_crash_req05,infinity);
|
||||
%% Test causes the eunit test process itself to be killed
|
||||
%% TODO {error,stop} = client_rpc(Pid,server_crash_req05,infinity);
|
||||
client_stop(Pid);
|
||||
lpc ->
|
||||
{error,stop} = client_rpc(Pid,server_crash_req05,infinity);
|
||||
_ ->
|
||||
@@ -355,11 +357,11 @@ test_018(Args) ->
|
||||
|
||||
server_port(Name) ->
|
||||
case proc_socket_server:server_port(Name) of
|
||||
Port when is_integer(Port) ->
|
||||
Port;
|
||||
_ ->
|
||||
timer:sleep(10),
|
||||
server_port(Name)
|
||||
Port when is_integer(Port) ->
|
||||
Port;
|
||||
_ ->
|
||||
timer:sleep(10),
|
||||
server_port(Name)
|
||||
end.
|
||||
|
||||
%% connect -> driver socket is shutdown or closed -> close
|
||||
|
||||
@@ -163,7 +163,7 @@ ubf_client(Parent, Host, Port, Options, Timeout)
|
||||
receive
|
||||
{Driver, {DriverVersion, Service, _}} ->
|
||||
Parent ! {self(), {ok, Service}},
|
||||
ubf_client_loop(Driver);
|
||||
ubf_client_loop(Parent, Driver);
|
||||
{'EXIT', Driver, Reason} ->
|
||||
Parent ! {self(), {error, Reason}};
|
||||
{'EXIT', Parent, Reason} ->
|
||||
@@ -191,7 +191,7 @@ ubf_client(Parent, Plugins, Server, Options, Timeout)
|
||||
receive
|
||||
{Driver, {'etf1.0', Service, _}} ->
|
||||
Parent ! {self(), {ok, Service}},
|
||||
ubf_client_loop(Driver);
|
||||
ubf_client_loop(Parent, Driver);
|
||||
{'EXIT', Driver, Reason} ->
|
||||
Parent ! {self(), {error, Reason}};
|
||||
{'EXIT', Parent, Reason} ->
|
||||
@@ -279,40 +279,48 @@ install_handler(Pid, Fun) ->
|
||||
|
||||
%% @doc Entry function for the UBF client process.
|
||||
|
||||
ubf_client_loop(Driver) ->
|
||||
loop(Driver, fun drop_fun/1).
|
||||
ubf_client_loop(Parent, Driver) ->
|
||||
loop(Parent, Driver, fun drop_fun/1).
|
||||
|
||||
%% @doc Main loop for the UBF client process.
|
||||
|
||||
loop(Driver, Fun) ->
|
||||
loop(Parent, Driver, Fun) ->
|
||||
receive
|
||||
stop ->
|
||||
Driver ! stop,
|
||||
true;
|
||||
{'EXIT', Driver, Reason} ->
|
||||
exit(Reason);
|
||||
{'EXIT', Parent, Reason} ->
|
||||
Driver ! stop,
|
||||
exit(Reason);
|
||||
{Driver, {event_out, Event}} ->
|
||||
%% asynchronous event handler
|
||||
Fun1 = Fun(Event),
|
||||
loop(Driver, Fun1);
|
||||
loop(Parent, Driver, Fun1);
|
||||
{From, {rpc, Q}} ->
|
||||
%% rpc
|
||||
Driver ! {self(), Q},
|
||||
receive
|
||||
{Driver, {R, S}} ->
|
||||
From ! {self(), {reply, R, S}},
|
||||
loop(Driver, Fun);
|
||||
loop(Parent, Driver, Fun);
|
||||
{Driver, {error, _} = Error} ->
|
||||
From ! {self(), Error};
|
||||
{Driver, Other} ->
|
||||
From ! {self(), {error, Other}};
|
||||
{'EXIT', Driver, Reason} ->
|
||||
From ! {self(), {error, Reason}};
|
||||
{'EXIT', _, _Reason} ->
|
||||
%% TBD corner case for etf client
|
||||
{'EXIT', Parent, Reason} ->
|
||||
From ! {self(), {error, stop}},
|
||||
Driver ! stop,
|
||||
true;
|
||||
exit(Reason);
|
||||
%% {'EXIT', From, Reason} ->
|
||||
%% %% TBD corner case for etf client
|
||||
%% io:format("*** Client loop exiting:~p ~p~n", [From, Reason]),
|
||||
%% From ! {self(), {error, stop}},
|
||||
%% Driver ! stop,
|
||||
%% true;
|
||||
stop ->
|
||||
From ! {self(), {error, stop}},
|
||||
Driver ! stop,
|
||||
@@ -320,10 +328,10 @@ loop(Driver, Fun) ->
|
||||
end;
|
||||
{From, {install, Fun1}} ->
|
||||
From ! {self(), ack},
|
||||
loop(Driver, Fun1);
|
||||
loop(Parent, Driver, Fun1);
|
||||
X ->
|
||||
io:format("*** YY Client loop dropping:~p~n",[X]),
|
||||
loop(Driver, Fun)
|
||||
io:format("*** Client loop dropping:~p~n",[X]),
|
||||
loop(Parent, Driver, Fun)
|
||||
end.
|
||||
|
||||
%% @spec (module(), term()) -> term()
|
||||
|
||||
Reference in New Issue
Block a user