Fix race condition in old invitation closing

This commit is contained in:
Dmitriy Simushev 2014-10-30 12:33:21 +00:00
parent b3c9a02660
commit 6e200bf956

View File

@ -21,6 +21,7 @@
use Mibew\EventDispatcher\EventDispatcher;
use Mibew\EventDispatcher\Events;
use Mibew\Database;
use Mibew\ProcessLock;
use Mibew\Settings;
use Mibew\Thread;
@ -248,6 +249,9 @@ function invitation_reject($visitor_id)
*/
function invitation_close_old()
{
// Run only one instance of cleaning process.
$lock = new ProcessLock('invitations_close_old');
if ($lock->get()) {
$db = Database::getInstance();
// Get all threads to close
@ -299,6 +303,10 @@ function invitation_close_old()
unset($thread);
}
// Release the lock
$lock->release();
}
}
/**