This sounds concerning to me as a mutex-lock should be a temporary lock and in case a lock fails/expires the mutex lock should be deleted. Not sure how PHP does it, but in other languages the mutex-cleanup is automatic
Nothing to be concerned about, the mutex implementation uses
php's flock() function to lock. The flock() functions needs a resource to operate on, and that resource is given using php's fopen() function which basically creates a file if it does not exist and returns a handler to the file to be used by flock(). When flock is done with the lock, fclose() is called to close the file handle, so the lock is removed but the file remains there. Next time when a lock with same name tries to be acquired, since the file exists, it won't be created anymore, only the lock will be acquired on it. That's the explanation in simple terms, and that's why i don't see a real reason for why the lock files to be removed.
@frm.mwz - "In computer programming, a
mutex is a program object that allows multiple program threads to share the same resource, such as file access, but not simultaneously. When a program is started, a
mutex is created with a unique name."
A theoretical example is a bank application. Say the customer has $10 in his account and opens a browser window where he starts an action to withdraw $10, then he opens another one to withdraw $10 more. If he does the actions one at a time, then he withdraws $10 and in the second window when he tries again, the system is going to tell him that he has $0 left, which is what you'd expect. However, if you start both actions at the same time, chances are that the system is not able to update the fact you removed $10 in before the second request to withdraw $10 more, so in the end, you'd had $10 in your account and you'd withdraw $20, which wouldn't be nice for bank apps, would it ?
That's why we need a mutex here, so that when a request to withdraw money starts, we lock it till it ends so that no further request can ask for more money till we are done completely and we update the current account balance to show $10 less.
See this answer of mine on stackoverflow a few days ago to a similar question:
https://stackoverflow.com/questions...to-avoid-race-condition-for/44017076#44017076