Re: MLton sockets and threads
Matthew Fluet <[email protected]> Mon, 22 Apr 2013 21:27:46 -0400
| Newsgroups | gmane.comp.lang.ml.mlton.devel |
|---|---|
| Message-ID | <CAMrhFL4bRRm1_WVYFMDxOY5UdLV1a1=Doyh-=5=emzmy7O7EAw@mail.gmail.com> |
On Sun, Apr 21, 2013 at 8:45 PM, Karl Crary <[email protected]> wrote: > I'm trying to port some code from SML/NJ to MLton, and I've run into some > troubles. I'm using Internet sockets and threads together (sockets and CML > actually), and the Windows version doesn't seem to like that. I'm getting > an exception: > > SysErr: Interrupted system call [intr] > > from the Socket.connect call. If I turn up the timeslice really high, > then I can get a few connections through before this happens. > > The strange thing is I'm doing this in an atomic block. I tried both > MLton.Thread.atomically, and ML.Thread.atomicBegin/**atomicEnd. Also, > MLton.Signal.restart is set to true. So my understanding is this should > not be happening. > > I even tried blocking every signal (MLton.Signal.Mask.block > MLton.Signal.Mask.all) and it still didn't help. I also tried both the > regular Windows version and the Cygwin version, with no difference. > > Any ideas? Sounds like you've tried all of the things that immediately come to mind. MLton.Thread.atomically simply instructs the runtime system not to switch to the signal handler thread (and, therefore, never to execute the ML-side thread scheduler) for the duration of the atomic section; it doesn't suppress the signal itself, so I could see the system call being interrupted. However, it looks like the Socket.connect is being wrapped by a Syscall.simple, rather than a Syscall.simpleRestart, so it is not being automatically restarted when it returns EINTR. You could try changing <root>/lib/mlton/sml/basis-library/net/socket.sml at line #271. (You don't need to rebuild the compiler.) However, as you say, I would have expected blocking all signals to avoid the interruption. On the other hand, it has always seemed that a lot of the posix emulation in Cygwin/MinGW can lead to non-intuitive behavior. I also note that http://mlton.org/RunningOnCygwin states that the socket.sml regression fails. Have you tried the code on a *NIX? ------------------------------------------------------------------------------ Precog is a next-generation analytics platform capable of advanced analytics on semi-structured data. The platform includes APIs for building apps and a phenomenal toolset for data science. Developers can use our toolset for easy data analysis & visualization. Get a free account! http://www2.precog.com/precogplatform/slashdotnewsletter _______________________________________________ MLton-devel mailing list [email protected]; [email protected] https://lists.sourceforge.net/lists/listinfo/mlton-devel