mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00
Implement GH-17668: zlib streams should support locking
This commit is contained in:
parent
34e1c590cb
commit
6c706c5714
2 changed files with 19 additions and 4 deletions
|
@ -1,13 +1,13 @@
|
|||
--TEST--
|
||||
Test function stream_get_meta_data on a zlib stream
|
||||
Test function flock on a zlib stream
|
||||
--EXTENSIONS--
|
||||
zlib
|
||||
--FILE--
|
||||
<?php
|
||||
$f = __DIR__."/004.txt.gz";
|
||||
$h = gzopen($f,'r');
|
||||
var_dump(flock($h, LOCK_SH));
|
||||
var_dump(flock($h, LOCK_EX));
|
||||
gzclose($h);
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(false)
|
||||
bool(true)
|
||||
|
|
|
@ -95,6 +95,21 @@ static int php_gziop_flush(php_stream *stream)
|
|||
return gzflush(self->gz_file, Z_SYNC_FLUSH);
|
||||
}
|
||||
|
||||
static int php_gziop_set_option(php_stream *stream, int option, int value, void *ptrparam)
|
||||
{
|
||||
struct php_gz_stream_data_t *self = stream->abstract;
|
||||
|
||||
switch (option) {
|
||||
case PHP_STREAM_OPTION_LOCKING:
|
||||
case PHP_STREAM_OPTION_META_DATA_API:
|
||||
return self->stream->ops->set_option(self->stream, option, value, ptrparam);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return PHP_STREAM_OPTION_RETURN_NOTIMPL;
|
||||
}
|
||||
|
||||
const php_stream_ops php_stream_gzio_ops = {
|
||||
php_gziop_write, php_gziop_read,
|
||||
php_gziop_close, php_gziop_flush,
|
||||
|
@ -102,7 +117,7 @@ const php_stream_ops php_stream_gzio_ops = {
|
|||
php_gziop_seek,
|
||||
NULL, /* cast */
|
||||
NULL, /* stat */
|
||||
NULL /* set_option */
|
||||
php_gziop_set_option /* set_option */
|
||||
};
|
||||
|
||||
php_stream *php_stream_gzopen(php_stream_wrapper *wrapper, const char *path, const char *mode, int options,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue