We cannot change it in SAPI where we are not the .exe because we don't
own the process.
Messing with that flag affects the entire process and could break
things at a higher level.

I call this kind of thing "library abuse", where one piece of code
assumes that it is the only consumer of the library.  In a modular
application, this is not the case.

I think your actual bug is elsewhere, and that the binary flag isn't
being explicitly set on a stdio file handle somewhere in the zip
library code.

I'm -1 on making this change to the other SAPI.

Incidentally, using stdio is not portable in a server application that
might have more than 255 open files at one time.  Best to use the
streams layer throughout if possible.

--Wez.

On 11/15/06, Pierre <[EMAIL PROTECTED]> wrote:
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


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to