aboutsummaryrefslogtreecommitdiffstats
path: root/lib/sasl
diff options
context:
space:
mode:
authorSiri Hansen <[email protected]>2011-11-14 12:06:06 +0100
committerSiri Hansen <[email protected]>2011-11-17 16:59:09 +0100
commitcc7c2a74ee9074357f6ab0701be61e7bb57004ef (patch)
tree45de30bfc0d23656dec908736b1ffe4ff386e599 /lib/sasl
parent19fc8435cbc938f102ffcd0bcbabfc0371dcccb9 (diff)
downloadotp-cc7c2a74ee9074357f6ab0701be61e7bb57004ef.tar.gz
otp-cc7c2a74ee9074357f6ab0701be61e7bb57004ef.tar.bz2
otp-cc7c2a74ee9074357f6ab0701be61e7bb57004ef.zip
Fix bug in erts upgrade on windows
The service which represents the temporary release during erts upgrade on windows was never deleted. This has been corrected. The service is now renamed just after the emulator restart.
Diffstat (limited to 'lib/sasl')
-rw-r--r--lib/sasl/src/release_handler.erl74
-rw-r--r--lib/sasl/test/release_handler_SUITE.erl3
2 files changed, 52 insertions, 25 deletions
diff --git a/lib/sasl/src/release_handler.erl b/lib/sasl/src/release_handler.erl
index 87660db3e3..94a704e61f 100644
--- a/lib/sasl/src/release_handler.erl
+++ b/lib/sasl/src/release_handler.erl
@@ -1000,8 +1000,10 @@ do_install_release(#state{start_prg = StartPrg,
%% In case there has been an emulator upgrade,
%% remove the temporary release
NReleases =
- new_emulator_rm_tmp_release(LatestRelease#release.vsn,
- RelDir,Releases,Masters),
+ new_emulator_rm_tmp_release(
+ LatestRelease#release.vsn,
+ LatestRelease#release.erts_vsn,
+ Vsn,RelDir,Releases,Masters),
%% Then execute the relup script
mon_nodes(true),
@@ -1134,12 +1136,46 @@ replace_config(App,Config,AppConfig) ->
lists:keystore(App,1,Config,AppConfig).
%% Remove all files related to the temporary release
-new_emulator_rm_tmp_release(?tmp_vsn(_)=TmpVsn,RelDir,Releases,Masters) ->
+new_emulator_rm_tmp_release(?tmp_vsn(_)=TmpVsn,EVsn,NewVsn,
+ RelDir,Releases,Masters) ->
+ case os:type() of
+ {win32, nt} ->
+ rename_tmp_service(EVsn,TmpVsn,NewVsn);
+ _ ->
+ ok
+ end,
remove_dir(filename:join(RelDir,TmpVsn),Masters),
lists:keydelete(TmpVsn,#release.vsn,Releases);
-new_emulator_rm_tmp_release(_,_,Releases,_) ->
+new_emulator_rm_tmp_release(_,_,_,_,Releases,_) ->
Releases.
+%% Rename the tempoarary service (for erts ugprade) to the real ToVsn
+rename_tmp_service(EVsn,TmpVsn,NewVsn) ->
+ FromName = hd(string:tokens(atom_to_list(node()),"@")) ++ "_" ++ TmpVsn,
+ ToName = hd(string:tokens(atom_to_list(node()),"@")) ++ "_" ++ NewVsn,
+ case erlsrv:get_service(EVsn,ToName) of
+ {error, _Error} ->
+ ok;
+ _Data ->
+ erlsrv:remove_service(ToName)
+ end,
+ rename_service(EVsn,FromName,ToName).
+
+
+%% Rename a service and check that it succeeded
+rename_service(EVsn,FromName,ToName) ->
+ case erlsrv:rename_service(EVsn,FromName,ToName) of
+ {ok,_} ->
+ case erlsrv:get_service(EVsn,ToName) of
+ {error,Error1} ->
+ throw({error,Error1});
+ _Data2 ->
+ ok
+ end;
+ Error2 ->
+ throw({error,{service_rename_failed, Error2}})
+ end.
+
%%% This code chunk updates the services in one of two ways,
%%% Either the emulator is restarted, in which case the old service
@@ -1157,26 +1193,16 @@ do_make_services_permanent(PermanentVsn,Vsn, PermanentEVsn, EVsn) ->
%% rename.
case os:getenv("ERLSRV_SERVICE_NAME") == PermName of
true ->
- case erlsrv:rename_service(EVsn,PermName,Name) of
- {ok,_} ->
- case erlsrv:get_service(EVsn,Name) of
- {error,Error2} ->
- throw({error,Error2});
- _Data2 ->
- %% The interfaces for doing this are
- %% NOT published and may be subject to
- %% change. Do NOT do this anywhere else!
-
- os:putenv("ERLSRV_SERVICE_NAME", Name),
-
- %% Restart heart port program, this
- %% function is only to be used here.
- heart:cycle(),
- ok
- end;
- Error3 ->
- throw({error,{service_rename_failed, Error3}})
- end;
+ rename_service(EVsn,PermName,Name),
+ %% The interfaces for doing this are
+ %% NOT published and may be subject to
+ %% change. Do NOT do this anywhere else!
+
+ os:putenv("ERLSRV_SERVICE_NAME", Name),
+
+ %% Restart heart port program, this
+ %% function is only to be used here.
+ heart:cycle();
false ->
throw({error,service_name_missmatch})
end;
diff --git a/lib/sasl/test/release_handler_SUITE.erl b/lib/sasl/test/release_handler_SUITE.erl
index 620d5b2761..180592894e 100644
--- a/lib/sasl/test/release_handler_SUITE.erl
+++ b/lib/sasl/test/release_handler_SUITE.erl
@@ -382,7 +382,8 @@ upgrade_restart(Conf) when is_list(Conf) ->
{wait,TestNodeInit2a} ->
%% We catched the node too early - it was supposed to
%% restart twice, so let's wait for one more restart.
- wait_nodes_up([{TestNode,TestNodeInit2a}],"upgrade_restart_2a",[])
+ wait_nodes_up([{TestNode,TestNodeInit2a}],"upgrade_restart_2a",[]),
+ ok = rpc_inst(TestNode, upgrade_restart_2a, [])
end,
TestNodeInit2 = rpc:call(TestNode,erlang,whereis,[init]),
stop_cover(TestNode),