File tree Expand file tree Collapse file tree 1 file changed +9
-24
lines changed Expand file tree Collapse file tree 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) {
10451045}
10461046
10471047// 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.
10501049func (conn * Connection ) contextWatchdog (fut * Future , ctx context.Context ) {
10511050 select {
10521051 case <- fut .done :
1052+ case <- ctx .Done ():
1053+ }
1054+
1055+ select {
1056+ case <- fut .done :
1057+ return
10531058 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" ))
10641060 }
10651061}
10661062
@@ -1076,11 +1072,9 @@ func (conn *Connection) send(req Request, streamId uint64) *Future {
10761072 return fut
10771073 default :
10781074 }
1079- }
1080- conn .putFuture (fut , req , streamId )
1081- if req .Ctx () != nil {
10821075 go conn .contextWatchdog (fut , req .Ctx ())
10831076 }
1077+ conn .putFuture (fut , req , streamId )
10841078 return fut
10851079}
10861080
@@ -1293,15 +1287,6 @@ func (conn *Connection) Do(req Request) *Future {
12931287 return fut
12941288 }
12951289 }
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- }
13051290 return conn .send (req , ignoreStreamId )
13061291}
13071292
You can’t perform that action at this time.
0 commit comments