From: zabmilenko at charter dot net Operating system: WinXP PHP version: 5.1.2 PHP Bug Type: Feature/Change Request Bug description: Block-level Semaphore Locking
Description: ------------ Currently, the sysvsem library is used for semaphore locking. I am proposing to integrate this functionality directly into php using a block-level statement: sem (420) { // Locked stuff here } The idea is that any code present inside the sem{} block will be guaranteed by php to be executed alone. 420 is the lock to set or wait for. Execution can be halted before the end of the sem block using the break; statement, as well as return, die, exit, or any other statement that moves execution outside of the block. As soon as execution leaves, the semaphore is instantly released. Naturally, nesting a lock is redundant but nevertheless could serve a purpose. If a nested lock is detected, a warning should be generated. This functionality would be minimalistic, but powerful and elegant when compared to the sysvsem library. If your imagination is wandering, then a radical idea would be setting a timeout or even a lock-count limit using parameters separated by ; (like a for() block). Anyways, my suggestion is a sem block. Have a nice day. Reproduce code: --------------- sem (0x2243) { // open a file // write a line // close the file } Expected result: ---------------- The first process will lock semaphore 0x2243 and attempt to write a line to a file. Any concurrent attempts will be delayed until the first process reaches leaves the sem block. Actual result: -------------- I get a parse error because my idea is still only in my head. -- Edit bug report at http://bugs.php.net/?id=36541&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=36541&r=trysnapshot44 Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=36541&r=trysnapshot51 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=36541&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=36541&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=36541&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=36541&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=36541&r=needscript Try newer version: http://bugs.php.net/fix.php?id=36541&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=36541&r=support Expected behavior: http://bugs.php.net/fix.php?id=36541&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=36541&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=36541&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=36541&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=36541&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=36541&r=dst IIS Stability: http://bugs.php.net/fix.php?id=36541&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=36541&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=36541&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=36541&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=36541&r=mysqlcfg