File tree 2 files changed +19
-16
lines changed 2 files changed +19
-16
lines changed Original file line number Diff line number Diff line change @@ -171,7 +171,9 @@ func (conn *Connection) reader() {
171
171
conn .closeConnection (err )
172
172
continue
173
173
}
174
- resp , err := newResponse (resp_bytes )
174
+ resp := Response {buf :smallBuf {b :resp_bytes }}
175
+ err = resp .decodeHeader ()
176
+ //resp, err := newResponse(resp_bytes)
175
177
if err != nil {
176
178
conn .closeConnection (err )
177
179
continue
Original file line number Diff line number Diff line change @@ -16,11 +16,10 @@ type Request struct {
16
16
type Future struct {
17
17
conn * Connection
18
18
id uint32
19
- resp * Response
19
+ resp Response
20
20
err error
21
21
c chan struct {}
22
22
t * time.Timer
23
- tc <- chan time.Time
24
23
}
25
24
26
25
func (conn * Connection ) NewRequest (requestCode int32 ) (req * Request ) {
@@ -217,7 +216,6 @@ func (req *Request) future() (f *Future) {
217
216
218
217
if req .conn .opts .Timeout > 0 {
219
218
f .t = time .NewTimer (req .conn .opts .Timeout )
220
- f .tc = f .t .C
221
219
}
222
220
return
223
221
}
@@ -226,32 +224,35 @@ func (f *Future) wait() {
226
224
select {
227
225
case <- f .c :
228
226
default :
229
- select {
230
- case <- f .c :
231
- case <- f .tc :
232
- f .conn .mutex .Lock ()
233
- if _ , ok := f .conn .requests [f .id ]; ok {
234
- delete (f .conn .requests , f .id )
235
- close (f .c )
236
- f .err = errors .New ("client timeout" )
227
+ if t := f .t ; t != nil {
228
+ select {
229
+ case <- f .c :
230
+ case <- t .C :
231
+ f .conn .mutex .Lock ()
232
+ if _ , ok := f .conn .requests [f .id ]; ok {
233
+ delete (f .conn .requests , f .id )
234
+ close (f .c )
235
+ f .err = errors .New ("client timeout" )
236
+ }
237
+ f .conn .mutex .Unlock ()
237
238
}
238
- f .conn .mutex .Unlock ()
239
+ } else {
240
+ <- f .c
239
241
}
240
242
}
241
243
if f .t != nil {
242
244
f .t .Stop ()
243
245
f .t = nil
244
- f .tc = nil
245
246
}
246
247
}
247
248
248
249
func (f * Future ) Get () (* Response , error ) {
249
250
f .wait ()
250
251
if f .err != nil {
251
- return f .resp , f .err
252
+ return & f .resp , f .err
252
253
}
253
254
f .err = f .resp .decodeBody ()
254
- return f .resp , f .err
255
+ return & f .resp , f .err
255
256
}
256
257
257
258
func (f * Future ) GetTyped (r interface {}) (error ) {
You can’t perform that action at this time.
0 commit comments