Skip to content

Commit c27a6eb

Browse files
author
Marcello Seri
committed
lib/channel_helper: use bytes for the io_vector
Lwt old-style io_vectors are still using strings, this was an oversight, and there is a breaking change on that interface planned for lwt 5.0.0. By using bytes and an unsafe conversion to string, we make sure that the compiler does not violate immutability assumptions. Signed-off-by: Marcello Seri <[email protected]>
1 parent 68fc9cb commit c27a6eb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/channel_helper.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,11 @@ let advertise_t _common_options_t proxy_socket =
116116
proxy fd (Lwt_unix.of_unix_file_descr proxy_socket) in
117117
let t_unix =
118118
Lwt_unix.accept s_unix >>= fun (fd, _peer) ->
119-
let buffer = String.make (String.length token) '\000' in
120-
let io_vector = Lwt_unix.io_vector ~buffer ~offset:0 ~length:(String.length buffer) in
119+
let buffer = Bytes.make (String.length token) '\000' in
120+
let io_vector = Lwt_unix.io_vector ~buffer:(Bytes.unsafe_to_string buffer) ~offset:0 ~length:(Bytes.length buffer) in
121121
Lwt_unix.recv_msg ~socket:fd ~io_vectors:[io_vector] >>= fun (n, fds) ->
122122
List.iter Unix.close fds;
123-
let token' = String.sub buffer 0 n in
123+
let token' = Bytes.sub_string buffer 0 n in
124124
let io_vector' = Lwt_unix.io_vector ~buffer:token' ~offset:0 ~length:(String.length token') in
125125
if token = token'
126126
then

0 commit comments

Comments
 (0)