提交 b33fa760 编写于 作者: K Kozlov Dmitry

use atomic operation on statistics update operations

上级 369689ab
......@@ -152,7 +152,7 @@ int __export establish_ppp(struct ppp_t *ppp)
triton_md_enable_handler(&ppp->unit_hnd, MD_MODE_READ);
ppp->state = PPP_STATE_STARTING;
ppp_stat.starting++;
__sync_add_and_fetch(&ppp_stat.starting, 1);
pthread_rwlock_wrlock(&ppp_lock);
list_add_tail(&ppp->entry, &ppp_list);
......@@ -184,13 +184,13 @@ static void destablish_ppp(struct ppp_t *ppp)
switch (ppp->state) {
case PPP_STATE_ACTIVE:
ppp_stat.active--;
__sync_sub_and_fetch(&ppp_stat.active, 1);
break;
case PPP_STATE_STARTING:
ppp_stat.starting--;
__sync_sub_and_fetch(&ppp_stat.starting, 1);
break;
case PPP_STATE_FINISHING:
ppp_stat.finishing--;
__sync_sub_and_fetch(&ppp_stat.finishing, 1);
break;
}
......@@ -374,8 +374,8 @@ void __export ppp_layer_started(struct ppp_t *ppp, struct ppp_layer_data_t *d)
if (n->entry.next == &ppp->layers) {
ppp->state = PPP_STATE_ACTIVE;
ppp_stat.starting--;
ppp_stat.active++;
__sync_sub_and_fetch(&ppp_stat.starting, 1);
__sync_add_and_fetch(&ppp_stat.active, 1);
ppp->ctrl->started(ppp);
triton_event_fire(EV_PPP_STARTED, ppp);
} else {
......@@ -430,10 +430,10 @@ void __export ppp_terminate(struct ppp_t *ppp, int cause, int hard)
ppp->terminating = 1;
if (ppp->state == PPP_STATE_ACTIVE)
ppp_stat.active--;
__sync_sub_and_fetch(&ppp_stat.active, 1);
else
ppp_stat.starting--;
ppp_stat.finishing++;
__sync_sub_and_fetch(&ppp_stat.starting, 1);
__sync_add_and_fetch(&ppp_stat.finishing, 1);
ppp->state = PPP_STATE_FINISHING;
log_ppp_debug("ppp_terminate\n");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册