Skip to content

Commit f432ab2

Browse files
hetao92veezhang
andauthored
fix pool defer (#44) (#47)
Co-authored-by: Vee Zhang <[email protected]>
1 parent f627219 commit f432ab2

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

service/pool/pool.go

+16-14
Original file line numberDiff line numberDiff line change
@@ -116,23 +116,25 @@ func NewConnection(address string, port int, username string, password string) (
116116
for {
117117
select {
118118
case request := <-connection.RequestChannel:
119-
defer func() {
120-
if err := recover(); err != nil {
121-
common.LogPanic(err)
122-
request.ResponseChannel <- ChannelResponse{
123-
Result: nil,
124-
Error: SessionLostError,
119+
func() {
120+
defer func() {
121+
if err := recover(); err != nil {
122+
common.LogPanic(err)
123+
request.ResponseChannel <- ChannelResponse{
124+
Result: nil,
125+
Error: SessionLostError,
126+
}
125127
}
128+
}()
129+
response, err := connection.session.Execute(request.Gql)
130+
if err != nil && (isThriftProtoError(err) || isThriftTransportError(err)) {
131+
err = ConnectionClosedError
132+
}
133+
request.ResponseChannel <- ChannelResponse{
134+
Result: response,
135+
Error: err,
126136
}
127137
}()
128-
response, err := connection.session.Execute(request.Gql)
129-
if err != nil && (isThriftProtoError(err) || isThriftTransportError(err)) {
130-
err = ConnectionClosedError
131-
}
132-
request.ResponseChannel <- ChannelResponse{
133-
Result: response,
134-
Error: err,
135-
}
136138
case <-connection.CloseChannel:
137139
connection.session.Release()
138140
connectLock.Lock()

0 commit comments

Comments
 (0)