File tree Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Original file line number Diff line number Diff line change 5
5
(package xapi)
6
6
(libraries
7
7
dune-build-info
8
+ polly
8
9
stunnel
9
10
safe-resources
10
11
xapi-consts
Original file line number Diff line number Diff line change @@ -60,12 +60,25 @@ let proxy (ain : Unix.file_descr) (aout : Unix.file_descr) (bin : Unixfd.t)
60
60
(if can_write a' then [bout] else [] )
61
61
@ if can_write b' then [aout] else []
62
62
in
63
- let r, w, _ = Unix. select r w [] (- 1.0 ) in
64
- (* Do the writing before the reading *)
65
- List. iter
66
- (fun fd -> if aout = fd then write_from b' a' else write_from a' b')
67
- w ;
68
- List. iter (fun fd -> if ain = fd then read_into a' else read_into b') r
63
+ let epoll = Polly. create () in
64
+ List. iter (fun fd -> Polly. add epoll fd Polly.Events. inp) r ;
65
+ List. iter (fun fd -> Polly. add epoll fd Polly.Events. out) w ;
66
+ Fun. protect
67
+ ~finally: (fun () -> Polly. close epoll)
68
+ (fun () ->
69
+ ignore
70
+ @@ Polly. wait epoll 4 (- 1 ) (fun _ fd _ ->
71
+ (* Note: only one fd is handled *)
72
+ if aout = fd then
73
+ write_from b' a'
74
+ else if bout = fd then
75
+ write_from a' b'
76
+ else if ain = fd then
77
+ read_into a'
78
+ else
79
+ read_into b'
80
+ )
81
+ )
69
82
done
70
83
with _ -> (
71
84
(try Unix. clear_nonblock ain with _ -> () ) ;
You can’t perform that action at this time.
0 commit comments