@@ -115,8 +115,6 @@ pub struct ConversationHttp {
115
115
pending_request : Option < ReplyHandleHttp > ,
116
116
/// outstanding response
117
117
pending_response : Option < StacksHttpResponse > ,
118
- /// whether or not there's an error response pending
119
- pending_error_response : bool ,
120
118
/// how much data to buffer (i.e. the socket's send buffer size)
121
119
socket_send_buffer_size : u32 ,
122
120
}
@@ -166,7 +164,6 @@ impl ConversationHttp {
166
164
canonical_stacks_tip_height : None ,
167
165
pending_request : None ,
168
166
pending_response : None ,
169
- pending_error_response : false ,
170
167
keep_alive : true ,
171
168
total_request_count : 0 ,
172
169
total_reply_count : 0 ,
@@ -228,15 +225,6 @@ impl ConversationHttp {
228
225
) ;
229
226
return Err ( net_error:: InProgress ) ;
230
227
}
231
- if self . pending_error_response {
232
- test_debug ! (
233
- "{:?},id={}: Error response is inflight" ,
234
- & self . peer_host,
235
- self . conn_id
236
- ) ;
237
- return Err ( net_error:: InProgress ) ;
238
- }
239
-
240
228
let handle = self . start_request ( req) ?;
241
229
242
230
self . pending_request = Some ( handle) ;
@@ -255,12 +243,12 @@ impl ConversationHttp {
255
243
) ;
256
244
return Err ( net_error:: InProgress ) ;
257
245
}
258
- if self . pending_error_response {
259
- // error already in-flight
260
- return Ok ( ( ) ) ;
261
- }
246
+ let ( mut preamble, body_contents) = res. try_into_contents ( ) ?;
247
+ preamble. content_length = body_contents. content_length ( ) ;
248
+ preamble. keep_alive = false ;
262
249
263
- let ( preamble, body_contents) = res. try_into_contents ( ) ?;
250
+ // account for the request
251
+ self . total_request_count += 1 ;
264
252
265
253
// make the relay handle. There may not have been a valid request in the first place, so
266
254
// we'll use a relay handle (not a reply handle) to push out the error.
@@ -269,7 +257,6 @@ impl ConversationHttp {
269
257
// queue up the HTTP headers, and then stream back the body.
270
258
preamble. consensus_serialize ( & mut reply) ?;
271
259
self . reply_streams . push_back ( ( reply, body_contents, false ) ) ;
272
- self . pending_error_response = true ;
273
260
Ok ( ( ) )
274
261
}
275
262
@@ -388,11 +375,12 @@ impl ConversationHttp {
388
375
if broken || ( drained_handle && drained_stream) {
389
376
// done with this stream
390
377
test_debug ! (
391
- "{:?}: done with stream (broken={}, drained_handle={}, drained_stream={})" ,
378
+ "{:?}: done with stream (broken={}, drained_handle={}, drained_stream={}, do_keep_alive={} )" ,
392
379
& self ,
393
380
broken,
394
381
drained_handle,
395
- drained_stream
382
+ drained_stream,
383
+ do_keep_alive,
396
384
) ;
397
385
self . total_reply_count += 1 ;
398
386
self . reply_streams . pop_front ( ) ;
@@ -482,6 +470,14 @@ impl ConversationHttp {
482
470
483
471
/// Is the connection idle?
484
472
pub fn is_idle ( & self ) -> bool {
473
+ test_debug ! (
474
+ "{:?} is_idle? {},{},{},{}" ,
475
+ self ,
476
+ self . pending_response. is_none( ) ,
477
+ self . connection. inbox_len( ) ,
478
+ self . connection. outbox_len( ) ,
479
+ self . reply_streams. len( )
480
+ ) ;
485
481
self . pending_response . is_none ( )
486
482
&& self . connection . inbox_len ( ) == 0
487
483
&& self . connection . outbox_len ( ) == 0
@@ -491,9 +487,13 @@ impl ConversationHttp {
491
487
/// Is the conversation out of pending data?
492
488
/// Don't consider it drained if we haven't received anything yet
493
489
pub fn is_drained ( & self ) -> bool {
494
- ( ( self . total_request_count > 0 && self . total_reply_count > 0 )
495
- || self . pending_error_response )
496
- && self . is_idle ( )
490
+ test_debug ! (
491
+ "{:?} is_drained? {},{}" ,
492
+ self ,
493
+ self . total_request_count,
494
+ self . total_reply_count
495
+ ) ;
496
+ self . total_request_count > 0 && self . total_reply_count > 0 && self . is_idle ( )
497
497
}
498
498
499
499
/// Should the connection be kept alive even if drained?
@@ -523,11 +523,6 @@ impl ConversationHttp {
523
523
& mut self ,
524
524
node : & mut StacksNodeState ,
525
525
) -> Result < Vec < StacksMessageType > , net_error > {
526
- // if we have an in-flight error, then don't take any more requests.
527
- if self . pending_error_response {
528
- return Ok ( vec ! [ ] ) ;
529
- }
530
-
531
526
// handle in-bound HTTP request(s)
532
527
let num_inbound = self . connection . inbox_len ( ) ;
533
528
let mut ret = vec ! [ ] ;
@@ -568,7 +563,6 @@ impl ConversationHttp {
568
563
}
569
564
StacksHttpMessage :: Error ( path, resp) => {
570
565
// new request, but resulted in an error when parsing it
571
- self . total_request_count += 1 ;
572
566
self . last_request_timestamp = get_epoch_time_secs ( ) ;
573
567
let start_time = Instant :: now ( ) ;
574
568
self . reply_error ( resp) ?;
0 commit comments