function node_import_lock_acquire in Node import 6
Acquire or release our node_import lock.
Parameters
$release: Boolean. If TRUE, release the lock. If FALSE, acquire the lock.
Return value
Boolean. Whether the lock was acquired.
Related topics
2 calls to node_import_lock_acquire()
- node_import_do_task in ./
node_import.inc - Import a number of rows from the specified task. Should only be called from within hook_cron() or from a JS callback as this function may take a long time.
- node_import_lock_release in ./
node_import.inc - Release our node_import lock.
File
- ./
node_import.inc, line 2187 - Public API of the Node import module.
Code
function node_import_lock_acquire($release = FALSE) {
static $lock_id, $locked;
if (!isset($lock_id)) {
$lock_id = md5(uniqid());
$locked = FALSE;
register_shutdown_function('node_import_lock_release');
}
if ($release) {
db_query("DELETE FROM {variable} WHERE name = '%s'", 'node_import:lock');
$locked = FALSE;
}
else {
if (!$locked) {
if (@db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", 'node_import:lock', $lock_id)) {
$locked = TRUE;
}
}
}
return $locked;
}