File tree 1 file changed +19
-6
lines changed
1 file changed +19
-6
lines changed Original file line number Diff line number Diff line change 21
21
* 02111-1307, USA.
22
22
*)
23
23
24
+ let (>> = ) = Lwt. bind
25
+
24
26
type t =
25
27
Plain
26
28
| SSL of Ssl .socket
@@ -150,12 +152,6 @@ let wait_write (fd, s) =
150
152
Plain -> Lwt_unix. wait_write fd
151
153
| SSL _ -> Lwt_unix. yield ()
152
154
153
- let out_channel_of_descr s =
154
- Lwt_io. make ~mode: Lwt_io. output (fun buf pos len -> write_bytes s buf pos len)
155
-
156
- let in_channel_of_descr s =
157
- Lwt_io. make ~mode: Lwt_io. input (fun buf pos len -> read_bytes s buf pos len)
158
-
159
155
let ssl_shutdown (fd , s ) =
160
156
match s with
161
157
Plain -> Lwt. return ()
@@ -167,6 +163,23 @@ let close (fd, _) = Lwt_unix.close fd
167
163
168
164
let abort (fd , _ ) = Lwt_unix. abort fd
169
165
166
+ let shutdown_and_close s =
167
+ ssl_shutdown s >> = fun () ->
168
+ Lwt. wrap2 shutdown s Unix. SHUTDOWN_ALL >> = fun () ->
169
+ close s
170
+
171
+ let out_channel_of_descr s =
172
+ Lwt_io. make
173
+ ~mode: Lwt_io. output
174
+ ~close: (fun () -> shutdown_and_close s)
175
+ (fun buf pos len -> write_bytes s buf pos len)
176
+
177
+ let in_channel_of_descr s =
178
+ Lwt_io. make
179
+ ~mode: Lwt_io. input
180
+ ~close: (fun () -> shutdown_and_close s)
181
+ (fun buf pos len -> read_bytes s buf pos len)
182
+
170
183
let get_fd (fd ,socket ) =
171
184
match socket with
172
185
| Plain -> Lwt_unix. unix_file_descr fd
You can’t perform that action at this time.
0 commit comments