Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
aae945c3
Commit
aae945c3
authored
18 years ago
by
Steven Wittens
Browse files
Options
Downloads
Patches
Plain Diff
#70995
: Prevent cron re-runs
parent
4bd256a2
No related branches found
No related tags found
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
includes/common.inc
+45
-13
45 additions, 13 deletions
includes/common.inc
modules/system/system.install
+5
-0
5 additions, 0 deletions
modules/system/system.install
with
50 additions
and
13 deletions
includes/common.inc
+
45
−
13
View file @
aae945c3
...
@@ -1698,24 +1698,56 @@ function drupal_cron_run() {
...
@@ -1698,24 +1698,56 @@ function drupal_cron_run() {
set_time_limit
(
240
);
set_time_limit
(
240
);
}
}
// Check if the last cron run completed
// Fetch the cron semaphore
if
(
variable_get
(
'cron_busy'
,
FALSE
))
{
$semaphore
=
variable_get
(
'cron_semaphore'
,
FALSE
);
watchdog
(
'cron'
,
t
(
'Last cron run did not complete.'
),
WATCHDOG_WARNING
);
if
(
$semaphore
)
{
if
(
time
()
-
$semaphore
>
3600
)
{
// Either cron has been running for more than an hour or the semaphore
// was not reset due to a database error.
watchdog
(
'cron'
,
t
(
'Cron has been running for more than an hour and is most likely stuck.'
),
WATCHDOG_ERROR
);
// Release cron semaphore
variable_del
(
'cron_semaphore'
);
}
else
{
// Cron is still running normally.
watchdog
(
'cron'
,
t
(
'Attempting to re-run cron while it is already running.'
),
WATCHDOG_WARNING
);
}
}
}
else
{
else
{
variable_set
(
'cron_busy'
,
TRUE
);
// Register shutdown callback
}
register_shutdown_function
(
'drupal_cron_cleanup'
);
// Lock cron semaphore
variable_set
(
'cron_semaphore'
,
time
());
// Iterate through the modules calling their cron handlers (if any):
module_invoke_all
(
'cron'
);
// Iterate through the modules calling their cron handlers (if any):
// Record cron time
module_invoke_all
(
'cron'
);
variable_set
(
'cron_last'
,
time
());
watchdog
(
'cron'
,
t
(
'Cron run completed.'
),
WATCHDOG_NOTICE
);
// Clean up
// Release cron semaphore
variable_set
(
'cron_busy'
,
FALSE
);
variable_del
(
'cron_semaphore'
);
variable_set
(
'cron_last'
,
time
());
watchdog
(
'cron'
,
t
(
'Cron run completed.'
),
WATCHDOG_NOTICE
);
// Return TRUE so other functions can check if it did run successfully
// Return TRUE so other functions can check if it did run successfully
return
TRUE
;
return
TRUE
;
}
}
/**
* Shutdown function for cron cleanup.
*/
function
drupal_cron_cleanup
()
{
// See if the semaphore is still locked.
if
(
variable_get
(
'cron_semaphore'
,
FALSE
))
{
watchdog
(
'cron'
,
t
(
'Cron run exceeded the time limit and was aborted.'
),
WATCHDOG_WARNING
);
// Release cron semaphore
variable_del
(
'cron_semaphore'
);
}
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
modules/system/system.install
+
5
−
0
View file @
aae945c3
...
@@ -3337,6 +3337,11 @@ function system_update_1013() {
...
@@ -3337,6 +3337,11 @@ function system_update_1013() {
return
$ret
;
return
$ret
;
}
}
function
system_update_1014
()
{
variable_del
(
'cron_busy'
);
return
array
();
}
/**
/**
* @} End of "defgroup updates-4.7-to-x.x"
* @} End of "defgroup updates-4.7-to-x.x"
* The next series of updates should start at 2000.
* The next series of updates should start at 2000.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment