Logical Combination: avoid corruption of pending combination report

in streaming mode.

Fixes github issue #165
This commit is contained in:
Chang, Harry 2019-06-06 15:12:24 +08:00
parent 1f4c10a58d
commit 64ea43ea39
2 changed files with 29 additions and 6 deletions

View File

@ -480,6 +480,25 @@ hwlmcb_rv_t roseReport(const struct RoseEngine *t, struct hs_scratch *scratch,
return roseHaltIfExhausted(t, scratch);
}
static rose_inline
hwlmcb_rv_t roseReportComb(const struct RoseEngine *t,
struct hs_scratch *scratch, u64a end,
ReportID onmatch, s32 offset_adjust, u32 ekey) {
DEBUG_PRINTF("firing callback onmatch=%u, end=%llu\n", onmatch, end);
int cb_rv = roseDeliverReport(end, onmatch, offset_adjust, scratch, ekey);
if (cb_rv == MO_HALT_MATCHING) {
DEBUG_PRINTF("termination requested\n");
return HWLM_TERMINATE_MATCHING;
}
if (ekey == INVALID_EKEY || cb_rv == ROSE_CONTINUE_MATCHING_NO_EXHAUST) {
return HWLM_CONTINUE_MATCHING;
}
return roseHaltIfExhausted(t, scratch);
}
/* catches up engines enough to ensure any earlier mpv triggers are enqueued
* and then adds the trigger to the mpv queue. */
static rose_inline
@ -1866,7 +1885,7 @@ hwlmcb_rv_t flushActiveCombinations(const struct RoseEngine *t,
}
DEBUG_PRINTF("Logical Combination Passed!\n");
if (roseReport(t, scratch, end, ci->id, 0,
if (roseReportComb(t, scratch, end, ci->id, 0,
ci->ekey) == HWLM_TERMINATE_MATCHING) {
return HWLM_TERMINATE_MATCHING;
}
@ -1910,7 +1929,7 @@ hwlmcb_rv_t checkPurelyNegatives(const struct RoseEngine *t,
}
DEBUG_PRINTF("Logical Combination from purely negative Passed!\n");
if (roseReport(t, scratch, end, ci->id, 0,
if (roseReportComb(t, scratch, end, ci->id, 0,
ci->ekey) == HWLM_TERMINATE_MATCHING) {
return HWLM_TERMINATE_MATCHING;
}

View File

@ -652,8 +652,10 @@ void report_eod_matches(hs_stream_t *id, hs_scratch_t *scratch,
scratch->core_info.logicalVector = state +
rose->stateOffsets.logicalVec;
scratch->core_info.combVector = state + rose->stateOffsets.combVec;
if (!id->offset) {
scratch->tctxt.lastCombMatchOffset = id->offset;
}
}
if (rose->somLocationCount) {
loadSomFromStream(scratch, id->offset);
@ -908,8 +910,10 @@ hs_error_t hs_scan_stream_internal(hs_stream_t *id, const char *data,
scratch->core_info.logicalVector = state +
rose->stateOffsets.logicalVec;
scratch->core_info.combVector = state + rose->stateOffsets.combVec;
if (!id->offset) {
scratch->tctxt.lastCombMatchOffset = id->offset;
}
}
assert(scratch->core_info.hlen <= id->offset
&& scratch->core_info.hlen <= rose->historyRequired);