Permalink
Browse files

[fix] build: fixed linux compilation.

Some Windows specific code was not disabled when compiling on Linux.
  • Loading branch information...
1 parent 8c6b3c5 commit e681f9efb7ff4251bbd9b6ebe38d3f3a2733d781 @shadinger committed Feb 12, 2012
Showing with 9 additions and 5 deletions.
  1. +9 −5 appruntime/connection.ml
View
@@ -67,6 +67,7 @@ let write conn ?(pos=0) buf len =
| `Ssl s -> Ssl.write s buf pos len
) 0
+#<Ifstatic:OS Win.*>
let write_async_WINDOWS conn buf len =
match NA.get_type_and_fd conn with
| `File _fd -> assert false (* Unix.write fd buf pos len *)
@@ -80,6 +81,12 @@ let write_status_WINDOWS conn =
if nread = 0 then -1
else nread
+ let write_to_async_WINDOWS conn addr buf len =
+ match NA.get_type_and_fd conn with
+ | `Udp fd -> Iocp.async_write_to fd buf len addr
+ | _ -> failwith "[Connection] write_to used on a non-UDP socket"
+#<End>
+
(* FIXME, should that really only work for UDP sockets? *)
let write_to conn addr ?(pos=0) buf len =
nonblocking_try (
@@ -89,11 +96,6 @@ let write_to conn addr ?(pos=0) buf len =
| _ -> failwith "[Connection] write_to used on a non-UDP socket"
) 0
-let write_to_async_WINDOWS conn addr buf len =
- match NA.get_type_and_fd conn with
- | `Udp fd -> Iocp.async_write_to fd buf len addr
- | _ -> failwith "[Connection] write_to used on a non-UDP socket"
-
let read_aux conn tmp to_read : int * Unix.sockaddr option =
let no_addr res = res, None in
nonblocking_try (
@@ -142,6 +144,7 @@ let read conn =
let nread, _ = read_aux conn read_buff read_buff_length in
nread, (String.sub read_buff 0 nread)
+#<Ifstatic:OS Win.*>
let read_async_WINDOWS ?(to_read=read_buff_length) conn =
(* Logger.error "read_async_WINDOWS(%d)" (Iocp.int_of_filedescr (NA.get_fd conn)); *)
Iocp.async_read (NA.get_fd conn) to_read
@@ -182,6 +185,7 @@ let read_more4_buffer_WINDOWS conn buf_in =
let nread = String.length buf in
let () = Buf.add_substring buf_in buf 0 nread in
nread, buf_in
+#<End>
exception PermissionDenied
exception UnixError

0 comments on commit e681f9e

Please sign in to comment.