summaryrefslogtreecommitdiff
path: root/accel-pptpd/ctrl/l2tp
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/l2tp
parent43803998812ee949cbe02a121030888c51a9aad2 (diff)
downloadaccel-ppp-369689ab48d7d213f66d338f5f090366b2bce56c.tar.gz
accel-ppp-369689ab48d7d213f66d338f5f090366b2bce56c.zip
use atomic operation on statistics update operations
Diffstat (limited to 'accel-pptpd/ctrl/l2tp')
-rw-r--r--accel-pptpd/ctrl/l2tp/l2tp.c16
1 files changed, 8 insertions, 8 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);
}