Skip to content

Commit b972cbf

Browse files
committed
Add todo notes to file.c flock
1 parent 5484b8d commit b972cbf

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ext/standard/file.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,9 @@ PHP_FUNCTION(flock)
344344

345345
PHP_STREAM_TO_ZVAL(stream, res);
346346

347-
act = operation & 3;
347+
act = operation & PHP_LOCK_UN;
348+
// TODO doesn't this fail if operation is a bitmask with LOCK_NB?
349+
//if (act != PHP_LOCK_SH && act != PHP_LOCK_EX && act != PHP_LOCK_UN) {
348350
if (act < 1 || act > 3) {
349351
zend_argument_value_error(2, "must be either LOCK_SH, LOCK_EX, or LOCK_UN");
350352
RETURN_THROWS();
@@ -354,7 +356,7 @@ PHP_FUNCTION(flock)
354356
ZEND_TRY_ASSIGN_REF_LONG(wouldblock, 0);
355357
}
356358

357-
/* flock_values contains all possible actions if (operation & 4) we won't block on the lock */
359+
/* flock_values contains all possible actions if (operation & PHP_LOCK_NB) we won't block on the lock */
358360
act = flock_values[act - 1] | (operation & PHP_LOCK_NB ? LOCK_NB : 0);
359361
if (php_stream_lock(stream, act)) {
360362
if (operation && errno == EWOULDBLOCK && wouldblock) {

0 commit comments

Comments
 (0)