Skip to content

Commit c24e948

Browse files
committed
Keep sticky requirement of super-sticky module on forced purge
On a forced purge, a sticky module required by a retained super-sticky module got a "forced unload" warning immediately followed by the error reporting its unload is skipped as a super-sticky requirement. The module stayed loaded, but the sticky check reported the forced unload before the requirement check retained the module. Check whether a module is required by a retained sticky module as part of the sticky check itself, prior reporting the forced unload of a sticky module. Rely on the existing sticky module test to determine if a sticky dependent is retained rather than duplicating this rule. Assisted-by: Claude:claude-fable-5-1 Signed-off-by: Xavier Delaruelle <xavier.delaruelle@cea.fr>
1 parent b48ed58 commit c24e948

3 files changed

Lines changed: 50 additions & 10 deletions

File tree

‎tcl/modeval.tcl‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,7 @@ proc getModuleStickyDependentTag {mod} {
965965
if {[isModuleTagged $dep_mod super-sticky 1]} {
966966
set sticky_tag super-sticky
967967
break
968-
} elseif {![getState force] && [isModuleTagged $dep_mod sticky 1]} {
968+
} elseif {[isModuleSticky $dep_mod]} {
969969
set sticky_tag sticky
970970
}
971971
}
@@ -1166,10 +1166,8 @@ proc failOrSkipUnloadIfSticky {modname modfile} {
11661166
set sticky_purge [expr {[getState commandname] eq {purge} ? [getConf\
11671167
sticky_purge] : {}}]
11681168

1169-
if {!$is_supersticky_not_reloading && $is_sticky_not_reloading &&\
1170-
[getState force]} {
1171-
reportWarning [getStickyForcedUnloadMsg]
1172-
} elseif {$is_supersticky_not_reloading || $is_sticky_not_reloading} {
1169+
if {$is_supersticky_not_reloading || ($is_sticky_not_reloading &&\
1170+
![getState force])} {
11731171
set msg [getStickyUnloadMsg [expr {$is_supersticky_not_reloading ?\
11741172
{super-sticky} : {sticky}}]]
11751173
# no message if sticky_purge is set to silent
@@ -1182,6 +1180,17 @@ proc failOrSkipUnloadIfSticky {modname modfile} {
11821180
return 1
11831181
}
11841182

1183+
# on purge, module required by a retained sticky module is kept loaded,
1184+
# which prevails over the forced unload of a sticky module
1185+
if {$sticky_purge ne {} && [failOrSkipUnloadIfRequiredBySticky\
1186+
$modname]} {
1187+
return 1
1188+
}
1189+
1190+
if {$is_sticky_not_reloading && [getState force]} {
1191+
reportWarning [getStickyForcedUnloadMsg]
1192+
}
1193+
11851194
return 0
11861195
}
11871196

‎tcl/subcmd.tcl.in‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,11 +1577,6 @@ proc cmdModuleUnload {context match auto force onlyureq args} {
15771577
set prereq_list [getDependentLoadedModuleList [list $modname]]
15781578
set prereq_loaded_list [getDependentLoadedModuleList [list $modname]\
15791579
1 1 0 0]
1580-
if {[llength $prereq_loaded_list] &&\
1581-
[getState commandname] eq {purge} &&\
1582-
[failOrSkipUnloadIfRequiredBySticky $modname]} {
1583-
continue
1584-
}
15851580
if {[llength $prereq_loaded_list] && (![getConf auto_handling] ||\
15861581
!$auto)} {
15871582
# force mode should not affect if we only look for mods w/o dep

‎testsuite/modules.50-cmds/464-sticky_purge.exp‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,42 @@ foreach {tag2 tag3 msg2 msg3} [list sticky super-sticky\
218218
unsetenv_var __MODULES_LMPREREQ
219219

220220

221+
# sticky requirement of super-sticky module is kept on forced purge
222+
setenv_var TESTSUITE_STICKY purge_req
223+
setenv_loaded_module [list sticky1/1.0 sticky2/1.0] [list\
224+
$mp/sticky1/1.0 $mp/sticky2/1.0]
225+
setenv_var __MODULES_LMTAG sticky1/1.0&sticky:sticky2/1.0&super-sticky
226+
setenv_var __MODULES_LMPREREQ sticky2/1.0&sticky1/1.0|sticky1/2.0
227+
foreach {report_mode msg reqmsg stickymsg} [list error\
228+
$err_superstickyunload $err_superstickyrequnload $err_stickyunload\
229+
warning $warn_superstickyunload $warn_superstickyrequnload\
230+
$warn_stickyunload silent {} {} {}] {
231+
setenv_var MODULES_STICKY_PURGE $report_mode
232+
set ans [list]
233+
if {$report_mode eq {error}} {
234+
lappend ans [list ERR]
235+
}
236+
set tserr {}
237+
if {$report_mode ne {silent}} {
238+
set tserr [msg_unload {sticky2/1.0 <sS>} $msg]\n\n[msg_unload\
239+
{sticky1/1.0 <S>} $stickymsg]
240+
}
241+
testouterr_cmd sh {purge} $ans $tserr
242+
243+
# requirement is retained, so no forced unload warning
244+
set tserr {}
245+
if {$report_mode ne {silent}} {
246+
set tserr [msg_unload {sticky2/1.0 <sS>} $msg]\n\n[msg_unload\
247+
{sticky1/1.0 <S>} $reqmsg]
248+
}
249+
testouterr_cmd sh {purge -f} $ans $tserr
250+
}
251+
252+
253+
unsetenv_var __MODULES_LMPREREQ
254+
unsetenv_var TESTSUITE_STICKY
255+
256+
221257
# module both sticky and super-sticky
222258
setenv_var TESTSUITE_FPMOD_TAG sticky2
223259
setenv_loaded_module [list foo/1.0 tag/1.0] [list $mp/foo/1.0 $mp/tag/1.0]

0 commit comments

Comments
 (0)