timer_modify check new_expires
parent
0995f447cb
commit
5a04c1c656
|
|
@ -96,6 +96,11 @@ int fast_timer_modify(FastTimer *timer, FastTimerEntry *entry,
|
||||||
const int64_t new_expires)
|
const int64_t new_expires)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
|
if (new_expires <= timer->current_time) {
|
||||||
|
return ETIMEDOUT;
|
||||||
|
}
|
||||||
|
|
||||||
if (new_expires > entry->expires) {
|
if (new_expires > entry->expires) {
|
||||||
entry->rehash = TIMER_GET_SLOT_INDEX(timer, new_expires) !=
|
entry->rehash = TIMER_GET_SLOT_INDEX(timer, new_expires) !=
|
||||||
TIMER_GET_SLOT_INDEX(timer, entry->expires);
|
TIMER_GET_SLOT_INDEX(timer, entry->expires);
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ typedef struct fast_timer_slot {
|
||||||
typedef struct fast_timer {
|
typedef struct fast_timer {
|
||||||
int slot_count; //time wheel slot count
|
int slot_count; //time wheel slot count
|
||||||
int64_t base_time; //base time for slot 0
|
int64_t base_time; //base time for slot 0
|
||||||
int64_t current_time;
|
volatile int64_t current_time;
|
||||||
FastTimerSlot *slots;
|
FastTimerSlot *slots;
|
||||||
} FastTimer;
|
} FastTimer;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -240,6 +240,10 @@ int locked_timer_modify(LockedTimer *timer, LockedTimerEntry *entry,
|
||||||
int result;
|
int result;
|
||||||
int slot_index;
|
int slot_index;
|
||||||
|
|
||||||
|
if (new_expires <= timer->current_time) {
|
||||||
|
return ETIMEDOUT;
|
||||||
|
}
|
||||||
|
|
||||||
if (new_expires > entry->expires) {
|
if (new_expires > entry->expires) {
|
||||||
if ((result=check_entry_status(timer, entry, &slot_index)) != 0) {
|
if ((result=check_entry_status(timer, entry, &slot_index)) != 0) {
|
||||||
return result;
|
return result;
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ typedef struct locked_timer {
|
||||||
int slot_count; //time wheel slot count
|
int slot_count; //time wheel slot count
|
||||||
LockedTimerSharedLocks entry_shares; //shared locks for entry
|
LockedTimerSharedLocks entry_shares; //shared locks for entry
|
||||||
int64_t base_time; //base time for slot 0
|
int64_t base_time; //base time for slot 0
|
||||||
int64_t current_time;
|
volatile int64_t current_time;
|
||||||
LockedTimerSlot *slots;
|
LockedTimerSlot *slots;
|
||||||
} LockedTimer;
|
} LockedTimer;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue