Repository navigation
Server: timeouts for the status page server - #162
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The status page server (
-http) was started as a barehttp.Server, with no timeouts. A connection that was slow to send its request, or stopped reading its answer, or sat idle, stayed open for as long as the client kept it, holding a goroutine and a file descriptor. The admin server already sets timeouts; the status page did not.Change
server/api.go:newStatusServer(addr, handler)builds the-httpserver with a 5 second header timeout, a 10 second read timeout, a 10 second write timeout and a 30 second idle timeout (named constants). The status answers are small, so these are far above a normal request.server/main.go:-httpuses it.server/status_timeouts_test.go: the constructor sets the four timeouts to the constants and each is between 0 and a minute; a request header that is never finished and a connection that is idle after an answer are closed by the server (with short timeouts in the test), while a normal request is answered 200;main.gobuilds the status server only through the constructor.site/index.htmlandsite/data.jsonregenerated (they carry the changelog).Tests
go vet,gofmtandgo test ./serverpass;python3 tools/repo_check.py,python3 tools/site.py --check,python3 tools/features.py --checkandscripts/check-deploy.shpass.main.goto a barehttp.Server, and removing the idle timeout (with its override in the test) each fail a test. Againstmain, the new tests do not build, becausenewStatusServerdoes not exist there.Not in this change
No new flag: the limits are fixed, as they are for the admin server. No header size limit, no change to what the pages answer, and the work the handlers do per request is unchanged.
Overlap
None open. Based on main at 7fdd762; touches
CHANGELOG.md,server/api.go,server/main.go, the two generated site files and a new test file.Developed with AI agent assistance.