diff --git a/HISTORY.md b/HISTORY.md index 81718ed3..8ad3a0f8 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,9 @@ +v0.5.1 (2014-8-4) +----------- +* Bugfix : http module +* Bugfix : multicast local channel delete +* Bugfix : socket.read(fd) + v0.5.0 (2014-7-28) ----------- * skynet.exit will quit service immediately. diff --git a/skynet-src/skynet_main.c b/skynet-src/skynet_main.c index 4eb18a59..fce5debb 100644 --- a/skynet-src/skynet_main.c +++ b/skynet-src/skynet_main.c @@ -89,7 +89,6 @@ static const char * load_config = "\ local code = assert(f:read \'*a\')\ local function getenv(name) return assert(os.getenv(name), name) end\ code = string.gsub(code, \'%$([%w_%d]+)\', getenv)\ - print(code)\ f:close()\ local result = {}\ assert(load(code,\'=(load)\',\'t\',result))()\ diff --git a/skynet-src/skynet_timer.c b/skynet-src/skynet_timer.c index 3cd0c51d..3d0421a9 100644 --- a/skynet-src/skynet_timer.c +++ b/skynet-src/skynet_timer.c @@ -9,6 +9,7 @@ #include #include #include +#include #if defined(__APPLE__) #include @@ -33,7 +34,7 @@ struct timer_event { struct timer_node { struct timer_node *next; - int expire; + uint32_t expire; }; struct link_list { @@ -43,9 +44,9 @@ struct link_list { struct timer { struct link_list near[TIME_NEAR]; - struct link_list t[4][TIME_LEVEL-1]; + struct link_list t[4][TIME_LEVEL]; int lock; - int time; + uint32_t time; uint32_t current; uint32_t starttime; uint64_t current_point; @@ -72,21 +73,22 @@ link(struct link_list *list,struct timer_node *node) { static void add_node(struct timer *T,struct timer_node *node) { - int time=node->expire; - int current_time=T->time; + uint32_t time=node->expire; + uint32_t current_time=T->time; if ((time|TIME_NEAR_MASK)==(current_time|TIME_NEAR_MASK)) { link(&T->near[time&TIME_NEAR_MASK],node); } else { int i; - int mask=TIME_NEAR << TIME_LEVEL_SHIFT; + uint32_t mask=TIME_NEAR << TIME_LEVEL_SHIFT; for (i=0;i<3;i++) { if ((time|(mask-1))==(current_time|(mask-1))) { break; } mask <<= TIME_LEVEL_SHIFT; } - link(&T->t[i][((time>>(TIME_NEAR_SHIFT + i*TIME_LEVEL_SHIFT)) & TIME_LEVEL_MASK)-1],node); + + link(&T->t[i][((time>>(TIME_NEAR_SHIFT + i*TIME_LEVEL_SHIFT)) & TIME_LEVEL_MASK)],node); } } @@ -103,29 +105,38 @@ timer_add(struct timer *T,void *arg,size_t sz,int time) { UNLOCK(T); } +static void +move_list(struct timer *T, int level, int idx) { + struct timer_node *current = link_clear(&T->t[level][idx]); + while (current) { + struct timer_node *temp=current->next; + add_node(T,current); + current=temp; + } +} + static void timer_shift(struct timer *T) { LOCK(T); int mask = TIME_NEAR; - int time = (++T->time) >> TIME_NEAR_SHIFT; - int i=0; - - while ((T->time & (mask-1))==0) { - int idx=time & TIME_LEVEL_MASK; - if (idx!=0) { - --idx; - struct timer_node *current = link_clear(&T->t[i][idx]); - while (current) { - struct timer_node *temp=current->next; - add_node(T,current); - current=temp; + uint32_t ct = ++T->time; + if (ct == 0) { + move_list(T, 3, 0); + } else { + uint32_t time = ct >> TIME_NEAR_SHIFT; + int i=0; + + while ((ct & (mask-1))==0) { + int idx=time & TIME_LEVEL_MASK; + if (idx!=0) { + move_list(T, i, idx); + break; } - break; + mask <<= TIME_LEVEL_SHIFT; + time >>= TIME_LEVEL_SHIFT; + ++i; } - mask <<= TIME_LEVEL_SHIFT; - time >>= TIME_LEVEL_SHIFT; - ++i; - } + } UNLOCK(T); } @@ -187,7 +198,7 @@ timer_create_timer() { } for (i=0;i<4;i++) { - for (j=0;jt[i][j]); } } @@ -265,6 +276,7 @@ skynet_updatetime(void) { uint64_t cp = gettime(); if(cp < TI->current_point) { skynet_error(NULL, "time diff error: change from %lld to %lld", cp, TI->current_point); + TI->current_point = cp; } else if (cp != TI->current_point) { uint32_t diff = (uint32_t)(cp - TI->current_point); TI->current_point = cp;