mirror of
https://github.com/valyala/fasthttp.git
synced 2026-06-13 15:46:49 +03:00
export ErrConnectionClosed (#2152)
This commit is contained in:
@@ -121,7 +121,7 @@ func (c *pipeConn) Write(p []byte) (int, error) {
|
||||
select {
|
||||
case <-c.pc.stopCh:
|
||||
releaseByteBuffer(b)
|
||||
return 0, errConnectionClosed
|
||||
return 0, ErrConnectionClosed
|
||||
default:
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ func (c *pipeConn) Write(p []byte) (int, error) {
|
||||
return 0, ErrTimeout
|
||||
case <-c.pc.stopCh:
|
||||
releaseByteBuffer(b)
|
||||
return 0, errConnectionClosed
|
||||
return 0, ErrConnectionClosed
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,10 +218,10 @@ func (c *pipeConn) readNextByteBuffer(mayBlock bool) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
var (
|
||||
errWouldBlock = errors.New("would block")
|
||||
errConnectionClosed = errors.New("connection closed")
|
||||
)
|
||||
var errWouldBlock = errors.New("would block")
|
||||
|
||||
// ErrConnectionClosed indicates that the underlying connection is closed. It could mean that the client has disconnected.
|
||||
var ErrConnectionClosed = errors.New("connection closed")
|
||||
|
||||
type timeoutError struct{}
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@ func testPipeConnsCloseWhileReadWrite(t *testing.T) {
|
||||
go func() {
|
||||
var err error
|
||||
if _, err = io.Copy(io.Discard, c1); err != nil {
|
||||
if err != errConnectionClosed {
|
||||
if err != ErrConnectionClosed {
|
||||
err = fmt.Errorf("unexpected error: %w", err)
|
||||
} else {
|
||||
err = nil
|
||||
@@ -176,7 +176,7 @@ func testPipeConnsCloseWhileReadWrite(t *testing.T) {
|
||||
var err error
|
||||
for {
|
||||
if _, err = c2.Write([]byte("foobar")); err != nil {
|
||||
if err != errConnectionClosed {
|
||||
if err != ErrConnectionClosed {
|
||||
err = fmt.Errorf("unexpected error: %w", err)
|
||||
} else {
|
||||
err = nil
|
||||
|
||||
Reference in New Issue
Block a user