Skip to content

Commit

Permalink
fix pool defer (vesoft-inc#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
veezhang committed Oct 27, 2021
1 parent faa520b commit 821fe97
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions service/pool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,23 +116,25 @@ func NewConnection(address string, port int, username string, password string) (
for {
select {
case request := <-connection.RequestChannel:
defer func() {
if err := recover(); err != nil {
common.LogPanic(err)
request.ResponseChannel <- ChannelResponse{
Result: nil,
Error: SessionLostError,
func() {
defer func() {
if err := recover(); err != nil {
common.LogPanic(err)
request.ResponseChannel <- ChannelResponse{
Result: nil,
Error: SessionLostError,
}
}
}()
response, err := connection.session.Execute(request.Gql)
if err != nil && (isThriftProtoError(err) || isThriftTransportError(err)) {
err = ConnectionClosedError
}
request.ResponseChannel <- ChannelResponse{
Result: response,
Error: err,
}
}()
response, err := connection.session.Execute(request.Gql)
if err != nil && (isThriftProtoError(err) || isThriftTransportError(err)) {
err = ConnectionClosedError
}
request.ResponseChannel <- ChannelResponse{
Result: response,
Error: err,
}
case <-connection.CloseChannel:
connection.session.Release()
connectLock.Lock()
Expand Down

0 comments on commit 821fe97

Please sign in to comment.