Drop the closed input that rtss_decide.h had and the worker never set.

The review found RtssIn.closed and its RTSS_WHY_CLOSED rule unused in the game: rtss_limit.c worker builds a poll's
view with the want alone, after it has skipped the poll under the lock once rtss_limit_restore ran, so the pure check's
closed case pinned a rule the worker never reaches. The field, the rule and the reason go; rtss_decide's comment says
that no poll decides after the exit and where that is done. The worker's skip stays as it was, and
tests/rtss_worker_check.c's restore_* scenarios (restore_inflight among them) keep covering it. The pure check's
closed_and_library becomes unset_and_library.

No decision changes: rtss_limit_check passes 27 of 27, check_content passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
chrg6
2026-11-13 17:52:46 -05:00
parent 55e03cf792
commit 130fa90590
2 changed files with 14 additions and 20 deletions

View File

@@ -82,7 +82,6 @@ enum {
RTSS_WHY_REFUSED, // RTSS refused this limit
RTSS_WHY_NEWER, // the want changed while the poll ran: nothing decided, the next poll takes the new one
RTSS_WHY_UNSET, // no want yet
RTSS_WHY_CLOSED, // the exit put the profile back (rtss_limit_restore)
};
// What the worker keeps between polls.
@@ -99,7 +98,6 @@ typedef struct {
typedef struct {
int64_t want; // the want the poll read
int current; // the want is still that one when the poll decides
int closed; // rtss_limit_restore ran
int hooks; // RTSS's hooks library: 1 loaded, 0 failed to load, -1 not tried (rtss_wants_hooks)
RtssApp app;
} RtssIn;
@@ -118,15 +116,15 @@ static inline int rtss_wants_hooks(const RtssState *s, const RtssIn *in) {
return in->want >= 0 && !s->fail && in->app.running;
}
// The decision of one poll, in this order: a closed run or no want does nothing; a kept-out want puts back what this
// run wrote (once the hooks are loaded); a failure lasts the run; RTSS not running leaves the profile for its return; a
// library that did not load fails the run; a refused limit stays with the game; a new limit goes into the profile at
// once, and RTSS holds it as soon as it lists the game. On an unchanged limit RTSS's own frame count is checked: more
// than RTSS_CHECK_SLACK times the limit for RTSS_CHECK_POLLS polls in a row puts the profile back for the run.
// The decision of one poll, in this order: no want does nothing; a kept-out want puts back what this run wrote (once
// the hooks are loaded); a failure lasts the run; RTSS not running leaves the profile for its return; a library that
// did not load fails the run; a refused limit stays with the game; a new limit goes into the profile at once, and RTSS
// holds it as soon as it lists the game. On an unchanged limit RTSS's own frame count is checked: more than
// RTSS_CHECK_SLACK times the limit for RTSS_CHECK_POLLS polls in a row puts the profile back for the run. After the
// exit put the profile back (rtss_limit_restore) no poll decides: rtss_limit.c worker skips it under the lock.
static inline RtssOut rtss_decide(RtssState *s, const RtssIn *in) {
int64_t w = in->want;
RtssOut o = {RTSS_DO_NOTHING, w, 0, RTSS_WHY_NOT_LISTED, 0};
if (in->closed) return o.why = RTSS_WHY_CLOSED, o;
if (w == RTSS_UNSET) return o.why = RTSS_WHY_UNSET, o;
if (w < 0) {
if (in->hooks == 1 && s->changed) o.act = RTSS_DO_PUT_BACK;

View File

@@ -160,15 +160,15 @@ static void run_init(Run *r) {
r->running = r->listed = 1, r->t0 = 1000, r->t1 = 2000, r->frames = 60;
}
// One poll for want, as rtss_limit.c worker makes it: the hooks library loads on the first poll that wants it and stays.
static RtssOut step_ex(Run *r, int64_t want, int current, int closed) {
RtssIn in = {.want = want, .current = current, .closed = closed};
static RtssOut step_ex(Run *r, int64_t want, int current) {
RtssIn in = {.want = want, .current = current};
in.app = (RtssApp){r->running, r->running && r->listed, r->t0, r->t1, r->frames};
if (r->st.loaded) in.hooks = 1;
else if (rtss_wants_hooks(&r->s, &in)) in.hooks = r->st.no_library ? 0 : (r->st.loaded = 1);
else in.hooks = -1;
return rtss_poll(&r->s, &in, &r->ops);
}
static RtssOut step(Run *r, int64_t want) { return step_ex(r, want, 1, 0); }
static RtssOut step(Run *r, int64_t want) { return step_ex(r, want, 1); }
// RTSS's injection delay: it runs but has not hooked the game for 30 polls. The limit goes into the profile at the
// first poll, and RTSS holds the game once it lists it, with no second write.
@@ -289,7 +289,7 @@ static void frame_count(void) {
r.frames = 144;
step(&r, 60000);
step(&r, 60000);
o = step_ex(&r, 60000, 0, 0);
o = step_ex(&r, 60000, 0);
CHECK(o.why == RTSS_WHY_NEWER && !o.holds && o.act == RTSS_DO_NOTHING && r.s.over == 1, "a newer want: no count");
}
@@ -337,17 +337,13 @@ static void movie(void) {
CHECK(o.act == RTSS_DO_APPLY && o.holds && r.st.applies == 3, "144 written again at its end");
}
// No want yet, and a closed run: nothing at all. The hooks library that does not load fails the run.
static void closed_and_library(void) {
// No want yet: nothing at all. The hooks library that does not load fails the run. (A run whose exit put the profile
// back makes no decision: rtss_limit.c worker skips the poll, which tests/rtss_worker_check.c's restore_* check.)
static void unset_and_library(void) {
Run r;
run_init(&r);
RtssOut o = step(&r, RTSS_UNSET);
CHECK(o.why == RTSS_WHY_UNSET && o.act == RTSS_DO_NOTHING && !r.st.loaded, "no want");
step(&r, 60000);
o = step_ex(&r, 144000, 1, 1);
CHECK(o.why == RTSS_WHY_CLOSED && o.act == RTSS_DO_NOTHING && r.st.holds == 60000, "closed: nothing written");
o = step_ex(&r, RTSS_OUT_FRAMEGEN, 1, 1);
CHECK(o.act == RTSS_DO_NOTHING && !r.st.put_backs, "closed: nothing put back");
run_init(&r);
r.st.no_library = 1;
o = step(&r, 60000);
@@ -396,7 +392,7 @@ int main(void) {
kept_out();
churn();
movie();
closed_and_library();
unset_and_library();
two();
printf("rtss_limit_check: %s\n", fails ? "FAIL" : "ok");
return fails != 0;