summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKozlov Dmitry <dima@server>2010-11-29 13:05:21 +0300
committerKozlov Dmitry <dima@server>2010-11-29 13:05:21 +0300
commitb33fa7609d8c58c1aa1fc219e491f46c109aa146 (patch)
tree1822d66582bd55ebf50936fcb4240684db310a65
parent369689ab48d7d213f66d338f5f090366b2bce56c (diff)
downloadaccel-ppp-b33fa7609d8c58c1aa1fc219e491f46c109aa146.tar.gz
accel-ppp-b33fa7609d8c58c1aa1fc219e491f46c109aa146.zip
use atomic operation on statistics update operations
-rw-r--r--accel-pptpd/ppp/ppp.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/accel-pptpd/ppp/ppp.c b/accel-pptpd/ppp/ppp.c
index 408383e6..4b472ff4 100644
--- a/accel-pptpd/ppp/ppp.c
+++ b/accel-pptpd/ppp/ppp.c
@@ -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");