uint64_t htp_config_memcap = 0;
SC_ATOMIC_DECLARE(uint64_t, htp_memuse);
+SC_ATOMIC_DECLARE(uint64_t, htp_memcap);
void HTPParseMemcap()
{
void HTPMemuseCounter(ThreadVars *tv, TcpReassemblyThreadCtx *trt)
{
- uint64_t memusecopy = SC_ATOMIC_GET(htp_memuse);
- SCPerfCounterSetUI64(trt->counter_htp_memuse, tv->sc_perf_pca, memusecopy);
+ uint64_t tmpval = SC_ATOMIC_GET(htp_memuse);
+ SCPerfCounterSetUI64(trt->counter_htp_memuse, tv->sc_perf_pca, tmpval);
+ tmpval = SC_ATOMIC_GET(htp_memcap);
+ SCPerfCounterSetUI64(trt->counter_htp_memcap, tv->sc_perf_pca, tmpval);
return;
}
/**
{
if (htp_config_memcap == 0 || size + SC_ATOMIC_GET(htp_memuse) <= htp_config_memcap)
return 1;
+ (void) SC_ATOMIC_ADD(htp_memcap, 1);
return 0;
}
/** account memory usage by suricata to handle HTTP protocol (not counting
* libhtp memory usage)*/
uint16_t counter_htp_memuse;
+ /* number of allocation failed due to memcap when handling HTTP protocol */
+ uint16_t counter_htp_memcap;
} TcpReassemblyThreadCtx;
#define OS_POLICY_DEFAULT OS_POLICY_BSD
stt->ra_ctx->counter_htp_memuse = SCPerfTVRegisterCounter("http.memuse", tv,
SC_PERF_TYPE_UINT64,
"NULL");
+ stt->ra_ctx->counter_htp_memcap = SCPerfTVRegisterCounter("http.memcap", tv,
+ SC_PERF_TYPE_UINT64,
+ "NULL");
SCLogDebug("StreamTcp thread specific ctx online at %p, reassembly ctx %p",
stt, stt->ra_ctx);