mirror of
https://github.com/pgsty/minio.git
synced 2026-11-25 08:39:19 +03:00
Merge pull request #358 from pgsty/codex/fix-gobwas-ws-6940
Signed-off-by: Feng Ruohang <rh@vonng.com>
This commit is contained in:
@@ -12037,33 +12037,6 @@ SOFTWARE.
|
|||||||
|
|
||||||
================================================================
|
================================================================
|
||||||
|
|
||||||
github.com/gobwas/pool
|
|
||||||
https://github.com/gobwas/pool
|
|
||||||
----------------------------------------------------------------
|
|
||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2017-2019 Sergey Kamardin <gobwas@gmail.com>
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
||||||
|
|
||||||
================================================================
|
|
||||||
|
|
||||||
github.com/gobwas/ws
|
github.com/gobwas/ws
|
||||||
https://github.com/gobwas/ws
|
https://github.com/gobwas/ws
|
||||||
----------------------------------------------------------------
|
----------------------------------------------------------------
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ require (
|
|||||||
github.com/go-ldap/ldap/v3 v3.4.15
|
github.com/go-ldap/ldap/v3 v3.4.15
|
||||||
github.com/go-openapi/loads v0.25.3
|
github.com/go-openapi/loads v0.25.3
|
||||||
github.com/go-sql-driver/mysql v1.10.1
|
github.com/go-sql-driver/mysql v1.10.1
|
||||||
github.com/gobwas/ws v1.4.0
|
github.com/gobwas/ws v1.5.0
|
||||||
github.com/golang-jwt/jwt/v4 v4.5.2
|
github.com/golang-jwt/jwt/v4 v4.5.2
|
||||||
github.com/gomodule/redigo v1.9.3
|
github.com/gomodule/redigo v1.9.3
|
||||||
github.com/google/uuid v1.6.0
|
github.com/google/uuid v1.6.0
|
||||||
@@ -191,7 +191,6 @@ require (
|
|||||||
github.com/go-openapi/validate v1.0.1 // indirect
|
github.com/go-openapi/validate v1.0.1 // indirect
|
||||||
github.com/go-viper/mapstructure/v2 v2.5.0 // indirect
|
github.com/go-viper/mapstructure/v2 v2.5.0 // indirect
|
||||||
github.com/gobwas/httphead v0.1.0 // indirect
|
github.com/gobwas/httphead v0.1.0 // indirect
|
||||||
github.com/gobwas/pool v0.2.1 // indirect
|
|
||||||
github.com/goccy/go-json v0.11.2 // indirect
|
github.com/goccy/go-json v0.11.2 // indirect
|
||||||
github.com/gogo/protobuf v1.3.2 // indirect
|
github.com/gogo/protobuf v1.3.2 // indirect
|
||||||
github.com/golang-jwt/jwt/v5 v5.3.1 // indirect
|
github.com/golang-jwt/jwt/v5 v5.3.1 // indirect
|
||||||
|
|||||||
@@ -247,11 +247,10 @@ github.com/go-viper/mapstructure/v2 v2.5.0 h1:vM5IJoUAy3d7zRSVtIwQgBj7BiWtMPfmPE
|
|||||||
github.com/go-viper/mapstructure/v2 v2.5.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
|
github.com/go-viper/mapstructure/v2 v2.5.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
|
||||||
github.com/gobwas/httphead v0.1.0 h1:exrUm0f4YX0L7EBwZHuCF4GDp8aJfVeBrlLQrs6NqWU=
|
github.com/gobwas/httphead v0.1.0 h1:exrUm0f4YX0L7EBwZHuCF4GDp8aJfVeBrlLQrs6NqWU=
|
||||||
github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM=
|
github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM=
|
||||||
github.com/gobwas/pool v0.2.1 h1:xfeeEhW7pwmX8nuLVlqbzVc7udMDrwetjEv+TZIz1og=
|
|
||||||
github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
|
github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
|
||||||
github.com/gobwas/ws v1.2.1/go.mod h1:hRKAFb8wOxFROYNsT1bqfWnhX+b5MFeJM9r2ZSwg/KY=
|
github.com/gobwas/ws v1.2.1/go.mod h1:hRKAFb8wOxFROYNsT1bqfWnhX+b5MFeJM9r2ZSwg/KY=
|
||||||
github.com/gobwas/ws v1.4.0 h1:CTaoG1tojrh4ucGPcoJFiAQUAsEWekEWvLy7GsVNqGs=
|
github.com/gobwas/ws v1.5.0 h1:jWzPex0GE9QidvBrBNddDmC5aZzvCXTg2qCZ/UA6nLg=
|
||||||
github.com/gobwas/ws v1.4.0/go.mod h1:G3gNqMNtPppf5XUz7O4shetPpcZ1VJ7zt18dlUeakrc=
|
github.com/gobwas/ws v1.5.0/go.mod h1:q9xc6wHP8xO4NsQjTN1y7E37A9+fV/Xz2LgNcyeRbyE=
|
||||||
github.com/goccy/go-json v0.11.2 h1:jdZv93Tt4ioR8yW1CoNsvSxrcZlCXAUU1aZXN7gpXUA=
|
github.com/goccy/go-json v0.11.2 h1:jdZv93Tt4ioR8yW1CoNsvSxrcZlCXAUU1aZXN7gpXUA=
|
||||||
github.com/goccy/go-json v0.11.2/go.mod h1:3NdmfEkZlB7YI5UFw/qdFKq8XN1aiWR0YyRPWZNQltY=
|
github.com/goccy/go-json v0.11.2/go.mod h1:3NdmfEkZlB7YI5UFw/qdFKq8XN1aiWR0YyRPWZNQltY=
|
||||||
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
||||||
|
|||||||
@@ -965,7 +965,6 @@ func (c *Connection) readStream(ctx context.Context, conn net.Conn, cancel conte
|
|||||||
OnIntermediate: controlHandler,
|
OnIntermediate: controlHandler,
|
||||||
}
|
}
|
||||||
readDataInto := func(dst []byte, s ws.State, want ws.OpCode) ([]byte, error) {
|
readDataInto := func(dst []byte, s ws.State, want ws.OpCode) ([]byte, error) {
|
||||||
dst = dst[:0]
|
|
||||||
for {
|
for {
|
||||||
hdr, err := wsReader.NextFrame()
|
hdr, err := wsReader.NextFrame()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -983,13 +982,11 @@ func (c *Connection) readStream(ctx context.Context, conn net.Conn, cancel conte
|
|||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if int64(cap(dst)) < hdr.Length+1 {
|
dst = frameReadBuffer(dst, hdr.Length)
|
||||||
dst = make([]byte, 0, hdr.Length+hdr.Length>>3)
|
|
||||||
}
|
|
||||||
if !hdr.Fin {
|
if !hdr.Fin {
|
||||||
hdr.Length = -1
|
hdr.Length = -1
|
||||||
}
|
}
|
||||||
return readAllInto(dst[:0], &wsReader, hdr.Length)
|
return readAllInto(dst, &wsReader, hdr.Length)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -122,6 +122,16 @@ var PutByteBuffer = func(b []byte) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// frameReadBuffer reserves at most one read buffer from the frame header.
|
||||||
|
// readAllInto grows it as the payload arrives.
|
||||||
|
func frameReadBuffer(b []byte, length int64) []byte {
|
||||||
|
initial := min(length, int64(readBufferSize))
|
||||||
|
if int64(cap(b)) >= initial {
|
||||||
|
return b[:0]
|
||||||
|
}
|
||||||
|
return make([]byte, 0, initial)
|
||||||
|
}
|
||||||
|
|
||||||
// readAllInto reads from r and appends to b until an error or EOF and returns the data it read.
|
// readAllInto reads from r and appends to b until an error or EOF and returns the data it read.
|
||||||
// A successful call returns err == nil, not err == EOF. Because readAllInto is
|
// A successful call returns err == nil, not err == EOF. Because readAllInto is
|
||||||
// defined to read from src until EOF, it does not treat an EOF from Read
|
// defined to read from src until EOF, it does not treat an EOF from Read
|
||||||
|
|||||||
@@ -34,6 +34,20 @@ import (
|
|||||||
"github.com/minio/minio/internal/logger/target/testlogger"
|
"github.com/minio/minio/internal/logger/target/testlogger"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestFrameReadBuffer(t *testing.T) {
|
||||||
|
for _, length := range []int64{0, 128, readBufferSize, 4 * readBufferSize} {
|
||||||
|
buf := frameReadBuffer(nil, length)
|
||||||
|
if len(buf) != 0 || int64(cap(buf)) != min(length, int64(readBufferSize)) {
|
||||||
|
t.Fatalf("length %d: got len %d, cap %d", length, len(buf), cap(buf))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
buf := make([]byte, 128)
|
||||||
|
got := frameReadBuffer(buf, int64(len(buf)))
|
||||||
|
if len(got) != 0 || cap(got) != cap(buf) || &got[:1][0] != &buf[0] {
|
||||||
|
t.Fatal("did not reuse the existing read buffer")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestSingleRoundtrip(t *testing.T) {
|
func TestSingleRoundtrip(t *testing.T) {
|
||||||
defer testlogger.T.SetLogTB(t)()
|
defer testlogger.T.SetLogTB(t)()
|
||||||
errFatal := func(err error) {
|
errFatal := func(err error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user