Skip to content

Commit

Permalink
Merge pull request #954 from yifsun/fix-atomic
Browse files Browse the repository at this point in the history
ip_vs_conn: A small improvement
  • Loading branch information
ywc689 authored Apr 30, 2024
2 parents f30c588 + 10ae133 commit a296c56
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/ipvs/ip_vs_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ static int dp_vs_conn_expire(void *priv)

/* refcnt == 1 means we are the only referer.
* no one is using the conn and it's timed out. */
if (rte_atomic32_read(&conn->refcnt) == 1) {
if (rte_atomic32_sub_return(&conn->refcnt, 1) == 0) {
dp_vs_conn_detach_timer(conn, false);

/* I was controlled by someone */
Expand All @@ -684,8 +684,6 @@ static int dp_vs_conn_expire(void *priv)
dp_vs_laddr_unbind(conn);
dp_vs_conn_free_packets(conn);

rte_atomic32_dec(&conn->refcnt);

#ifdef CONFIG_DPVS_IPVS_STATS_DEBUG
conn_stats_dump("del conn", conn);
#endif
Expand All @@ -696,16 +694,15 @@ static int dp_vs_conn_expire(void *priv)
dp_vs_conn_free(conn);

return DTIMER_STOP;
}

dp_vs_conn_hash(conn);
} else {
dp_vs_conn_hash(conn);

/* some one is using it when expire,
* try del it again later */
dp_vs_conn_refresh_timer(conn, false);
/* some one is using it when expire,
* try del it again later */
dp_vs_conn_refresh_timer(conn, false);

rte_atomic32_dec(&conn->refcnt);
return DTIMER_OK;
return DTIMER_OK;
}
}

void dp_vs_conn_expire_now(struct dp_vs_conn *conn)
Expand Down

0 comments on commit a296c56

Please sign in to comment.