summaryrefslogtreecommitdiffstats
path: root/otherlibs/win32unix/select.c
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2003-01-06 16:44:21 +0000
committerXavier Leroy <xavier.leroy@inria.fr>2003-01-06 16:44:21 +0000
commit424b9cf4d40da771f4d7bf346c9b95a7f272c235 (patch)
treeaa9127b10231cc937e7dc8ea8099fa907a61688b /otherlibs/win32unix/select.c
parentca7ebc2e5fc64690b2e92f7567453723fd464abc (diff)
Ajout {set,clear}_nonblock. Cas special Unix.select lorsque les 3 listes de descripteurs sont vides. Correction bug traitement d'erreur dans Unix.accept. PR#1499
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5375 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'otherlibs/win32unix/select.c')
-rw-r--r--otherlibs/win32unix/select.c51
1 files changed, 31 insertions, 20 deletions
diff --git a/otherlibs/win32unix/select.c b/otherlibs/win32unix/select.c
index 74aad826e..44930f7a7 100644
--- a/otherlibs/win32unix/select.c
+++ b/otherlibs/win32unix/select.c
@@ -57,27 +57,38 @@ CAMLprim value unix_select(value readfds, value writefds, value exceptfds, value
Begin_roots3 (readfds, writefds, exceptfds)
Begin_roots3 (read_list, write_list, except_list)
- fdlist_to_fdset(readfds, &read);
- fdlist_to_fdset(writefds, &write);
- fdlist_to_fdset(exceptfds, &except);
- tm = Double_val(timeout);
- if (tm < 0.0)
- tvp = (struct timeval *) NULL;
- else {
- tv.tv_sec = (int) tm;
- tv.tv_usec = (int) (1e6 * (tm - (int) tm));
- tvp = &tv;
- }
- enter_blocking_section();
- retcode = select(FD_SETSIZE, &read, &write, &except, tvp);
- leave_blocking_section();
- if (retcode == -1) {
- win32_maperr(WSAGetLastError());
- uerror("select", Nothing);
+ if (readfds == Val_int(0)
+ && writefds == Val_int(0)
+ && exceptfds == Val_int(0)) {
+ if ( tm > 0.0 ) {
+ enter_blocking_section();
+ Sleep( (int)(tm * 1000));
+ leave_blocking_section();
+ }
+ read_list = write_list = except_list = Val_int(0);
+ } else {
+ fdlist_to_fdset(readfds, &read);
+ fdlist_to_fdset(writefds, &write);
+ fdlist_to_fdset(exceptfds, &except);
+ tm = Double_val(timeout);
+ if (tm < 0.0)
+ tvp = (struct timeval *) NULL;
+ else {
+ tv.tv_sec = (int) tm;
+ tv.tv_usec = (int) (1e6 * (tm - (int) tm));
+ tvp = &tv;
+ }
+ enter_blocking_section();
+ retcode = select(FD_SETSIZE, &read, &write, &except, tvp);
+ leave_blocking_section();
+ if (retcode == -1) {
+ win32_maperr(WSAGetLastError());
+ uerror("select", Nothing);
+ }
+ read_list = fdset_to_fdlist(readfds, &read);
+ write_list = fdset_to_fdlist(writefds, &write);
+ except_list = fdset_to_fdlist(exceptfds, &except);
}
- read_list = fdset_to_fdlist(readfds, &read);
- write_list = fdset_to_fdlist(writefds, &write);
- except_list = fdset_to_fdlist(exceptfds, &except);
res = alloc_small(3, 0);
Field(res, 0) = read_list;
Field(res, 1) = write_list;