From f2f467bd9609f5fad2491a4718380fadaa449470 Mon Sep 17 00:00:00 2001 From: Daniel Lowrey Date: Mon, 2 Feb 2015 10:29:11 -0500 Subject: Fixed bug #65272: correctly set flock() out param in windows --- NEWS | 4 ++++ ext/standard/file.c | 4 ++++ ext/standard/tests/file/bug65272.phpt | 26 ++++++++++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 ext/standard/tests/file/bug65272.phpt diff --git a/NEWS b/NEWS index bcf021f528..cccb8c1694 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 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-- + +--FILE-- + +--EXPECTF-- +bool(true) +bool(false) +int(1) +Done -- cgit v1.2.1