diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 2010-05-25 13:01:06 +0000 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 2010-05-25 13:01:06 +0000 |
commit | 734b8051613d689f7f45962c78f7681ada21d320 (patch) | |
tree | b30a2c6d758b212af4056d397264e9c19994b98a /otherlibs/win32unix/unixsupport.h | |
parent | e671780b01a86ad3f126017e814d126b8e4df1f9 (diff) |
Patch provided by Sylvain Le Gall:
- Fix #4894: Windows (mingw): Unix.select and non-blocking sockets,
add a filedescr.flags_fd in win32unix/unixsupport.h. It contains the
non-blocking status of the associated filedescr and helps to restore
this status after a select.
- Fix #4789: Windows: Unix.select failing with EPIPE error,
Apply patch provided by J. Vouillon
- Fix #4973: Failure "Unknown handle",
Be consistent between Windows and Linux, raise an EBADF Unix_error
for a closed pipe handle.
- Fix #4844: Unix.select bug (triggered if linked against threads),
Apply patch by C. Bauer, replace lpOrig by lpOrigIdx which can survive
a GC collection
For otherlibs/win32unix/{select|windbug}.c:
- Remove Heap* fucntions to allocate/free memory and replace it by
caml_stat_* function, which are more OCaml compliant
- Rework DBUG message, use DEBUG_PRINT rather than #ifdef DBUG... #endif
and use DEBUG variable (more OCaml compliant), also remove dbug_init
functions and use a static variable to replace it (subject to race
condition but this not really important, because every path lead to
same initialization)
- Use a fast start scheme for pipe polling, rather than always waiting
10ms, start by 1, 2, 4, 8 and then 10ms. The 4 first times give select
a chance to a fast answer.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@10467 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'otherlibs/win32unix/unixsupport.h')
-rw-r--r-- | otherlibs/win32unix/unixsupport.h | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/otherlibs/win32unix/unixsupport.h b/otherlibs/win32unix/unixsupport.h index bf71ac6dc..d56158304 100644 --- a/otherlibs/win32unix/unixsupport.h +++ b/otherlibs/win32unix/unixsupport.h @@ -26,15 +26,17 @@ struct filedescr { union { HANDLE handle; SOCKET socket; - } fd; + } fd; /* Real windows handle */ enum { KIND_HANDLE, KIND_SOCKET } kind; - int crt_fd; + int crt_fd; /* C runtime descriptor */ + unsigned int flags_fd; /* See FLAGS_FD_* */ }; #define Handle_val(v) (((struct filedescr *) Data_custom_val(v))->fd.handle) #define Socket_val(v) (((struct filedescr *) Data_custom_val(v))->fd.socket) #define Descr_kind_val(v) (((struct filedescr *) Data_custom_val(v))->kind) #define CRT_fd_val(v) (((struct filedescr *) Data_custom_val(v))->crt_fd) +#define Flags_fd_val(v) (((struct filedescr *) Data_custom_val(v))->flags_fd) /* extern value win_alloc_handle_or_socket(HANDLE); */ extern value win_alloc_handle(HANDLE); @@ -50,4 +52,11 @@ extern void unix_error (int errcode, char * cmdname, value arg); extern void uerror (char * cmdname, value arg); extern value unix_freeze_buffer (value); +/* Information stored in flags_fd, describing more precisely the socket + * and its status. The whole flags_fd is initialized to 0. + */ + +/* Blocking or nonblocking. By default a filedescr is in blocking state */ +#define FLAGS_FD_IS_BLOCKING (1<<0) + #define UNIX_BUFFER_SIZE 16384 |