Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
WP Plugins
Cron-Control
Commits
6770a263
Commit
6770a263
authored
Dec 12, 2016
by
Erick Hitter
Committed by
GitHub
Dec 12, 2016
Browse files
Merge pull request #72 from Automattic/develop
Fix timeouts on event-level locking
parents
928d30f0
0235f0ae
Changes
2
Hide whitespace changes
Inline
Side-by-side
includes/class-events.php
View file @
6770a263
...
...
@@ -184,7 +184,7 @@ class Events extends Singleton {
* @param $event array Event data
*/
private
function
prime_event_action_lock
(
$event
)
{
Lock
::
prime_lock
(
$this
->
get_lock_key_for_event_action
(
$event
),
JOB_LOCK_EXPIRY_IN_MINUTES
);
Lock
::
prime_lock
(
$this
->
get_lock_key_for_event_action
(
$event
),
JOB_LOCK_EXPIRY_IN_MINUTES
*
\
MINUTE_IN_SECONDS
);
}
/**
...
...
@@ -206,7 +206,7 @@ class Events extends Singleton {
}
// Limit to one concurrent execution of a specific action
if
(
!
Lock
::
check_lock
(
$this
->
get_lock_key_for_event_action
(
$event
),
1
,
JOB_LOCK_EXPIRY_IN_MINUTES
)
)
{
if
(
!
Lock
::
check_lock
(
$this
->
get_lock_key_for_event_action
(
$event
),
1
,
JOB_LOCK_EXPIRY_IN_MINUTES
*
\
MINUTE_IN_SECONDS
)
)
{
return
false
;
}
...
...
@@ -226,7 +226,7 @@ class Events extends Singleton {
}
// Reset individual event lock
Lock
::
reset_lock
(
$this
->
get_lock_key_for_event_action
(
$event
),
JOB_LOCK_EXPIRY_IN_MINUTES
);
Lock
::
reset_lock
(
$this
->
get_lock_key_for_event_action
(
$event
),
JOB_LOCK_EXPIRY_IN_MINUTES
*
\
MINUTE_IN_SECONDS
);
}
/**
...
...
includes/class-lock.php
View file @
6770a263
...
...
@@ -5,12 +5,16 @@ namespace Automattic\WP\Cron_Control;
class
Lock
{
/**
* Set a lock and limit how many concurrent jobs are permitted
*
* @param $lock string Lock name
* @param $limit int Concurrency limit
* @param $timeout int Timeout in seconds
*
* @return bool
*/
public
static
function
check_lock
(
$lock
,
$limit
=
null
,
$timeout
_in_minutes
=
null
)
{
public
static
function
check_lock
(
$lock
,
$limit
=
null
,
$timeout
=
null
)
{
// Timeout, should a process die before its lock is freed
if
(
is_numeric
(
$timeout_in_minutes
)
)
{
$timeout
=
$timeout_in_minutes
*
\
MINUTE_IN_SECONDS
;
}
else
{
if
(
!
is_numeric
(
$timeout
)
)
{
$timeout
=
LOCK_DEFULT_TIMEOUT_IN_MINUTES
*
\
MINUTE_IN_SECONDS
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment