Replace sgh refcnt by a flag.

remotes/origin/master-1.0.x
Victor Julien 15 years ago
parent 91d14964b6
commit 32e51e5e5a

@ -253,7 +253,6 @@ int SigLoadSignatures (DetectEngineCtx *de_ctx, char *sig_file)
/* Setup the signature group lookup structure and pattern matchers */
SigGroupBuild(de_ctx);
return 0;
}
@ -1686,7 +1685,7 @@ int BuildDestinationAddressHeads(DetectEngineCtx *de_ctx, DetectAddressGroupsHea
de_ctx->gh_reuse++;
sgr->flags |= ADDRESS_SIGGROUPHEAD_COPY;
sgr->sh->refcnt++;
sgr->sh->flags |= SIG_GROUP_HEAD_REFERENCED;
}
}
@ -1973,7 +1972,7 @@ static int BuildDestinationAddressHeadsWithBothPorts(DetectEngineCtx *de_ctx, De
SigGroupHeadFree(dp->sh);
dp->sh = lookup_dp_sgh;
dp->flags |= PORT_SIGGROUPHEAD_COPY;
dp->sh->refcnt++;
dp->sh->flags |= SIG_GROUP_HEAD_REFERENCED;
de_ctx->gh_reuse++;
}
@ -1983,7 +1982,7 @@ static int BuildDestinationAddressHeadsWithBothPorts(DetectEngineCtx *de_ctx, De
SigGroupHeadFree(sp->sh);
sp->sh = lookup_sp_sgh;
sp->flags |= PORT_SIGGROUPHEAD_COPY;
sp->sh->refcnt++;
sp->sh->flags |= SIG_GROUP_HEAD_REFERENCED;
SCLogDebug("replacing sp->dst_ph %p with lookup_sp_sgh->port %p", sp->dst_ph, lookup_sp_sgh->port);
DetectPortCleanupList(sp->dst_ph);
@ -1997,7 +1996,7 @@ static int BuildDestinationAddressHeadsWithBothPorts(DetectEngineCtx *de_ctx, De
SigGroupHeadFree(dst_gr->sh);
dst_gr->sh = lookup_sgh;
dst_gr->flags |= ADDRESS_SIGGROUPHEAD_COPY;
dst_gr->sh->refcnt++;
dst_gr->sh->flags |= SIG_GROUP_HEAD_REFERENCED;
SCLogDebug("replacing dst_gr->port %p with lookup_sgh->port %p", dst_gr->port, lookup_sgh->port);
DetectPortCleanupList(dst_gr->port);
@ -2011,10 +2010,9 @@ static int BuildDestinationAddressHeadsWithBothPorts(DetectEngineCtx *de_ctx, De
DetectPort *sp = dst_gr->port;
for ( ; sp != NULL; sp = sp->next) {
if (!(sp->flags & PORT_SIGGROUPHEAD_COPY)) {
if (sp->sh->refcnt == 0) {
if (!(sp->sh->flags & SIG_GROUP_HEAD_REFERENCED)) {
if (SigGroupHeadHashRemove(de_ctx,sp->sh) == 0 &&
SigGroupHeadSPortHashRemove(de_ctx,sp->sh) == 0) {
//printf("BothPorts: removed sgh %p\n", sp->sh);
SigGroupHeadFree(sp->sh);
sp->sh = NULL;
}
@ -2032,7 +2030,7 @@ static int BuildDestinationAddressHeadsWithBothPorts(DetectEngineCtx *de_ctx, De
dst_gr_head = GetHeadPtr(src_gr->dst_gh,family);
for (dst_gr = dst_gr_head; dst_gr != NULL; dst_gr = dst_gr->next) {
if (!(dst_gr->flags & ADDRESS_SIGGROUPHEAD_COPY)) {
if (dst_gr->sh->refcnt == 0) {
if (!(dst_gr->sh->flags & SIG_GROUP_HEAD_REFERENCED)) {
if (SigGroupHeadHashRemove(de_ctx,dst_gr->sh) == 0) {
//printf("BothPorts: removed sgh %p\n", dst_gr->sh);
SigGroupHeadFree(dst_gr->sh);

@ -339,11 +339,12 @@ typedef struct SigTableElmt_ {
char *name;
} SigTableElmt;
#define SIG_GROUP_HAVECONTENT 0x01
#define SIG_GROUP_HAVEURICONTENT 0x02
#define SIG_GROUP_HEAD_MPM_COPY 0x04
#define SIG_GROUP_HEAD_MPM_URI_COPY 0x08
#define SIG_GROUP_HEAD_FREE 0x10
#define SIG_GROUP_HAVECONTENT 0x01
#define SIG_GROUP_HAVEURICONTENT 0x02
#define SIG_GROUP_HEAD_MPM_COPY 0x04
#define SIG_GROUP_HEAD_MPM_URI_COPY 0x08
#define SIG_GROUP_HEAD_FREE 0x10
#define SIG_GROUP_HEAD_REFERENCED 0x20 /**< sgh is being referenced by others, don't clear */
/** \brief head of the list of containers. */
typedef struct SigGroupHead_ {
@ -376,13 +377,6 @@ typedef struct SigGroupHead_ {
/* port ptr */
struct DetectPort_ *port;
// uint16_t mpm_len1;
// uint16_t mpm_len2;
// uint16_t mpm_len3;
// uint16_t mpm_len4; /* 4+ */
uint32_t refcnt;
} SigGroupHead;
/** sigmatch has no options, so the parser shouldn't expect any */

Loading…
Cancel
Save