Skip to content

Commit

Permalink
websocket: fix transfer conn concurrent op
Browse files Browse the repository at this point in the history
  • Loading branch information
lesismal committed Nov 20, 2023
1 parent 8512d68 commit b7f2ada
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions nbhttp/websocket/upgrader.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func (u *Upgrader) Upgrade(w http.ResponseWriter, r *http.Request, responseHeade
nbhttpConn.Trasfered = true
}
vt.ResetRawInput()
parser = &nbhttp.Parser{Execute: nbc.Execute}
parser = nbhttp.NewParser(nil, false, engine.ReadLimit, nbc.Execute)
if engine.EpollMod == nbio.EPOLLET && engine.EPOLLONESHOT == nbio.EPOLLONESHOT {
parser.Execute = nbhttp.SyncExecutor
}
Expand Down Expand Up @@ -301,7 +301,7 @@ func (u *Upgrader) Upgrade(w http.ResponseWriter, r *http.Request, responseHeade
return
}
if nread > 0 {
errRead = wsc.Read(parser, buffer[:nread])
errRead = parser.Read(buffer[:nread])
if err != nil {
logging.Debug("websocket Conn Read failed: %v", errRead)
c.CloseWithError(errRead)
Expand Down Expand Up @@ -346,7 +346,7 @@ func (u *Upgrader) Upgrade(w http.ResponseWriter, r *http.Request, responseHeade
if nbhttpConn != nil {
nbhttpConn.Trasfered = true
}
parser = &nbhttp.Parser{Execute: nbc.Execute}
parser = nbhttp.NewParser(nil, false, engine.ReadLimit, nbc.Execute)
if engine.EpollMod == nbio.EPOLLET && engine.EPOLLONESHOT == nbio.EPOLLONESHOT {
parser.Execute = nbhttp.SyncExecutor
}
Expand All @@ -364,7 +364,7 @@ func (u *Upgrader) Upgrade(w http.ResponseWriter, r *http.Request, responseHeade
}
}()

errRead := wsc.Read(parser, data)
errRead := parser.Read(data)
if errRead != nil {
logging.Debug("websocket Conn Read failed: %v", errRead)
c.CloseWithError(errRead)
Expand Down

0 comments on commit b7f2ada

Please sign in to comment.