mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-12-05 01:52:46 +00:00
a156188b3e
* update dependencies, bump Go version to 1.19 * bump test image Go version * update golangci-lint * update gotosocial-drone-build * sign * linting, go fmt * update swagger docs * update swagger docs * whitespace * update contributing.md * fuckin whoopsie doopsie * linterino, linteroni * fix followrequest test not starting processor * fix other api/client tests not starting processor * fix remaining tests where processor not started * bump go-runners version * don't check last-webfingered-at, processor may have updated this * update swagger command * update bun to latest version * fix embed to work the same as before with new bun Signed-off-by: kim <grufwub@gmail.com> Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
53 lines
1.1 KiB
Go
53 lines
1.1 KiB
Go
// Copyright 2014 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// Flow control
|
|
|
|
package http2
|
|
|
|
// flow is the flow control window's size.
|
|
type flow struct {
|
|
_ incomparable
|
|
|
|
// n is the number of DATA bytes we're allowed to send.
|
|
// A flow is kept both on a conn and a per-stream.
|
|
n int32
|
|
|
|
// conn points to the shared connection-level flow that is
|
|
// shared by all streams on that conn. It is nil for the flow
|
|
// that's on the conn directly.
|
|
conn *flow
|
|
}
|
|
|
|
func (f *flow) setConnFlow(cf *flow) { f.conn = cf }
|
|
|
|
func (f *flow) available() int32 {
|
|
n := f.n
|
|
if f.conn != nil && f.conn.n < n {
|
|
n = f.conn.n
|
|
}
|
|
return n
|
|
}
|
|
|
|
func (f *flow) take(n int32) {
|
|
if n > f.available() {
|
|
panic("internal error: took too much")
|
|
}
|
|
f.n -= n
|
|
if f.conn != nil {
|
|
f.conn.n -= n
|
|
}
|
|
}
|
|
|
|
// add adds n bytes (positive or negative) to the flow control window.
|
|
// It returns false if the sum would exceed 2^31-1.
|
|
func (f *flow) add(n int32) bool {
|
|
sum := f.n + n
|
|
if (sum > n) == (f.n > 0) {
|
|
f.n = sum
|
|
return true
|
|
}
|
|
return false
|
|
}
|