@@ -179,7 +179,7 @@ impl<P: ExecutorProviderInterface> Proxy<P> {
179
179
res = receiver. recv( ) => {
180
180
match async_map( res, |r| self . handle_incoming( is_primary, r) ) . await {
181
181
Some ( HandleRequestResult :: Ok ) if is_primary => {
182
- self . maybe_flush_primary_queue( true , & mut sender) ;
182
+ self . maybe_flush_primary_queue( true , & mut sender) . await ;
183
183
} ,
184
184
Some ( HandleRequestResult :: Ok ) => { } ,
185
185
Some ( HandleRequestResult :: TerminateConnection ) => {
@@ -201,13 +201,13 @@ impl<P: ExecutorProviderInterface> Proxy<P> {
201
201
// the same connection mode. The client must have lost its connection.
202
202
// We terminate the current (old) connection with a `ConnectionInUse` error.
203
203
( true , true ) => {
204
- sender. terminate( TerminationReason :: ConnectionInUse ) ;
204
+ sender. terminate( TerminationReason :: ConnectionInUse ) . await ;
205
205
self . discard_bytes = true ;
206
206
self . queued_primary_response. clear( ) ;
207
207
State :: OnlyPrimaryConnection ( pair)
208
208
} ,
209
209
( false , false ) => {
210
- sender. terminate( TerminationReason :: ConnectionInUse ) ;
210
+ sender. terminate( TerminationReason :: ConnectionInUse ) . await ;
211
211
self . discard_bytes = true ;
212
212
State :: OnlySecondaryConnection ( pair)
213
213
}
@@ -255,12 +255,12 @@ impl<P: ExecutorProviderInterface> Proxy<P> {
255
255
// This might be a window to flush some pending responses to the
256
256
// primary.
257
257
if is_primary {
258
- self . maybe_flush_primary_queue( true , & mut sender) ;
258
+ self . maybe_flush_primary_queue( true , & mut sender) . await ;
259
259
}
260
260
261
261
let bytes = self . buffer. split_to( 4 ) ;
262
262
let len = u32 :: from_be_bytes( * array_ref![ bytes, 0 , 4 ] ) as usize ;
263
- sender. start_write( len) ;
263
+ sender. start_write( len) . await ;
264
264
self . current_write = len;
265
265
continue ' inner; // to handle `len` == 0.
266
266
}
@@ -274,7 +274,7 @@ impl<P: ExecutorProviderInterface> Proxy<P> {
274
274
continue ' inner;
275
275
}
276
276
277
- if sender. write( bytes. freeze( ) ) . is_err( ) {
277
+ if sender. write( bytes. freeze( ) ) . await . is_err( ) {
278
278
self . discard_bytes = true ;
279
279
self . queued_primary_response. clear( ) ;
280
280
return State :: NoConnection ;
@@ -285,7 +285,7 @@ impl<P: ExecutorProviderInterface> Proxy<P> {
285
285
}
286
286
} ;
287
287
288
- sender. terminate ( reason) ;
288
+ sender. terminate ( reason) . await ;
289
289
State :: Terminated
290
290
}
291
291
@@ -312,7 +312,7 @@ impl<P: ExecutorProviderInterface> Proxy<P> {
312
312
res = p_receiver. recv( ) => {
313
313
match async_map( res, |r| self . handle_incoming( true , r) ) . await {
314
314
Some ( HandleRequestResult :: Ok ) => {
315
- self . maybe_flush_primary_queue( false , & mut p_sender) ;
315
+ self . maybe_flush_primary_queue( false , & mut p_sender) . await ;
316
316
} ,
317
317
Some ( HandleRequestResult :: TerminateConnection ) => {
318
318
break ' outer TerminationReason :: InternalError ;
@@ -393,11 +393,11 @@ impl<P: ExecutorProviderInterface> Proxy<P> {
393
393
394
394
// This might be a window to flush some pending responses to the
395
395
// primary.
396
- self . maybe_flush_primary_queue( false , & mut p_sender) ;
396
+ self . maybe_flush_primary_queue( false , & mut p_sender) . await ;
397
397
398
398
let bytes = self . buffer. split_to( 4 ) ;
399
399
let len = u32 :: from_be_bytes( * array_ref![ bytes, 0 , 4 ] ) as usize ;
400
- s_sender. start_write( len) ;
400
+ s_sender. start_write( len) . await ;
401
401
self . current_write = len;
402
402
continue ' inner; // to handle `len` == 0.
403
403
}
@@ -412,14 +412,14 @@ impl<P: ExecutorProviderInterface> Proxy<P> {
412
412
}
413
413
414
414
return if self . is_primary_the_current_sender {
415
- if p_sender. write( bytes. freeze( ) ) . is_ok( ) {
415
+ if p_sender. write( bytes. freeze( ) ) . await . is_ok( ) {
416
416
continue ' inner;
417
417
}
418
418
self . discard_bytes = true ;
419
419
self . queued_primary_response. clear( ) ;
420
420
State :: OnlySecondaryConnection ( ( s_sender, s_receiver) . into( ) )
421
421
} else {
422
- if s_sender. write( bytes. freeze( ) ) . is_ok( ) {
422
+ if s_sender. write( bytes. freeze( ) ) . await . is_ok( ) {
423
423
continue ' inner;
424
424
}
425
425
self . discard_bytes = true ;
@@ -431,8 +431,8 @@ impl<P: ExecutorProviderInterface> Proxy<P> {
431
431
}
432
432
} ;
433
433
434
- s_sender. terminate ( reason) ;
435
- p_sender. terminate ( reason) ;
434
+ s_sender. terminate ( reason) . await ;
435
+ p_sender. terminate ( reason) . await ;
436
436
State :: Terminated
437
437
}
438
438
@@ -493,7 +493,7 @@ impl<P: ExecutorProviderInterface> Proxy<P> {
493
493
}
494
494
495
495
#[ inline( always) ]
496
- fn maybe_flush_primary_queue < S : TransportSender > (
496
+ async fn maybe_flush_primary_queue < S : TransportSender > (
497
497
& mut self ,
498
498
only_primary : bool ,
499
499
sender : & mut S ,
@@ -505,7 +505,7 @@ impl<P: ExecutorProviderInterface> Proxy<P> {
505
505
let is_primary_current_writer = only_primary || self . is_primary_the_current_sender ;
506
506
if !is_primary_current_writer || self . current_write == 0 || self . discard_bytes {
507
507
while let Some ( res) = self . queued_primary_response . pop_back ( ) {
508
- sender. send ( res) ;
508
+ sender. send ( res) . await ;
509
509
}
510
510
}
511
511
}
0 commit comments