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 55 (package xapi)
66 (libraries
77 dune-build-info
8+ polly
89 stunnel
910 safe-resources
1011 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)
6060 (if can_write a' then [bout] else [] )
6161 @ if can_write b' then [aout] else []
6262 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+ )
6982 done
7083 with _ -> (
7184 (try Unix. clear_nonblock ain with _ -> () ) ;
You can’t perform that action at this time.
0 commit comments