@@ -249,6 +249,7 @@ static int _php_stream_free_persistent(zval *zv, void *pStream)
249249 return le -> ptr == pStream ;
250250}
251251
252+ static int php_stream_flush_ex (php_stream * stream , bool closing );
252253
253254PHPAPI int php_stream_free (php_stream * stream , int close_options ) /* {{{ */
254255{
@@ -336,7 +337,7 @@ fprintf(stderr, "stream_free: %s:%p[%s] preserve_handle=%d release_cast=%d remov
336337
337338 if (stream -> flags & PHP_STREAM_FLAG_WAS_WRITTEN || stream -> writefilters .head ) {
338339 /* make sure everything is saved */
339- _php_stream_flush (stream , 1 );
340+ php_stream_flush_ex (stream , true );
340341 }
341342
342343 /* If not called from the resource dtor, remove the stream from the resource list. */
@@ -1183,7 +1184,7 @@ static ssize_t php_stream_write_filtered(php_stream *stream, const char *buf, si
11831184 return consumed ;
11841185}
11851186
1186- PHPAPI int _php_stream_flush (php_stream * stream , int closing )
1187+ static int php_stream_flush_ex (php_stream * stream , bool closing )
11871188{
11881189 int ret = 0 ;
11891190
@@ -1200,6 +1201,10 @@ PHPAPI int _php_stream_flush(php_stream *stream, int closing)
12001201 return ret ;
12011202}
12021203
1204+ PHPAPI int php_stream_flush (php_stream * stream ) {
1205+ return php_stream_flush_ex (stream , false);
1206+ }
1207+
12031208PHPAPI ssize_t php_stream_write (php_stream * stream , const char * buf , size_t count )
12041209{
12051210 ssize_t bytes ;
@@ -1324,7 +1329,7 @@ PHPAPI int php_stream_seek(php_stream *stream, zend_off_t offset, int whence)
13241329 bool is_start_seeking = whence == SEEK_SET && offset == 0 ;
13251330
13261331 if (stream -> writefilters .head ) {
1327- _php_stream_flush (stream , 0 );
1332+ php_stream_flush (stream );
13281333 if (!php_stream_are_filters_seekable (stream -> writefilters .head , is_start_seeking ,
13291334 PHP_STREAM_FILTER_WRITE )) {
13301335 return -1 ;
0 commit comments