httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dean Gaudet <dgau...@arctic.org>
Subject Re: Win32 16k problem nailed!
Date Wed, 12 Nov 1997 20:29:46 GMT
On a similar topic ... I seem to recall someone here saying listen() 
limits you to a backlog of 5 under win32 including NT... and that the only
way around this was to use completion ports, which requires a complete
revamp of how you do I/O.  Which also happens to fix the below problem. 

But definately isn't an easy thing to do for someone just wanting to port
a unix app. 

Dean

On Wed, 12 Nov 1997, Ben Laurie wrote:

> OK, I've now traced the cause of the problem, and fixed it.
> 
> Executive summary: Win32 select() is broken.
> 
> Full story: Because there's no such thing as alarm() on Windoze, doing
> timeouts on read()s and write()s must be simulated. The strategy
> employed is as follows (this may not be the best way of doing, but its
> what we've got at the moment):
> 
> 1. put socket in non-blocking mode.
> 2. attempt the write
> 3. if the write succeeds, we're done.
> 4. select on the socket, with timeout set to remaining time
> 5. write again
> 
> What happens is that sometimes, on some machines, the select returns
> with write available, _but_ the write (at step 5) still says it will
> block. Now, I thought at first that this could be correct - all select
> is saying is that it can write a single byte to the socket, but we are
> (typically) attempting to write 8k. So, I wrapped the write in a loop
> that tried successively smaller amounts. I thought this should have
> fixed the problem, but didn't - it gets all the way down to 1 byte and
> _still_ fails. So, I added another loop - if we get down to 1 byte,
> sleep for 100 milliseconds, and try again. This works.
> 
> Further thought, and manual reading, says that the "step down the size"
> strategy should not be needed - if there is insufficient space for the
> whole buffer, a partial write should occur. So, I'll eliminate that,
> leave in the retry loop, go for one more test, and commit. I'll leave a
> logging message warning that Windoze is broken.
> 
> Cheers,
> 
> Ben.
> 
> 
> -- 
> Ben Laurie            |Phone: +44 (181) 735 0686|Apache Group member
> Freelance Consultant  |Fax:   +44 (181) 735 0689|http://www.apache.org
> and Technical Director|Email: ben@algroup.co.uk |Apache-SSL author
> A.L. Digital Ltd,     |http://www.algroup.co.uk/Apache-SSL
> London, England.      |"Apache: TDG" http://www.ora.com/catalog/apache
> 

Mime
View raw message