File tree 1 file changed +9
-24
lines changed 1 file changed +9
-24
lines changed Original file line number Diff line number Diff line change @@ -1045,22 +1045,18 @@ func (conn *Connection) newFuture(ctx context.Context) (fut *Future) {
1045
1045
}
1046
1046
1047
1047
// This method removes a future from the internal queue if the context
1048
- // is "done" before the response is come. Such select logic is inspired
1049
- // from this thread: https://groups.google.com/g/golang-dev/c/jX4oQEls3uk
1048
+ // is "done" before the response is come.
1050
1049
func (conn * Connection ) contextWatchdog (fut * Future , ctx context.Context ) {
1051
1050
select {
1052
1051
case <- fut .done :
1052
+ case <- ctx .Done ():
1053
+ }
1054
+
1055
+ select {
1056
+ case <- fut .done :
1057
+ return
1053
1058
default :
1054
- select {
1055
- case <- ctx .Done ():
1056
- conn .cancelFuture (fut , fmt .Errorf ("context is done" ))
1057
- default :
1058
- select {
1059
- case <- fut .done :
1060
- case <- ctx .Done ():
1061
- conn .cancelFuture (fut , fmt .Errorf ("context is done" ))
1062
- }
1063
- }
1059
+ conn .cancelFuture (fut , fmt .Errorf ("context is done" ))
1064
1060
}
1065
1061
}
1066
1062
@@ -1076,11 +1072,9 @@ func (conn *Connection) send(req Request, streamId uint64) *Future {
1076
1072
return fut
1077
1073
default :
1078
1074
}
1079
- }
1080
- conn .putFuture (fut , req , streamId )
1081
- if req .Ctx () != nil {
1082
1075
go conn .contextWatchdog (fut , req .Ctx ())
1083
1076
}
1077
+ conn .putFuture (fut , req , streamId )
1084
1078
return fut
1085
1079
}
1086
1080
@@ -1293,15 +1287,6 @@ func (conn *Connection) Do(req Request) *Future {
1293
1287
return fut
1294
1288
}
1295
1289
}
1296
- if req .Ctx () != nil {
1297
- select {
1298
- case <- req .Ctx ().Done ():
1299
- fut := NewFuture ()
1300
- fut .SetError (fmt .Errorf ("context is done" ))
1301
- return fut
1302
- default :
1303
- }
1304
- }
1305
1290
return conn .send (req , ignoreStreamId )
1306
1291
}
1307
1292
You can’t perform that action at this time.
0 commit comments