/** never prune a host that is used by a packet
* we are currently processing in one of the threads */
- if (h->use_cnt > 0) {
+ if (SC_ATOMIC_GET(h->use_cnt) > 0) {
return 0;
}
memset(h, 0x00, sizeof(Host));
SCMutexInit(&h->m, NULL);
+ SC_ATOMIC_INIT(h->use_cnt);
return h;
error:
ThresholdListFree(h->threshold);
h->threshold = NULL;
}
+ SC_ATOMIC_DESTROY(h->use_cnt);
}
#define HOST_DEFAULT_HASHSIZE 4096
/* free spare queue */
while((h = HostDequeue(&host_spare_q))) {
- BUG_ON(h->use_cnt > 0);
+ BUG_ON(SC_ATOMIC_GET(h->use_cnt) > 0);
HostFree(h);
}
}
#define HostIncrUsecnt(h) \
- (h)->use_cnt++
+ SC_ATOMIC_ADD((h)->use_cnt, 1)
#define HostDecrUsecnt(h) \
- (h)->use_cnt--
+ SC_ATOMIC_SUB((h)->use_cnt, 1)
void HostInit(Host *h, Address *a) {
COPY_ADDRESS(a, &h->a);
/** never prune a host that is used by a packets
* we are currently processing in one of the threads */
- if (h->use_cnt > 0) {
+ if (SC_ATOMIC_GET(h->use_cnt) > 0) {
HRLOCK_UNLOCK(hb);
SCMutexUnlock(&h->m);
continue;
Address a;
/** use cnt, reference counter */
- uint16_t use_cnt;
+ SC_ATOMIC_DECLARE(unsigned short, use_cnt);
/** pointers to tag and threshold storage */
void *tag;