1
0
mirror of https://github.com/ubf/ubf.git synced 2026-04-26 06:37:42 +00:00

bugfix - ubf client behavior, rollback server socket active behavior, and fix 2 previous unit tests

This commit is contained in:
Joseph Wayne Norton
2009-06-12 11:46:48 +09:00
parent fb023c8059
commit ce06d1955d
5 changed files with 23 additions and 28 deletions

View File

@@ -29,7 +29,7 @@ all_tests_(Setup,Teardown) ->
Teardown,
(all_actual_tests_("localhost",3000,ubf,true))(not_used)
++ (all_actual_tests_("localhost",3001,ebf,true))(not_used)
%% ++ (all_actual_tests_("localhost",3002,jsf,true))(not_used)
%% DISABLE ++ (all_actual_tests_("localhost",3002,jsf,true))(not_used)
%% TODO ++ (all_actual_tests_("localhost",none,etf))(not_used)
}.

View File

@@ -5,7 +5,7 @@
-include("ubf.hrl").
do_eunit() ->
case eunit:test(?MODULE) of
case eunit:test({timeout,30,?MODULE}) of
ok -> ok;
_ -> erlang:halt(1)
end.
@@ -29,7 +29,7 @@ all_tests_(Setup,Teardown) ->
Teardown,
(all_actual_tests_("localhost",3000,ubf,false))(not_used)
++ (all_actual_tests_("localhost",3001,ebf,false))(not_used)
%% ++ (all_actual_tests_("localhost",3002,jsf,false))(not_used)
%% DISABLE ++ (all_actual_tests_("localhost",3002,jsf,false))(not_used)
%% TODO ++ (all_actual_tests_("localhost",none,etf))(not_used)
}.
@@ -51,14 +51,14 @@ all_actual_tests_(Host,Port,Proto,Stateless) ->
%%%----------------------------------------------------------------------
test_setup(Sup) ->
%% user_default:dbgoff(),
%% user_default:dbgon(ubf_client),
%% user_default:dbgadd(contract_manager),
%% user_default:dbgadd(ubf_driver),
%% user_default:dbgadd(ubf_plugin_handler),
%% user_default:dbgadd(ubf_plugin_metaserverful),
%% user_default:dbgadd(ubf_plugin_metaserverless),
%% user_default:dbgadd(ubf_server),
%% user_default:dbgoff(),
%% user_default:dbgon(ubf_client),
%% user_default:dbgadd(contract_manager),
%% user_default:dbgadd(ubf_driver),
%% user_default:dbgadd(ubf_plugin_handler),
%% user_default:dbgadd(ubf_plugin_metaserverful),
%% user_default:dbgadd(ubf_plugin_metaserverless),
%% user_default:dbgadd(ubf_server),
kill_process(undefined),
@@ -133,7 +133,6 @@ test_004(Host,Port,Proto,Stateless) ->
assert_process(Proto, 0, 0, 0).
%% connect -> client timeout -> close
%% @todo fix ubf_client behavior
test_005(Host,Port,Proto,Stateless) ->
assert_process(Proto, 0, 0, 0),
{ok,Pid,?S("test_meta_server")} = ubf_client:connect(Host,Port,[{proto,Proto},{statelessrpc,Stateless}],infinity),
@@ -143,13 +142,7 @@ test_005(Host,Port,Proto,Stateless) ->
{reply,ok,none} = ubf_client:rpc(Pid,keepalive),
assert_process(Proto, 1, 1, 1),
timeout = ubf_client:rpc(Pid,{client_timeout_req03,1000},500),
assert_process(Proto, 1, 1, 1),
timer:sleep(1100),
assert_process(Proto, 1, 1, 1),
{reply,client_timeout_res03,none} = ubf_client:rpc(Pid,keepalive),
assert_process(Proto, 1, 1, 1),
{reply,ok,none} = ubf_client:rpc(Pid,keepalive),
assert_process(Proto, 1, 1, 1),
assert_process(Proto, 0, 0, 0),
ubf_client:stop(Pid),
assert_process(Proto, 0, 0, 0).
@@ -187,7 +180,6 @@ test_007(Host,Port,Proto,Stateless) ->
assert_process(Proto, 0, 0, 0).
%% connect -> server crash -> close
%% @todo fix ubf_client behavior
test_008(Host,Port,Proto,Stateless) ->
assert_process(Proto, 0, 0, 0),
{ok,Pid,?S("test_meta_server")} = ubf_client:connect(Host,Port,[{proto,Proto},{statelessrpc,Stateless}],infinity),
@@ -196,7 +188,7 @@ test_008(Host,Port,Proto,Stateless) ->
assert_process(Proto, 1, 1, 1),
{reply,ok,none} = ubf_client:rpc(Pid,keepalive),
assert_process(Proto, 1, 1, 1),
timeout = ubf_client:rpc(Pid,server_crash_req05,500),
{error,stop} = ubf_client:rpc(Pid,server_crash_req05,50000),
assert_process(Proto, 0, 0, 0),
ubf_client:stop(Pid),
assert_process(Proto, 0, 0, 0).

View File

@@ -65,7 +65,7 @@ cold_start(Port, Fun, Max, PacketType, PacketSize) ->
process_flag(trap_exit, true),
%% io:format("Starting a port server on ~p...~n",[Port]),
DefaultListenOptions =
[binary, {nodelay, true}, {active, false}, {reuseaddr, true}, {backlog, 100}],
[binary, {nodelay, true}, {active, true}, {reuseaddr, true}, {backlog, 100}],
ListenOptions =
case {PacketType, PacketSize} of
{0,0} ->
@@ -120,6 +120,7 @@ start_child(Parent, Listen, Fun) ->
case gen_tcp:accept(Listen) of
{ok, Socket} ->
Parent ! {started, self()}, % tell the controller
inet:setopts(Socket, [{active, true}]), % before we activate socket
%% Start the child
%% io:format("Starting a child on:~p~n",[Socket]),
case (catch Fun(Socket)) of

View File

@@ -212,7 +212,7 @@ rpc(Pid, Q, Timeout) ->
"<<< ~p ~n",[Q, Reply]),
Reply
after Timeout ->
exit(Pid, timeout),
Pid ! stop,
timeout
end.
@@ -277,7 +277,13 @@ loop(Driver, Fun) ->
{Driver, {error, X}} ->
From ! {self(), {error, X}};
{Driver, Other} ->
From ! {self(), {error, Other}}
From ! {self(), {error, Other}};
{'EXIT', Driver, Reason} ->
From ! {self(), {error, Reason}};
stop ->
From ! {self(), {error, stop}},
Driver ! stop,
true
end;
{Driver, {event, Msg, State}} ->
Fun1 = Fun(Msg, State),

View File

@@ -189,10 +189,6 @@ start_ubf_listener(MetaServerModule, Port, Server, Options) ->
Server, MetaServerModule},
%% and activate the loop that will now
%% execute the last two statements :-)
inet:setopts(Socket, [{active, true}
%%, {send_timeout, IdleTimer}
%%, {send_timeout_close, true}
]),
DriverModule:loop(Socket, self(), IdleTimer)
end,
proplists:get_value(maxconn,Options,10000),