com php-src: Fixed bug #65272: correctly set flock() out param in windows: NEWS ext/standard/file.c ext/standard/tests/file/bug65272.phpt
| From: | rdlowrey@php.net | Date: | Mon, 02 Feb 2015 15:47:54 +0000 |
| Subject: | com php-src: Fixed bug #65272: correctly set flock() out param in windows: NEWS ext/standard/file.c ext/standard/tests/file/bug65272.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-84570@lists.php.net to get a copy of this message | ||
Commit: f2f467bd9609f5fad2491a4718380fadaa449470
Author: Daniel Lowrey <rdlowrey@php.net> Mon, 2 Feb 2015 10:29:11 -0500
Parents: 9d8b1170aa03dfc6cb52cb41f24fbb9c44573d89
Branches: PHP-5.5
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f2f467bd9609f5fad2491a4718380fadaa449470
Log:
Fixed bug #65272: correctly set flock() out param in windows
Bugs:
https://bugs.php.net/65272
Changed paths:
M NEWS
M ext/standard/file.c
A ext/standard/tests/file/bug65272.phpt
Diff:
diff --git a/NEWS b/NEWS
index bcf021f..cccb8c1 100644
--- a/NEWS
+++ b/NEWS
@@ -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 c2e71d1..c15dd50 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 0000000..04a5c2d
--- /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