Date: 01/16/01
- Next message: Andi Gutmans: "RE: [PHP-DEV] Patch that corrects non blocked socket reading on W IN32"
- Previous message: Sascha Schumann: "RE: [PHP-DEV] Patch that corrects non blocked socket reading on W IN32"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Yeah but it's dangerous coding. If someone adds code to some other place in
fsock.c he could be bitten by this. I would make it obvious or by
abstraction or by #ifdef.
Andi
At 09:43 AM 1/16/2001 -0800, Christophe Thibault wrote:
>Actually, it's not that dangerous as the redefinition of errno only occurs
>in fsock.c and errno is only used in fsock.c for retrieving socket errors...
>
>-c
>
>-----Original Message-----
>From: Andi Gutmans [mailto:andi <email protected>]
>Sent: mardi 16 janvier 2001 09:48
>To: Christophe Thibault; php-dev <email protected>
>Subject: Re: [PHP-DEV] Patch that corrects non blocked socket reading on
>WIN32
>
>
>I think the code itself should be fixed (with #ifdef or add it to the
>socket abstraction). It's dangerous to redefine errno because other code
>uses it too.
>
>Andi
>
>At 01:01 PM 1/14/2001 -0800, Christophe Thibault wrote:
> >I just came across a bug still present in the latest php 4 release. i have
> >the following script:
> >
> > $g_ssock=fsockopen($server,$port,$errno,$errstr,30);
> > socket_set_blocking($g_ssock,0);
> > while(!feof($g_ssock))
> > echo fgets($g_ssock,4096);
> >
> >if you uncomment the socket_set_blocking line it will work fine on win32,
> >but with non blocking sockets, feof will always return true. by digging
> >through the code, it appears that fsock.c uses the errno() function for
> >determining any socket error as seen in function php_sockread_internal:
> >
> > } else if(nr_bytes == 0 || (nr_bytes < 0 && errno != EWOULDBLOCK))
>{
> > sock->eof = 1;
> > }
> >
> >the problem is that win32 doesn't report socket errors with _errno() but
> >with WSAGetLastError() so here is my fix:
> >
> >in fsock.c, line 46, replace:
> >
> >#ifdef PHP_WIN32
> >#include <winsock.h>
> >#else
> >
> >with:
> >
> >#ifdef PHP_WIN32
> >#include <winsock.h>
> >#undef errno
> >#define errno (WSAGetLastError())
> >#else
> >
> >and now it works like a charm :) please submit my patch to the cvs server
>so
> >i can benefit of it in the next php releases
> >
> >bye,
> >-christophe
> >
> >--
> >PHP Development Mailing List <http://www.php.net/>
> >To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
> >For additional commands, e-mail: php-dev-help <email protected>
> >To contact the list administrators, e-mail: php-list-admin <email protected>
>
>--
>PHP Development Mailing List <http://www.php.net/>
>To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
>For additional commands, e-mail: php-dev-help <email protected>
>To contact the list administrators, e-mail: php-list-admin <email protected>
-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Andi Gutmans: "RE: [PHP-DEV] Patch that corrects non blocked socket reading on W IN32"
- Previous message: Sascha Schumann: "RE: [PHP-DEV] Patch that corrects non blocked socket reading on W IN32"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

