diff --git a/include/proto/session.h b/include/proto/session.h index d54e9454b..0b7d08d99 100644 --- a/include/proto/session.h +++ b/include/proto/session.h @@ -62,7 +62,8 @@ static inline void session_store_counters(struct session *sess) if (ptr) { HA_RWLOCK_WRLOCK(STK_SESS_LOCK, &ts->lock); - stktable_data_cast(ptr, conn_cur)--; + if (stktable_data_cast(ptr, conn_cur) > 0) + stktable_data_cast(ptr, conn_cur)--; HA_RWLOCK_WRUNLOCK(STK_SESS_LOCK, &ts->lock); diff --git a/include/proto/stream.h b/include/proto/stream.h index f44820977..a8c299214 100644 --- a/include/proto/stream.h +++ b/include/proto/stream.h @@ -103,7 +103,8 @@ static inline void stream_store_counters(struct stream *s) if (ptr) { HA_RWLOCK_WRLOCK(STK_SESS_LOCK, &ts->lock); - stktable_data_cast(ptr, conn_cur)--; + if (stktable_data_cast(ptr, conn_cur) > 0) + stktable_data_cast(ptr, conn_cur)--; HA_RWLOCK_WRUNLOCK(STK_SESS_LOCK, &ts->lock); @@ -141,7 +142,8 @@ static inline void stream_stop_content_counters(struct stream *s) if (ptr) { HA_RWLOCK_WRLOCK(STK_SESS_LOCK, &ts->lock); - stktable_data_cast(ptr, conn_cur)--; + if (stktable_data_cast(ptr, conn_cur) > 0) + stktable_data_cast(ptr, conn_cur)--; HA_RWLOCK_WRUNLOCK(STK_SESS_LOCK, &ts->lock);