File tree 1 file changed +10
-4
lines changed 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -112,7 +112,7 @@ final class Select implements EventInterface
112
112
*
113
113
* @var int
114
114
*/
115
- private int $ selectTimeout = 800000 ;
115
+ private int $ selectTimeout = self :: MAX_SELECT_TIMOUT_US ;
116
116
117
117
/**
118
118
* Next run time of the timer.
@@ -126,6 +126,13 @@ final class Select implements EventInterface
126
126
*/
127
127
private $ errorHandler = null ;
128
128
129
+ /**
130
+ * Select timeout.
131
+ *
132
+ * @var int
133
+ */
134
+ const MAX_SELECT_TIMOUT_US = 800000 ;
135
+
129
136
/**
130
137
* Construct.
131
138
*/
@@ -359,11 +366,10 @@ protected function setNextTickTime(float $nextTickTime): void
359
366
if ($ nextTickTime == 0 ) {
360
367
// Swow will affect the signal interruption characteristics of stream_select,
361
368
// so a shorter timeout should be used to detect signals.
362
- $ this ->selectTimeout = 800000 ;
369
+ $ this ->selectTimeout = self :: MAX_SELECT_TIMOUT_US ;
363
370
return ;
364
371
}
365
- $ timeNow = microtime (true );
366
- $ this ->selectTimeout = max ((int )(($ nextTickTime - $ timeNow ) * 1000000 ), 0 );
372
+ $ this ->selectTimeout = min (max ((int )(($ nextTickTime - microtime (true )) * 1000000 ), 0 ), self ::MAX_SELECT_TIMOUT_US );
367
373
}
368
374
369
375
/**
You can’t perform that action at this time.
0 commit comments