@@ -1899,6 +1899,26 @@ io_buf_recv_yaml(php_stream *stream, struct io_buf *buf)
1899
1899
return true;
1900
1900
}
1901
1901
1902
+ /*
1903
+ * php_stream_read made right
1904
+ * See https://bugs.launchpad.net/tarantool/+bug/1182474
1905
+ */
1906
+ static size_t
1907
+ php_stream_read_real (php_stream * stream , char * buf , size_t size )
1908
+ {
1909
+ size_t total_size = 0 ;
1910
+ while (total_size < size ) {
1911
+ size_t read_size = php_stream_read (stream , buf + total_size ,
1912
+ size - total_size );
1913
+ assert (read_size <= size - total_size );
1914
+ if (read_size == 0 )
1915
+ return total_size ;
1916
+ total_size += read_size ;
1917
+ }
1918
+
1919
+ return total_size ;
1920
+ }
1921
+
1902
1922
static bool
1903
1923
io_buf_send_iproto (php_stream * stream , int32_t type , int32_t request_id , struct io_buf * buf )
1904
1924
{
@@ -1939,7 +1959,7 @@ io_buf_recv_iproto(php_stream *stream, struct io_buf *buf)
1939
1959
/* receiving header */
1940
1960
struct iproto_header header ;
1941
1961
size_t length = sizeof (struct iproto_header );
1942
- if (php_stream_read (stream , (char * ) & header , length ) != length ) {
1962
+ if (php_stream_read_real (stream , (char * ) & header , length ) != length ) {
1943
1963
zend_throw_exception_ex (zend_exception_get_default (TSRMLS_C ), 0 TSRMLS_DC ,
1944
1964
"failed to receive response: eof when "
1945
1965
"reading iproto header" );
@@ -1949,7 +1969,7 @@ io_buf_recv_iproto(php_stream *stream, struct io_buf *buf)
1949
1969
/* receiving body */
1950
1970
if (!io_buf_resize (buf , header .length ))
1951
1971
return false;
1952
- if (php_stream_read (stream , buf -> value , buf -> size ) != buf -> size ) {
1972
+ if (php_stream_read_real (stream , buf -> value , buf -> size ) != buf -> size ) {
1953
1973
zend_throw_exception_ex (zend_exception_get_default (TSRMLS_C ), 0 TSRMLS_DC ,
1954
1974
"failed to receive response: eof when "
1955
1975
"reading response body" );
0 commit comments