Re: Antwort: Bug #1695 Updated: fgets read to few data (1 byte)

From: Date: Thu, 01 Jan 1970 00:00:00 +0000
Subject: Re: Antwort: Bug #1695 Updated: fgets read to few data (1 byte)
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-8392@lists.php.net to get a copy of this message
> OK, sorry - the problem is more difficult. I am reading and writing binary > data from a socket based server (no LF and no EOF > between the requests). The latest version doing it was php3.0.6. Then we > try php3.0.9 where this application did not work. > Before i try to find out whats going wrong there is php3.0.11 available and > we test it. same problem. Now we have to > read n+1 byte (this has changed) in fgets. This work fine for the first m > requests, but the last request sleep forever. So i start > debugging (its not easy to find a small example to send you). The problem > is the buffered io in blocked sockets. If we want > to read the last x < 512 bytes, from socket and the bytes are always in the > buffer, php try to wait for data with funktion > _php_sock_wait_for_data() ! > In funktion _php3_sock_fgets the nr_toread did cause the bug. Firs it try > _php3_sock_read_limited( sock, 0) whitch return zero. > Next it try _php3_sock_read_limited( sock, 512). This end in > _php_sock_wait_for_data(). But all data are available in the buffer and > the server will not send any more bytes! > > there is no need for nr_toread. replace line 600 in file functions/fsock.c: > > < nr_read += _php3_sock_read_limited( sock, nr_toread); > > nr_read += _php3_sock_read_limited( sock, maxlen); > > i am no nativ speaker, but i hope you will understand the problem. If not, > i try to make a sample. Could you test it with the current cvs version and let us know if it clears anything up? See http://cvs.php.net -Rasmus

« previous php.dev (#8392) next »