Browse Source

Fixed bug #65272: correctly set flock() out param in windows

pull/1063/head
Daniel Lowrey 12 years ago
parent
commit
f2f467bd96
  1. 4
      NEWS
  2. 4
      ext/standard/file.c
  3. 26
      ext/standard/tests/file/bug65272.phpt

4
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)

4
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;

26
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
Loading…
Cancel
Save