summaryrefslogtreecommitdiff
path: root/accel-pptpd/ctrl
diff options
context:
space:
mode:
authorKozlov Dmitry <dima@server>2010-11-29 13:01:18 +0300
committerKozlov Dmitry <dima@server>2010-11-29 13:01:18 +0300
commit369689ab48d7d213f66d338f5f090366b2bce56c (patch)
treebf0f6069c201f637ca645330c7fd5b410e11b40f /accel-pptpd/ctrl
parent43803998812ee949cbe02a121030888c51a9aad2 (diff)
downloadaccel-ppp-369689ab48d7d213f66d338f5f090366b2bce56c.tar.gz
accel-ppp-369689ab48d7d213f66d338f5f090366b2bce56c.zip
use atomic operation on statistics update operations
Diffstat (limited to 'accel-pptpd/ctrl')
-rw-r--r--accel-pptpd/ctrl/l2tp/l2tp.c16
-rw-r--r--accel-pptpd/ctrl/pppoe/pppoe.c10
-rw-r--r--accel-pptpd/ctrl/pptp/pptp.c16
3 files changed, 21 insertions, 21 deletions
diff --git a/accel-pptpd/ctrl/l2tp/l2tp.c b/accel-pptpd/ctrl/l2tp/l2tp.c
index b4b7b74..d7aeae8 100644
--- a/accel-pptpd/ctrl/l2tp/l2tp.c
+++ b/accel-pptpd/ctrl/l2tp/l2tp.c
@@ -119,11 +119,11 @@ static void l2tp_disconnect(struct l2tp_conn_t *conn)
triton_timer_del(&conn->hello_timer);
if (conn->state == STATE_PPP) {
- stat_active--;
+ __sync_sub_and_fetch(&stat_active, 1);
conn->state = STATE_FIN;
ppp_terminate(&conn->ppp, TERM_USER_REQUEST, 1);
} else if (conn->state != STATE_FIN)
- stat_starting--;
+ __sync_sub_and_fetch(&stat_starting, 1);
pthread_mutex_lock(&l2tp_lock);
l2tp_conn[conn->tid] = NULL;
@@ -201,7 +201,7 @@ static void l2tp_ppp_finished(struct ppp_t *ppp)
log_ppp_debug("l2tp: ppp finished\n");
if (conn->state != STATE_FIN) {
- stat_active--;
+ __sync_sub_and_fetch(&stat_active, 1);
if (l2tp_terminate(conn, 0, 0))
triton_context_call(&conn->ctx, (triton_event_func)l2tp_disconnect, conn);
}
@@ -212,7 +212,7 @@ static void l2tp_conn_close(struct triton_context_t *ctx)
struct l2tp_conn_t *conn = container_of(ctx, typeof(*conn), ctx);
if (conn->state == STATE_PPP) {
- stat_active--;
+ __sync_sub_and_fetch(&stat_active, 1);
conn->state = STATE_FIN;
ppp_terminate(&conn->ppp, TERM_ADMIN_RESET, 1);
}
@@ -357,7 +357,7 @@ static int l2tp_tunnel_alloc(struct l2tp_serv_t *serv, struct l2tp_packet_t *pac
triton_context_call(&conn->ctx, (triton_event_func)l2tp_send_SCCRP, conn);
- stat_starting++;
+ __sync_add_and_fetch(&stat_starting, 1);
return 0;
@@ -419,8 +419,8 @@ static int l2tp_connect(struct l2tp_conn_t *conn)
if (establish_ppp(&conn->ppp))
return -1;
- stat_starting--;
- stat_active++;
+ __sync_sub_and_fetch(&stat_starting, 1);
+ __sync_add_and_fetch(&stat_active, 1);
conn->state = STATE_PPP;
@@ -835,7 +835,7 @@ static int l2tp_recv_CDN(struct l2tp_conn_t *conn, struct l2tp_packet_t *pack)
}
if (conn->state == STATE_PPP) {
- stat_active--;
+ __sync_sub_and_fetch(&stat_active, 1);
conn->state = STATE_FIN;
ppp_terminate(&conn->ppp, TERM_USER_REQUEST, 1);
}
diff --git a/accel-pptpd/ctrl/pppoe/pppoe.c b/accel-pptpd/ctrl/pppoe/pppoe.c
index daa07b7..24d2405 100644
--- a/accel-pptpd/ctrl/pppoe/pppoe.c
+++ b/accel-pptpd/ctrl/pppoe/pppoe.c
@@ -82,7 +82,7 @@ void pppoe_server_free(struct pppoe_serv_t *serv);
static void disconnect(struct pppoe_conn_t *conn)
{
if (conn->ppp_started) {
- stat_active--;
+ __sync_sub_and_fetch(&stat_active, 1);
conn->ppp_started = 0;
ppp_terminate(&conn->ppp, TERM_USER_REQUEST, 1);
}
@@ -132,7 +132,7 @@ static void ppp_finished(struct ppp_t *ppp)
log_ppp_debug("pppoe: ppp finished\n");
if (conn->ppp_started) {
- stat_active--;
+ __sync_sub_and_fetch(&stat_active, 1);
conn->ppp_started = 0;
triton_context_call(&conn->ctx, (triton_event_func)disconnect, conn);
}
@@ -546,7 +546,7 @@ static void free_delayed_pado(struct delayed_pado_t *pado)
{
triton_timer_del(&pado->timer);
- stat_delayed_pado--;
+ __sync_sub_and_fetch(&stat_delayed_pado, 1);
list_del(&pado->entry);
if (pado->host_uniq)
@@ -655,7 +655,7 @@ static void pppoe_recv_PADI(struct pppoe_serv_t *serv, uint8_t *pack, int size)
triton_timer_add(&serv->ctx, &pado->timer, 0);
list_add_tail(&pado->entry, &serv->pado_list);
- stat_delayed_pado++;
+ __sync_add_and_fetch(&stat_delayed_pado, 1);
} else
pppoe_send_PADO(serv, ethhdr->h_source, host_uniq_tag, relay_sid_tag, service_name_tag);
}
@@ -756,7 +756,7 @@ static void pppoe_recv_PADR(struct pppoe_serv_t *serv, uint8_t *pack, int size)
if (connect_channel(conn))
disconnect(conn);
else {
- stat_active++;
+ __sync_add_and_fetch(&stat_active, 1);
conn->ppp_started = 1;
}
}
diff --git a/accel-pptpd/ctrl/pptp/pptp.c b/accel-pptpd/ctrl/pptp/pptp.c
index 608be30..1523d99 100644
--- a/accel-pptpd/ctrl/pptp/pptp.c
+++ b/accel-pptpd/ctrl/pptp/pptp.c
@@ -82,11 +82,11 @@ static void disconnect(struct pptp_conn_t *conn)
triton_timer_del(&conn->echo_timer);
if (conn->state == STATE_PPP) {
- stat_active--;
+ __sync_sub_and_fetch(&stat_active, 1);
conn->state = STATE_CLOSE;
ppp_terminate(&conn->ppp, TERM_USER_REQUEST, 1);
} else if (conn->state != STATE_CLOSE)
- stat_starting--;
+ __sync_sub_and_fetch(&stat_starting, 1);
triton_event_fire(EV_CTRL_FINISHED, &conn->ppp);
@@ -329,8 +329,8 @@ static int pptp_out_call_rqst(struct pptp_conn_t *conn)
return -1;
}
conn->state = STATE_PPP;
- stat_starting--;
- stat_active++;
+ __sync_sub_and_fetch(&stat_starting, 1);
+ __sync_add_and_fetch(&stat_active, 1);
if (conn->timeout_timer.tpd)
triton_timer_del(&conn->timeout_timer);
@@ -367,7 +367,7 @@ static int pptp_call_clear_rqst(struct pptp_conn_t *conn)
log_ppp_info("recv [PPTP Call-Clear-Request <Call-ID %x>]\n", ntohs(rqst->call_id));
if (conn->state == STATE_PPP) {
- stat_active--;
+ __sync_sub_and_fetch(&stat_active, 1);
conn->state = STATE_CLOSE;
ppp_terminate(&conn->ppp, TERM_USER_REQUEST, 1);
}
@@ -549,7 +549,7 @@ static void pptp_close(struct triton_context_t *ctx)
{
struct pptp_conn_t *conn = container_of(ctx, typeof(*conn), ctx);
if (conn->state == STATE_PPP) {
- stat_active--;
+ __sync_sub_and_fetch(&stat_active, 1);
conn->state = STATE_CLOSE;
ppp_terminate(&conn->ppp, TERM_ADMIN_RESET, 1);
if (send_pptp_call_disconnect_notify(conn, 3)) {
@@ -579,7 +579,7 @@ static void ppp_finished(struct ppp_t *ppp)
if (conn->state != STATE_CLOSE) {
log_ppp_debug("pptp: ppp finished\n");
conn->state = STATE_CLOSE;
- stat_active--;
+ __sync_sub_and_fetch(&stat_active, 1);
if (send_pptp_call_disconnect_notify(conn, 3))
triton_context_call(&conn->ctx, (void (*)(void*))disconnect, conn);
@@ -667,7 +667,7 @@ static int pptp_connect(struct triton_md_handler_t *h)
triton_event_fire(EV_CTRL_STARTING, &conn->ppp);
- stat_starting++;
+ __sync_add_and_fetch(&stat_starting, 1);
}
return 0;
}