Browse thread
windows, threads and sockets
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Sylvain Le Gall <sylvain@l...> |
| Subject: | Re: windows, threads and sockets |
Hello, On 07-08-2009, Christoph Bauer <christoph.bauer@lmsintl.com> wrote: > >> Do you mean that the following code is wrong with 3.11.1 and >> not 3.10.2: >> >> let res_listener = Unix.select listOfSockets [] [] timeout in >> (List.nth res_listener 0) = listenSocket >> >> Can you find listenSocket in the result elsewhere ? > > No! I try to clarify: > > my check is then > > match Unix.select sockets [] [] timeout with > | (l,_,_) -> > List.iter (fun sock -> printf "%b,%b\n" (List.mem sock > sockets) (List.memq sock sockets)) l > > I only use OCaml 3.11.0. It only happens on windows. > > If I compile and link with -thread and link with ocamlfind ... -package > threads > then the result is > > false,false > > But without the thread package the result is > > true,true > Maybe, I understand the bug. I use "lpOrig = (void *)fd;" where fd is an OCaml value (in select.c). Without thread and during the enter/leave_blocking_section(), there is less chance to trigger the GC and to modify "fd" value. This is the reason why it seems correct without thread and fall into a bug with thread. The obvious solution is to replace "lpOrig = (void *)fd" by a non-OCaml value (e.g. EMode + nth in ocaml list). Could you reduce your bug to the smallest possible program and submit the bug on OCaml bug tracking ? > > BTW, I use systhreads, but the files (scheduler.c, unix.ml) I mentioned > before are used in the vmthread case. > In otherlibs\systhreads\threadUnix.ml I found > > let select = Unix.select > This remains another bug (less important) since we cannot use -vmthreads, Unix.select and pipes on windows. Regards, Sylvain Le Gall