]> source.dussan.org Git - gitea.git/commit
Set self-adjusting deadline for connection writing (#16068) (#16123)
authorzeripath <art27@cantab.net>
Thu, 10 Jun 2021 21:26:32 +0000 (22:26 +0100)
committerGitHub <noreply@github.com>
Thu, 10 Jun 2021 21:26:32 +0000 (00:26 +0300)
commitf034804e5d98f70d087c2d577a3fb6f0091e742f
tree3185d1317db22760c1b8a9ee427f65e70536da6d
parentc1887bfc9b8a093632eed23f07e8738f998a02a4
Set self-adjusting deadline for connection writing (#16068) (#16123)

In #16055 it appears that the simple 5s deadline doesn't work for large
file writes. Now we can't - or at least shouldn't just set no deadline
as go will happily let these connections block indefinitely. However,
what seems reasonable is to set some minimum rate we expect for writing.

This PR suggests the following algorithm:

* Every write has a minimum timeout of 5s (adjustable at compile time.)
* If there has been a previous write - then consider its previous
deadline, add half of the minimum timeout + 2s per kb about to written.
* If that new deadline is after the minimum timeout use that.

Fix #16055

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
custom/conf/app.example.ini
docs/content/doc/advanced/config-cheat-sheet.en-us.md
modules/graceful/server.go
modules/setting/setting.go
modules/ssh/ssh_graceful.go