提交 5a04c1c6 编写于 作者: Y YuQing

timer_modify check new_expires

上级 0995f447
......@@ -96,6 +96,11 @@ int fast_timer_modify(FastTimer *timer, FastTimerEntry *entry,
const int64_t new_expires)
{
int result;
if (new_expires <= timer->current_time) {
return ETIMEDOUT;
}
if (new_expires > entry->expires) {
entry->rehash = TIMER_GET_SLOT_INDEX(timer, new_expires) !=
TIMER_GET_SLOT_INDEX(timer, entry->expires);
......
......@@ -36,7 +36,7 @@ typedef struct fast_timer_slot {
typedef struct fast_timer {
int slot_count; //time wheel slot count
int64_t base_time; //base time for slot 0
int64_t current_time;
volatile int64_t current_time;
FastTimerSlot *slots;
} FastTimer;
......
......@@ -240,6 +240,10 @@ int locked_timer_modify(LockedTimer *timer, LockedTimerEntry *entry,
int result;
int slot_index;
if (new_expires <= timer->current_time) {
return ETIMEDOUT;
}
if (new_expires > entry->expires) {
if ((result=check_entry_status(timer, entry, &slot_index)) != 0) {
return result;
......
......@@ -58,7 +58,7 @@ typedef struct locked_timer {
int slot_count; //time wheel slot count
LockedTimerSharedLocks entry_shares; //shared locks for entry
int64_t base_time; //base time for slot 0
int64_t current_time;
volatile int64_t current_time;
LockedTimerSlot *slots;
} LockedTimer;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册