diff options
author | Siri Hansen <[email protected]> | 2012-07-04 11:18:29 +0200 |
---|---|---|
committer | Siri Hansen <[email protected]> | 2012-08-17 11:15:49 +0200 |
commit | 1bf4656b1f7802af453f46085946ddea53119559 (patch) | |
tree | a65920ed289d8f8ea6c70df6da8e09463f88e2c4 /lib/common_test/src | |
parent | b26f1ce4ba088efa7538122680f828b3f92f57d8 (diff) | |
download | otp-1bf4656b1f7802af453f46085946ddea53119559.tar.gz otp-1bf4656b1f7802af453f46085946ddea53119559.tar.bz2 otp-1bf4656b1f7802af453f46085946ddea53119559.zip |
[common_test] Don't allow named (required) connection to be opened twice
Earlier, it was possible to open connection (ct_gen_conn) with the
same (required) name twice, which could give unexpected results. Such
attempts will now return {error,{connection_exists,OtherClient}}.
Diffstat (limited to 'lib/common_test/src')
-rw-r--r-- | lib/common_test/src/ct_gen_conn.erl | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/lib/common_test/src/ct_gen_conn.erl b/lib/common_test/src/ct_gen_conn.erl index 6b183110c6..72937e747c 100644 --- a/lib/common_test/src/ct_gen_conn.erl +++ b/lib/common_test/src/ct_gen_conn.erl @@ -204,16 +204,13 @@ do_start(Address,InitData,CallbackMod,Opts0) -> Opts = check_opts(Opts0,#gen_opts{callback=CallbackMod, address=Address, init_data=InitData}), - case Opts#gen_opts.use_existing of - true -> - case ct_util:does_connection_exist(Opts#gen_opts.name, - Address,CallbackMod) of - {ok,Pid} -> - log("ct_gen_conn:start","Using existing connection!\n",[]), - {ok,Pid}; - false -> - do_start(Opts) - end; + case ct_util:does_connection_exist(Opts#gen_opts.name, + Address,CallbackMod) of + {ok,Pid} when Opts#gen_opts.use_existing -> + log("ct_gen_conn:start","Using existing connection!\n",[]), + {ok,Pid}; + {ok,Pid} when not Opts#gen_opts.use_existing -> + {error,{connection_exists,Pid}}; false -> do_start(Opts) end. |