Skip to content

Commit

Permalink
fix #69
Browse files Browse the repository at this point in the history
  • Loading branch information
joao-r-reis committed Oct 19, 2022
1 parent e049544 commit 215ab16
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
18 changes: 10 additions & 8 deletions proxy/pkg/zdmproxy/clientconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ func (cc *ClientConnector) listenForRequests() {
bufferedReader := bufio.NewReaderSize(cc.connection, cc.conf.RequestWriteBufferSizeBytes)
connectionAddr := cc.connection.RemoteAddr().String()
protocolErrOccurred := false
var alreadySentProtocolErr *frame.RawFrame
for cc.clientHandlerContext.Err() == nil {
f, err := readRawFrame(bufferedReader, connectionAddr, cc.clientHandlerContext)

Expand All @@ -174,14 +175,15 @@ func (cc *ClientConnector) listenForRequests() {
err, cc.clientHandlerContext, cc.clientHandlerCancelFunc, ClientConnectorLogPrefix, "reading", connectionAddr)
break
} else if protocolErrResponseFrame != nil {
f = protocolErrResponseFrame
if !protocolErrOccurred {
protocolErrOccurred = true
cc.sendResponseToClient(protocolErrResponseFrame)
cc.clientHandlerShutdownRequestCancelFn()
setDrainModeNowFunc()
continue
}
alreadySentProtocolErr = protocolErrResponseFrame
protocolErrOccurred = true
cc.sendResponseToClient(protocolErrResponseFrame)
continue
} else if alreadySentProtocolErr != nil {
clonedProtocolErr := alreadySentProtocolErr.Clone()
clonedProtocolErr.Header.StreamId = f.Header.StreamId
cc.sendResponseToClient(clonedProtocolErr)
continue
}

wg.Add(1)
Expand Down
1 change: 0 additions & 1 deletion proxy/pkg/zdmproxy/clienthandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,6 @@ func (ch *ClientHandler) tryProcessProtocolError(response *Response, protocolErr
errMsg, response.connectorType)
}
ch.clientConnector.sendResponseToClient(response.responseFrame)
ch.clientHandlerShutdownRequestCancelFn()
}
return true
}
Expand Down

0 comments on commit 215ab16

Please sign in to comment.