Skip to content

Commit

Permalink
Merge pull request #399 from lesismal/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
lesismal authored Feb 24, 2024
2 parents a22b783 + 0aa4c4c commit 5bf91e6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion conn_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ func (c *Conn) closeWithErrorWithoutLock(err error) error {
c.writeList = nil
}

if c.p.g != nil {
if c.p != nil {
c.p.deleteConn(c)
}

Expand Down
11 changes: 10 additions & 1 deletion nbhttp/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -580,17 +580,21 @@ func (engine *Engine) AddConnNonTLSNonBlocking(conn *Conn, tlsConfig *tls.Config
nbc, err := nbio.NBConn(conn.Conn)
if err != nil {
conn.Close()
decrease()
logging.Error("AddConnNonTLSNonBlocking failed: %v", err)
return
}
conn.Conn = nbc
if nbc.Session() != nil {
nbc.Close()
decrease()
logging.Error("AddConnNonTLSNonBlocking failed, invalid session: %v", nbc.Session())
return
}
key, err := conn2Array(nbc)
if err != nil {
nbc.Close()
decrease()
logging.Error("AddConnNonTLSNonBlocking failed: %v", err)
return
}
Expand All @@ -599,6 +603,7 @@ func (engine *Engine) AddConnNonTLSNonBlocking(conn *Conn, tlsConfig *tls.Config
if len(engine.conns) >= engine.MaxLoad {
engine.mux.Unlock()
nbc.Close()
decrease()
logging.Error("AddConnNonTLSNonBlocking failed: overload, already has %v online", engine.MaxLoad)
return
}
Expand All @@ -622,9 +627,9 @@ func (engine *Engine) AddConnNonTLSBlocking(conn *Conn, tlsConfig *tls.Config, d
engine.mux.Lock()
if len(engine.conns) >= engine.MaxLoad {
engine.mux.Unlock()
logging.Error("AddConnNonTLSBlocking failed: overload, already has %v online", engine.MaxLoad)
conn.Close()
decrease()
logging.Error("AddConnNonTLSBlocking failed: overload, already has %v online", engine.MaxLoad)
return
}
switch vt := conn.Conn.(type) {
Expand Down Expand Up @@ -660,18 +665,21 @@ func (engine *Engine) AddConnTLSNonBlocking(conn *Conn, tlsConfig *tls.Config, d
nbc, err := nbio.NBConn(conn.Conn)
if err != nil {
conn.Close()
decrease()
logging.Error("AddConnTLSNonBlocking failed: %v", err)
return
}
conn.Conn = nbc
if nbc.Session() != nil {
nbc.Close()
decrease()
logging.Error("AddConnTLSNonBlocking failed: session should not be nil")
return
}
key, err := conn2Array(nbc)
if err != nil {
nbc.Close()
decrease()
logging.Error("AddConnTLSNonBlocking failed: %v", err)
return
}
Expand All @@ -680,6 +688,7 @@ func (engine *Engine) AddConnTLSNonBlocking(conn *Conn, tlsConfig *tls.Config, d
if len(engine.conns) >= engine.MaxLoad {
engine.mux.Unlock()
nbc.Close()
decrease()
logging.Error("AddConnTLSNonBlocking failed: overload, already has %v online", engine.MaxLoad)
return
}
Expand Down

0 comments on commit 5bf91e6

Please sign in to comment.