rproxy: one small type for waiting for the reports #433

Open
opened 2026-11-19 17:12:42 +01:00 by clawbot · 1 comment
Collaborator

From the architecture review, "Inside rproxy", under "Waiting for reports is three fields on handler": #283 (comment). Approved for building: #283 (comment). The code was read at 809d266 on next. Line numbers are that commit's.

What is there

  • handler in internal/rproxy/rproxy.go holds three fields for the reports being sent: reports sync.WaitGroup, reportsMu and reportsStopped (lines 140 to 142).
  • sendReport in internal/rproxy/waf.go:256 locks, tests the flag and starts the goroutine.
  • Server.WaitForReports in rproxy.go:115 reaches into s.h to lock, set the flag and wait.

Why it matters

One invariant, that no report starts once waiting has begun, is held by two functions in two files on two types.

What changes

A small private type with two methods: one starts a report unless stopped, one stops and waits. About twenty lines, with the invariant in one place. handler holds one field of it.

Before (rproxy.go):

func (s *Server) WaitForReports() {
	s.h.reportsMu.Lock()
	s.h.reportsStopped = true
	s.h.reportsMu.Unlock()

	s.h.reports.Wait()
}

After (the names are placeholders):

func (s *Server) WaitForReports() {
	s.h.reports.stopAndWait()
}

What stays

  • Server.WaitForReports keeps its name and what it promises: internal/sww calls it as rproxy's last step.
  • A report still goes on a goroutine of its own, after the request's context has ended, and one that comes after the wait began is dropped.

Done when

  • the three fields are one field of the new type, and only that type's methods touch the lock and the flag;
  • behaviour is unchanged: every existing test passes with no assertion changed;
  • make check passes;
  • the PR body lists the new type's name and its methods'. Each says what the thing is to a reader of that one file, the standard of the symbol names audit (#213).

Model: fable-5-2

From the architecture review, "Inside `rproxy`", under "Waiting for reports is three fields on `handler`": https://git.eeqj.de/sneak/smallwebwaf/issues/283#issuecomment-173849. Approved for building: https://git.eeqj.de/sneak/smallwebwaf/issues/283#issuecomment-183550. The code was read at `809d266` on `next`. Line numbers are that commit's. ### What is there - `handler` in `internal/rproxy/rproxy.go` holds three fields for the reports being sent: `reports sync.WaitGroup`, `reportsMu` and `reportsStopped` (lines 140 to 142). - `sendReport` in `internal/rproxy/waf.go:256` locks, tests the flag and starts the goroutine. - `Server.WaitForReports` in `rproxy.go:115` reaches into `s.h` to lock, set the flag and wait. ### Why it matters One invariant, that no report starts once waiting has begun, is held by two functions in two files on two types. ### What changes A small private type with two methods: one starts a report unless stopped, one stops and waits. About twenty lines, with the invariant in one place. `handler` holds one field of it. Before (`rproxy.go`): ```go func (s *Server) WaitForReports() { s.h.reportsMu.Lock() s.h.reportsStopped = true s.h.reportsMu.Unlock() s.h.reports.Wait() } ``` After (the names are placeholders): ```go func (s *Server) WaitForReports() { s.h.reports.stopAndWait() } ``` ### What stays - `Server.WaitForReports` keeps its name and what it promises: `internal/sww` calls it as `rproxy`'s last step. - A report still goes on a goroutine of its own, after the request's context has ended, and one that comes after the wait began is dropped. ### Done when - the three fields are one field of the new type, and only that type's methods touch the lock and the flag; - behaviour is unchanged: every existing test passes with no assertion changed; - `make check` passes; - the PR body lists the new type's name and its methods'. Each says what the thing is to a reader of that one file, the standard of the symbol names audit (https://git.eeqj.de/sneak/smallwebwaf/issues/213). Model: fable-5-2
clawbot self-assigned this 2026-11-19 17:12:42 +01:00
Author
Collaborator

Built in #453, branch issue-433-report-goroutines: reportGoroutines in internal/rproxy/waf.go replaces the three fields on handler.

Disclosure: one make check run failed in an untouched internal/waf test that timed out under host load; it is filed as #454.

Model: opus-5-5

Built in https://git.eeqj.de/sneak/smallwebwaf/pulls/453, branch `issue-433-report-goroutines`: `reportGoroutines` in `internal/rproxy/waf.go` replaces the three fields on `handler`. Disclosure: one `make check` run failed in an untouched `internal/waf` test that timed out under host load; it is filed as https://git.eeqj.de/sneak/smallwebwaf/issues/454. Model: opus-5-5
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/smallwebwaf#433