rproxy: the two time limits get a type and a file of their own (closes #432) #478

Merged
clawbot merged 1 commits from issue-432-time-limits-type into next 2026-11-20 00:28:55 +01:00
Collaborator

Closes #432.

The mutex, the two timers and the end of the request move from request into a type of their own. request holds one field of it, limits. Behaviour is unchanged.

New names:

  • internal/rproxy/timelimits.go: the file of the type.
  • timeLimits: one request's SWW_RPROXY_MAX_REQUEST_TIME_MS and SWW_RPROXY_MAX_RESPONSE_TIME_MS.
    • waitingForVisitor: field; reports whether a read of the visitor's body is waiting for the visitor.
    • endVisitorRead: field; ends that read at once.
    • stopped: field; once set, neither limit acts.
    • requestDeadline: when the visitor must have sent its whole request.
    • startRequestTimer: starts the request limit.
    • requestTimedOut: the request limit ran out; refuses 408 or 504.
    • wroteRequest: the app has the whole request; the response limit starts.
    • startResponseTimer: starts the response limit from the end of the request.
    • responseTimedOut: the response limit ran out; refuses 504.
    • endRequest: notes the end of the request once, and returns it.
    • stop: stops both limits for good.
  • internal/rproxy/timelimits_internal_test.go: tests of the type alone, in a testing/synctest bubble.

What the diff does not show:

  • responseReceived on request is gone: it only stopped the timers, so responseBody now gets rq.limits.stop.
  • endVisitorRead is still called with the lock held, so it cannot reach the connection after the request is handled.
  • modifyResponse, prepareOwnAnswer and setResponseDeadline still read SWW_RPROXY_MAX_RESPONSE_TIME_MS from the config; they work on the connection and stay on request.

Model: opus-5-5

Closes https://git.eeqj.de/sneak/smallwebwaf/issues/432. The mutex, the two timers and the end of the request move from `request` into a type of their own. `request` holds one field of it, `limits`. Behaviour is unchanged. New names: - `internal/rproxy/timelimits.go`: the file of the type. - `timeLimits`: one request's `SWW_RPROXY_MAX_REQUEST_TIME_MS` and `SWW_RPROXY_MAX_RESPONSE_TIME_MS`. - `waitingForVisitor`: field; reports whether a read of the visitor's body is waiting for the visitor. - `endVisitorRead`: field; ends that read at once. - `stopped`: field; once set, neither limit acts. - `requestDeadline`: when the visitor must have sent its whole request. - `startRequestTimer`: starts the request limit. - `requestTimedOut`: the request limit ran out; refuses 408 or 504. - `wroteRequest`: the app has the whole request; the response limit starts. - `startResponseTimer`: starts the response limit from the end of the request. - `responseTimedOut`: the response limit ran out; refuses 504. - `endRequest`: notes the end of the request once, and returns it. - `stop`: stops both limits for good. - `internal/rproxy/timelimits_internal_test.go`: tests of the type alone, in a `testing/synctest` bubble. What the diff does not show: - `responseReceived` on `request` is gone: it only stopped the timers, so `responseBody` now gets `rq.limits.stop`. - `endVisitorRead` is still called with the lock held, so it cannot reach the connection after the request is handled. - `modifyResponse`, `prepareOwnAnswer` and `setResponseDeadline` still read `SWW_RPROXY_MAX_RESPONSE_TIME_MS` from the config; they work on the connection and stay on `request`. Model: opus-5-5
clawbot added the needs-review label 2026-11-20 00:02:31 +01:00
clawbot added 1 commit 2026-11-20 00:02:31 +01:00
timeLimits in internal/rproxy/timelimits.go owns the mutex, the two
timers and the end of the request; request holds one field of it. It
is given refuse, whether the visitor's body is being waited on, and a
function that ends that read. Tests of the type alone run in a
synctest bubble.

Model: opus-5-5
clawbot self-assigned this 2026-11-20 00:02:33 +01:00
Author
Collaborator

Verdict: PASS
Head: bb3c8f9351

The two time limits move unchanged into timeLimits in internal/rproxy/timelimits.go, with synctest tests of the type alone, which meets every point of the definition of done in #432.

Model: opus-5-5

Verdict: PASS Head: bb3c8f9351607bf1bd2af8d62588eeb0f520feff The two time limits move unchanged into `timeLimits` in `internal/rproxy/timelimits.go`, with `synctest` tests of the type alone, which meets every point of the definition of done in https://git.eeqj.de/sneak/smallwebwaf/issues/432. Model: opus-5-5
clawbot merged commit abf6c8d517 into next 2026-11-20 00:28:55 +01:00
Sign in to join this conversation.