Windows SAPI possible binary file operation bug and possible fix

From: Date: Wed, 15 Nov 2006 16:07:24 +0000
Subject: Windows SAPI possible binary file operation bug and possible fix
Groups: php.internals 
Request: Send a blank email to internals+get-26606@lists.php.net to get a copy of this message
Hello, While debugging a zip bug (http://pecl.php.net/bugs/bug.php?id=9278), I was wondering what's the difference between CLI/CGI and ISAPI or Apache2. The same code works perfectly in CLI and CGI on windows and using all SAPIs on linux (apache1 or 2, cli, cgi). It was not that obvious, even after having read the MS manual. The problem seems to be the default mode for the file operation and the binary mode being ignored by windows ("rb" or "wb"). We only force the default mode in Embed, CLI and CGI. I would suggest to do it as well in all SAPIs:
./sapi/cgi/cgi_main.c:1042:     _fmode = _O_BINARY; /* sets default
for file streams to binary */
./sapi/cli/php_cli.c:626:       _fmode = _O_BINARY;
/*sets default for file streams to binary */ ./sapi/embed/php_embed.c:157: _fmode = _O_BINARY; /*sets default for file streams to binary */ _fmode is global per process. We should set the mode of stdin/out: _setmode( _fileno( stdin ), _O_BINARY ); If we need it and if it is already opened when we init the SAPI, but someone has to verify this point. I do not have the time to test it now, but it should also solve a couple of other issues in HEAD. I can write a patch and commit if we agree on this fix. Thanks for your upcoming comments, --Pierre [1] http://msdn2.microsoft.com/en-us/library/z5hh6ee9(VS.80).aspx

« previous php.internals (#26606) next »