File tree Expand file tree Collapse file tree 3 files changed +42
-3
lines changed Expand file tree Collapse file tree 3 files changed +42
-3
lines changed Original file line number Diff line number Diff line change @@ -463,7 +463,20 @@ sub grpc {
463
463
{ name => ' te' , value => ' trailers' , mode => 2 }]});
464
464
465
465
if (!$extra {reuse }) {
466
- $client = $server -> accept() or return ;
466
+ eval {
467
+ local $SIG {ALRM } = sub { die " timeout\n " };
468
+ alarm(5);
469
+
470
+ $client = $server -> accept() or return ;
471
+
472
+ alarm(0);
473
+ };
474
+ alarm(0);
475
+ if ($@ ) {
476
+ log_in(" died: $@ " );
477
+ return undef ;
478
+ }
479
+
467
480
log2c(" (new connection $client )" );
468
481
$n ++;
469
482
Original file line number Diff line number Diff line change @@ -102,7 +102,20 @@ sub grpc {
102
102
{ name => ' content-length' , value => ' 5' }]});
103
103
104
104
if (!$extra {reuse }) {
105
- $client = $server -> accept() or return ;
105
+ eval {
106
+ local $SIG {ALRM } = sub { die " timeout\n " };
107
+ alarm(5);
108
+
109
+ $client = $server -> accept() or return ;
110
+
111
+ alarm(0);
112
+ };
113
+ alarm(0);
114
+ if ($@ ) {
115
+ log_in(" died: $@ " );
116
+ return undef ;
117
+ }
118
+
106
119
log2c(" (new connection $client )" );
107
120
108
121
$client -> sysread (my $buf , 24) == 24 or return ; # preface
Original file line number Diff line number Diff line change @@ -241,7 +241,20 @@ sub grpc {
241
241
{ name => ' te' , value => ' trailers' , mode => 2 }]});
242
242
243
243
if (!$extra {reuse }) {
244
- $client = $server -> accept() or return ;
244
+ eval {
245
+ local $SIG {ALRM } = sub { die " timeout\n " };
246
+ alarm(5);
247
+
248
+ $client = $server -> accept() or return ;
249
+
250
+ alarm(0);
251
+ };
252
+ alarm(0);
253
+ if ($@ ) {
254
+ log_in(" died: $@ " );
255
+ return undef ;
256
+ }
257
+
245
258
log2c(" (new connection $client )" );
246
259
247
260
$client -> sysread (my $buf , 24) == 24 or return ; # preface
You can’t perform that action at this time.
0 commit comments