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 @@ -1062,22 +1062,18 @@ func (conn *Connection) newFuture(ctx context.Context) (fut *Future) {
1062
1062
}
1063
1063
1064
1064
// This method removes a future from the internal queue if the context
1065
- // is "done" before the response is come. Such select logic is inspired
1066
- // from this thread: https://groups.google.com/g/golang-dev/c/jX4oQEls3uk
1065
+ // is "done" before the response is come.
1067
1066
func (conn * Connection ) contextWatchdog (fut * Future , ctx context.Context ) {
1068
1067
select {
1069
1068
case <- fut .done :
1069
+ case <- ctx .Done ():
1070
+ }
1071
+
1072
+ select {
1073
+ case <- fut .done :
1074
+ return
1070
1075
default :
1071
- select {
1072
- case <- ctx .Done ():
1073
- conn .cancelFuture (fut , fmt .Errorf ("context is done" ))
1074
- default :
1075
- select {
1076
- case <- fut .done :
1077
- case <- ctx .Done ():
1078
- conn .cancelFuture (fut , fmt .Errorf ("context is done" ))
1079
- }
1080
- }
1076
+ conn .cancelFuture (fut , fmt .Errorf ("context is done" ))
1081
1077
}
1082
1078
}
1083
1079
@@ -1093,11 +1089,9 @@ func (conn *Connection) send(req Request, streamId uint64) *Future {
1093
1089
return fut
1094
1090
default :
1095
1091
}
1096
- }
1097
- conn .putFuture (fut , req , streamId )
1098
- if req .Ctx () != nil {
1099
1092
go conn .contextWatchdog (fut , req .Ctx ())
1100
1093
}
1094
+ conn .putFuture (fut , req , streamId )
1101
1095
return fut
1102
1096
}
1103
1097
@@ -1310,15 +1304,6 @@ func (conn *Connection) Do(req Request) *Future {
1310
1304
return fut
1311
1305
}
1312
1306
}
1313
- if req .Ctx () != nil {
1314
- select {
1315
- case <- req .Ctx ().Done ():
1316
- fut := NewFuture ()
1317
- fut .SetError (fmt .Errorf ("context is done" ))
1318
- return fut
1319
- default :
1320
- }
1321
- }
1322
1307
return conn .send (req , ignoreStreamId )
1323
1308
}
1324
1309
You can’t perform that action at this time.
0 commit comments