diff options
author | Daniel Lowrey <rdlowrey@php.net> | 2015-02-02 10:29:11 -0500 |
---|---|---|
committer | Daniel Lowrey <rdlowrey@php.net> | 2015-02-02 10:47:54 -0500 |
commit | f2f467bd9609f5fad2491a4718380fadaa449470 (patch) | |
tree | 1e4a137594b1fa8fcbab2bf109e4cf5ce927525a | |
parent | 9d8b1170aa03dfc6cb52cb41f24fbb9c44573d89 (diff) | |
download | php-git-f2f467bd9609f5fad2491a4718380fadaa449470.tar.gz |
Fixed bug #65272: correctly set flock() out param in windows
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | ext/standard/file.c | 4 | ||||
-rw-r--r-- | ext/standard/tests/file/bug65272.phpt | 26 |
3 files changed, 34 insertions, 0 deletions
@@ -56,6 +56,10 @@ PHP NEWS - Session: . Fixed bug #68941 (mod_files.sh is a bash-script) (bugzilla at ii.nl, Yasuo) +- Standard: + . Fixed bug #65272 (flock() out parameter not set correctly in windows). + (Daniel Lowrey) + - Streams: . Fixed bug which caused call after final close on streams filter. (Bob) diff --git a/ext/standard/file.c b/ext/standard/file.c index c2e71d1dea..c15dd50507 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -356,7 +356,11 @@ PHP_FUNCTION(flock) /* flock_values contains all possible actions if (operation & 4) we won't block on the lock */ act = flock_values[act - 1] | (operation & PHP_LOCK_NB ? LOCK_NB : 0); if (php_stream_lock(stream, act)) { +#ifdef PHP_WIN32 + if (operation && errno == ERROR_INVALID_BLOCK && arg3 && PZVAL_IS_REF(arg3)) { +#else if (operation && errno == EWOULDBLOCK && arg3 && PZVAL_IS_REF(arg3)) { +#endif Z_LVAL_P(arg3) = 1; } RETURN_FALSE; diff --git a/ext/standard/tests/file/bug65272.phpt b/ext/standard/tests/file/bug65272.phpt new file mode 100644 index 0000000000..04a5c2d5d5 --- /dev/null +++ b/ext/standard/tests/file/bug65272.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #65272: flock() correctly sets wouldblock out param in windows +--SKIPIF-- +<?php +if (stripos(PHP_OS, 'win') !== 0) die("skip windows required"); +?> +--FILE-- +<?php + +$file = dirname(__FILE__)."/flock.dat"; + +$fp1 = fopen($file, "w"); +var_dump(flock($fp1, LOCK_SH)); + +$fp2 = fopen($file, "r"); +var_dump(flock($fp2, LOCK_EX|LOCK_NB, $wouldblock)); +var_dump($wouldblock); + +@unlink($file); +echo "Done\n"; +?> +--EXPECTF-- +bool(true) +bool(false) +int(1) +Done |