Skip to content

Commit d826c11

Browse files
committed
Check stickiness prior processing dependent unload
Move stickiness check when unloading a module prior processing any automated module handling mechanism. Stickiness check procedure is renamed failOrSkipUnloadIfSticky and moved from interp.tcl to modeval.tcl file. Fixes #536
1 parent f7994a4 commit d826c11

File tree

4 files changed

+38
-50
lines changed

4 files changed

+38
-50
lines changed

NEWS.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ Modules 5.5.0 (not yet released)
188188
when trying to reload Dependent Reload modules that conflict with other
189189
loaded modules. This error may be by-passed with :option:`--force`
190190
command-line option.
191+
* Move stickiness check when unloading a module prior processing any automated
192+
module handling mechanism. (fix issue #536)
191193

192194
.. warning:: Variant names are now fully checked instead of just verifying
193195
their first character. Only characters within the ``A-Za-z0-9_-`` range are

tcl/interp.tcl.in

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -184,50 +184,6 @@ x-resource {x-resource x-resource reportCmd nop nop
184184
}
185185
}
186186

187-
# Fail unload attempt if module is sticky, unless if forced or reloading
188-
# Also fail unload if mod is super-sticky even if forced, unless reloading
189-
proc skipUnloadIfSticky {mode modname modfile} {
190-
if {$mode ne {unload}} {
191-
return 0
192-
}
193-
194-
# when loaded, tags applies to mod name and version (not with variant)
195-
set is_supersticky_not_reloading [expr {[isModuleTagged $modname\
196-
super-sticky 1 $modfile] && [currentState reloading_supersticky] ne\
197-
$modname}]
198-
set is_sticky_not_reloading [expr {[isModuleTagged $modname sticky 1\
199-
$modfile] && [currentState reloading_sticky] ne $modname &&\
200-
[currentState unloading_sticky] ne $modname}]
201-
set sticky_purge [expr {[getState commandname] eq {purge} ? [getConf\
202-
sticky_purge] : {}}]
203-
204-
if {!$is_supersticky_not_reloading && $is_sticky_not_reloading &&\
205-
[getState force]} {
206-
reportWarning [getStickyForcedUnloadMsg]
207-
} elseif {$is_supersticky_not_reloading || $is_sticky_not_reloading} {
208-
# restore changed states prior raising error
209-
lpopState debug_msg_prefix
210-
lpopState modulepath
211-
lpopState specifiedname
212-
lpopState modulename
213-
lpopState modulenamevr
214-
lpopState modulefile
215-
216-
set msg [getStickyUnloadMsg [expr {$is_supersticky_not_reloading ?\
217-
{super-sticky} : {sticky}}]]
218-
# no message if sticky_purge is set to silent
219-
switch -- $sticky_purge {
220-
error - {} {knerror $msg}
221-
warning {reportWarning $msg}
222-
}
223-
224-
# skip unload without raised error
225-
return 1
226-
}
227-
228-
return 0
229-
}
230-
231187
proc execute-modulefile {modfile modname modnamevrvar modspec requested\
232188
{up_namevr 1} {fetch_tags 1} {modpath {}}} {
233189
# link to modnamevr variable name from calling ctx if content update asked
@@ -267,12 +223,6 @@ proc execute-modulefile {modfile modname modnamevrvar modspec requested\
267223
set nearlyforbidwarn 1
268224
}
269225

270-
# fail unload when sticky
271-
if {[skipUnloadIfSticky $mode $modname $modfile]} {
272-
# skip end of unload upper level process when no error raised
273-
return -code continue 0
274-
}
275-
276226
if {![info exists ::g_modfileUntrackVars]} {
277227
# list variable that should not be tracked for saving
278228
array set ::g_modfileUntrackVars [list ModulesCurrentModulefile 1 env 1]

tcl/modeval.tcl

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,6 +1138,38 @@ proc reloadDepReModules {} {
11381138
reloadModuleListLoadPhase $depre_list $err_msg_tpl depre
11391139
}
11401140

1141+
# Fail unload attempt if module is sticky, unless if forced or reloading
1142+
# Also fail unload if mod is super-sticky even if forced, unless reloading
1143+
proc failOrSkipUnloadIfSticky {modname modfile} {
1144+
# when loaded, tags applies to mod name and version (not with variant)
1145+
set is_supersticky_not_reloading [expr {[isModuleTagged $modname\
1146+
super-sticky 1 $modfile] && [currentState reloading_supersticky] ne\
1147+
$modname}]
1148+
set is_sticky_not_reloading [expr {[isModuleTagged $modname sticky 1\
1149+
$modfile] && [currentState reloading_sticky] ne $modname &&\
1150+
[currentState unloading_sticky] ne $modname}]
1151+
set sticky_purge [expr {[getState commandname] eq {purge} ? [getConf\
1152+
sticky_purge] : {}}]
1153+
1154+
if {!$is_supersticky_not_reloading && $is_sticky_not_reloading &&\
1155+
[getState force]} {
1156+
reportWarning [getStickyForcedUnloadMsg]
1157+
} elseif {$is_supersticky_not_reloading || $is_sticky_not_reloading} {
1158+
set msg [getStickyUnloadMsg [expr {$is_supersticky_not_reloading ?\
1159+
{super-sticky} : {sticky}}]]
1160+
# no message if sticky_purge is set to silent
1161+
switch -- $sticky_purge {
1162+
error - {} {knerror $msg}
1163+
warning {reportWarning $msg}
1164+
}
1165+
1166+
# skip unload without raising error
1167+
return 1
1168+
}
1169+
1170+
return 0
1171+
}
1172+
11411173
# ;;; Local Variables: ***
11421174
# ;;; mode:tcl ***
11431175
# ;;; End: ***

tcl/subcmd.tcl.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1546,6 +1546,10 @@ proc cmdModuleUnload {context match auto force onlyureq args} {
15461546

15471547
pushSettings
15481548
if {[set errCode [catch {
1549+
if {[failOrSkipUnloadIfSticky $modname $modfile]} {
1550+
continue
1551+
}
1552+
15491553
# stop unless forced or auto handling mode enabled if unloading
15501554
# module violates a registered prereq
15511555
set prereq_list [getDependentLoadedModuleList [list $modname]]

0 commit comments

Comments
 (0)