@@ -508,6 +508,27 @@ static int pending_shutdown(struct conn *c)
508
508
return c -> cd [0 ].pending_shutdown + c -> cd [1 ].pending_shutdown ;
509
509
}
510
510
511
+ static bool should_shutdown (struct conn * c )
512
+ {
513
+ int i ;
514
+
515
+ if (!pending_shutdown (c ))
516
+ return false;
517
+ if (is_sink )
518
+ return true;
519
+ if (!bidi )
520
+ return c -> cd [0 ].rcv == c -> cd [1 ].snd ;
521
+
522
+ for (i = 0 ; i < 2 ; i ++ ) {
523
+ if (c -> cd [0 ].rcv != c -> cd [1 ].snd )
524
+ return false;
525
+ if (c -> cd [1 ].rcv != c -> cd [0 ].snd )
526
+ return false;
527
+ }
528
+
529
+ return true;
530
+ }
531
+
511
532
static void __close_conn (struct io_uring * ring , struct conn * c )
512
533
{
513
534
printf ("Client %d: queueing shutdown\n" , c -> tid );
@@ -540,7 +561,7 @@ static void __queue_send(struct io_uring *ring, struct conn *c, int fd,
540
561
}
541
562
542
563
sqe = get_sqe (ring );
543
- io_uring_prep_send (sqe , fd , data , len , MSG_WAITALL );
564
+ io_uring_prep_send (sqe , fd , data , len , MSG_WAITALL | MSG_NOSIGNAL );
544
565
encode_userdata (sqe , c , __SEND , bgid , bid , fd );
545
566
if (fixed_files )
546
567
sqe -> flags |= IOSQE_FIXED_FILE ;
@@ -1055,7 +1076,7 @@ static void check_for_close(struct io_uring *ring)
1055
1076
1056
1077
if (c -> flags & (CONN_F_DISCONNECTING | CONN_F_DISCONNECTED ))
1057
1078
continue ;
1058
- if (pending_shutdown (c )) {
1079
+ if (should_shutdown (c )) {
1059
1080
__close_conn (ring , c );
1060
1081
c -> flags |= CONN_F_DISCONNECTING ;
1061
1082
}
0 commit comments