@@ -207,41 +207,39 @@ let rec process_timeouts s =
207
207
*. (1. /. 1_000_000_000. )
208
208
209
209
let rec select_thread s timeout rd wr ex =
210
- if s.state == `Alive then
211
- if Atomic. compare_and_set s.phase Continue Select then
212
- begin
210
+ if s.state == `Alive then (
211
+ let rd_fds, wr_fds, ex_fds =
212
+ if Atomic. compare_and_set s.phase Continue Select then begin
213
213
try
214
214
Unix. select
215
215
(s.pipe_inn :: rd.unique_fds)
216
216
wr.unique_fds ex.unique_fds timeout
217
217
with Unix. Unix_error (EINTR, _ , _ ) -> ([] , [] , [] )
218
218
end
219
- |> select_thread_continue s rd wr ex
220
- else select_thread_continue s rd wr ex ([] , [] , [] )
221
-
222
- and select_thread_continue s rd wr ex (rd_fds , wr_fds , ex_fds ) =
223
- begin
224
- match Atomic. exchange s.phase Continue with
225
- | Select | Process | Continue -> ()
226
- | Waking_up ->
227
- let n = Unix. read s.pipe_inn s.byte 0 1 in
228
- assert (n = 1 )
229
- end ;
230
- let rd = process_fds rd_fds rd (Picos_thread_atomic. exchange s.new_rd [] ) in
231
- let wr = process_fds wr_fds wr (Picos_thread_atomic. exchange s.new_wr [] ) in
232
- let ex = process_fds ex_fds ex (Picos_thread_atomic. exchange s.new_ex [] ) in
233
- let tos = process_timeouts s in
234
- let tos =
235
- let state = Atomic. get intr_pending in
236
- if state.value = 0 then tos
237
- else begin
238
- assert (0 < state.value);
239
- Unix. kill (Unix. getpid () ) config.intr_sig;
240
- let idle = 0.000_001 (* 1μs *) in
241
- if tos < 0.0 || idle < = tos then idle else tos
242
- end
243
- in
244
- select_thread s tos rd wr ex
219
+ else ([] , [] , [] )
220
+ in
221
+ begin
222
+ match Atomic. exchange s.phase Continue with
223
+ | Select | Process | Continue -> ()
224
+ | Waking_up ->
225
+ let n = Unix. read s.pipe_inn s.byte 0 1 in
226
+ assert (n = 1 )
227
+ end ;
228
+ let rd = process_fds rd_fds rd (Picos_thread_atomic. exchange s.new_rd [] ) in
229
+ let wr = process_fds wr_fds wr (Picos_thread_atomic. exchange s.new_wr [] ) in
230
+ let ex = process_fds ex_fds ex (Picos_thread_atomic. exchange s.new_ex [] ) in
231
+ let timeout = process_timeouts s in
232
+ let timeout =
233
+ let state = Atomic. get intr_pending in
234
+ if state.value = 0 then timeout
235
+ else begin
236
+ assert (0 < state.value);
237
+ Unix. kill (Unix. getpid () ) config.intr_sig;
238
+ let idle = 0.000_001 (* 1μs *) in
239
+ if timeout < 0.0 || idle < = timeout then idle else timeout
240
+ end
241
+ in
242
+ select_thread s timeout rd wr ex)
245
243
246
244
let select_thread s =
247
245
if Picos_domain. is_main_domain () then
0 commit comments