Skip to content

Commit 9741682

Browse files
committed
Include mod loaded from other path in conflict_unload
Update *Conflict Unload* mechanism to also include module loaded from another modulepath than the one specified for a requirement to load. As a result, such module loaded from another path will be unloaded to be replaced by the module from the selected modulepath.
1 parent 33ad74e commit 9741682

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

tcl/modfind.tcl.in

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,7 +1629,7 @@ proc getLoadedConflict {mod} {
16291629
}
16301630
}
16311631

1632-
proc getModuleLoadedConflict {mod} {
1632+
proc getModuleLoadedConflict {mod {modulepath_list {}}} {
16331633
set mod_con_list {}
16341634
defineModEqProc [isIcase] [getConf extended_default] 1
16351635
# get module short name if loaded by its full pathname
@@ -1667,7 +1667,8 @@ proc getModuleLoadedConflict {mod} {
16671667
}
16681668
}
16691669

1670-
if {[isOtherVariantOfModuleLoaded $mod]} {
1670+
if {[isOtherVariantOfModuleLoaded $mod] || ([isModuleLoaded $mod] &&\
1671+
![isLoadedMatchSpecificPath $mod $modulepath_list 0])} {
16711672
lappend mod_con_list [getModuleNameAndVersFromVersSpec $mod]
16721673
}
16731674

tcl/subcmd.tcl.in

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,7 +1170,11 @@ proc cmdModuleLoad {context uasked tryload loadany tag_list modulepath_list\
11701170
# constrained list
11711171
if {![isLoadedMatchSpecificPath $modname $modulepath_list [expr\
11721172
{!$isloaded}]]} {
1173-
knerror [getModFromDiffPathIsLoadedMsg]
1173+
# no error if ConUn mechanism handles unload of this module
1174+
if {![getConf auto_handling] || ![getConf conflict_unload] ||\
1175+
$isloading} {
1176+
knerror [getModFromDiffPathIsLoadedMsg]
1177+
}
11741178
# stop if same mod is loaded but with a different set of variants
11751179
} elseif {[isOtherVariantOfModuleLoaded $modnamevr] ||\
11761180
[isOtherVariantOfModuleLoading $modnamevr]} {
@@ -1216,7 +1220,8 @@ proc cmdModuleLoad {context uasked tryload loadany tag_list modulepath_list\
12161220
if {[getConf auto_handling]} {
12171221
if {[getConf conflict_unload]} {
12181222
# get loaded conflicting modules and unload them (ConUn)
1219-
set conun_mod_list [getModuleLoadedConflict $modnamevr]
1223+
set conun_mod_list [getModuleLoadedConflict $modnamevr\
1224+
$modulepath_list]
12201225
reportDebug "conun mod list is '$conun_mod_list'"
12211226
if {[llength $conun_mod_list]} {
12221227
foreach conun_mod [lreverse $conun_mod_list] {

0 commit comments

Comments
 (0)