[MLton-devel] Regression of 20030502 ?

Matthew Fluet fluet@cs.cornell.edu
Tue, 10 Jun 2003 13:35:32 -0400 (EDT)


> We have witnessed a regression (or at least a semantic change) of
> 20030502 wrt 20030312 : the behaviour in -basis 1997 mode differs in the
> following scenario:
>
>     1) start a server which listen on a socket;
>     2) accept a connection;
>     3) apply canInput on the corresponding instream.
>
> The newer MLton does not seem to wait, and the corresponding canInput
> says that nothing is available, with errno=11, as if the instream
> generated from the accept() call had been opened in nonblocking mode.
> Looking at the cvs diffs, I was wondering if it could arise from the
> activation of the new IO.
>
> Thanks for your help.


There was a semantic change, for the better; or, at least more closely
conforming to the Basis specification.  The Basis specifies:

 canInput (strm, n)
    returns NONE if any attempt at input would block. Returns SOME k,
    where 0 <= k <= n, if a call to input would return immediately with at
    least k characters. Note that k = 0 corresponds to the stream being at
    end-of-stream.

The old IO implementation of canInput had the comment:
(* not entirely correct - really needs to do non blocking lookahead *)
and would block if no input were available.  Inspection of the code shows
that canInput would never return NONE.

The new IO implementation will never block; hence will always return
"immediately" (modulo the time to copy available input to the ML
buffer) and return NONE when a call to input would block.

I suspect that the behavior you are seeing is that canInput is returning
NONE whereas before it was returning SOME k.  If the behavior you are
looking for is block until N characters are available for input, I think
you will need to synthesize that with an inputN loop.

Hope that explains it.  If not, we can take a look at the code.



-------------------------------------------------------
This SF.net email is sponsored by:  Etnus, makers of TotalView, The best
thread debugger on the planet. Designed with thread debugging features
you've never dreamed of, try TotalView 6 free at www.etnus.com.
_______________________________________________
MLton-devel mailing list
MLton-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlton-devel