php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #4827 Have flock accept LOCK_* instead of 1, 2 ...
Submitted: 2000-06-05 17:48 UTC Modified: 2000-07-05 19:31 UTC
From: juhl at eisenstein dot dk Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.0.0 Release OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: juhl at eisenstein dot dk
New email:
PHP Version: OS:

 

 [2000-06-05 17:48 UTC] juhl at eisenstein dot dk
What I'd like to see is for flock() to accept the constants LOCK_SH, LOCK_EX, LOCK_UN and LOCK_NB instead of 1, 2, 3, +4 - this is similar to how the C function behaves and makes it possible for the creators of PHP to change the values used for the different functions without affecting scripts.
Using the values 1, 2, 3, +4 is (IMHO) a mess and will lead to problems sooner or later when flock() has to be changed.

For those who do not know the C flock() function here's the meaning of the constants:

LOCK_SH = Shared  lock
LOCK_EX = Exclusive  lock
LOCK_UN = Unlock
LOCK_NB = Don't  block when locking

It would also be nice if flock() could return EWOULDBLOCK or something simmilar if nonblocking operation was requested, but the function would block. Currently there's no way to distinguish between a failed call and a call that would have blocked (in both cases false is returned).


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-06-05 19:57 UTC] rasmus at cvs dot php dot net
This has been implemented.  There is now an optional 3rd arg
to flock() which will be set to true if EWOULDBLOCK is set,
and you can now pass in the various LOCK_* constants instead
of sending actual numbers.
 [2000-07-05 19:31 UTC] juhl at eisenstein dot dk
Thank you :-)

 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Tue Jun 16 07:00:01 2026 UTC