diff options
| author | 刘文坛 <[email protected]> | 2023-10-18 03:32:53 +0000 |
|---|---|---|
| committer | 刘文坛 <[email protected]> | 2023-10-18 03:32:53 +0000 |
| commit | 613b5b3dcf749bc6773fd9883ab4d030c1c3e36e (patch) | |
| tree | e60bd3fe0d59c5447d403199e7b7e3c97b0b1710 /src/maat_expr.c | |
| parent | 48af7e7aac84f673bf39a5679503bc891407a182 (diff) | |
[FEATURE]Refactor NOT clause, NOTE:forward incompatibility!!!
Diffstat (limited to 'src/maat_expr.c')
| -rw-r--r-- | src/maat_expr.c | 37 |
1 files changed, 12 insertions, 25 deletions
diff --git a/src/maat_expr.c b/src/maat_expr.c index 4712a16..8663631 100644 --- a/src/maat_expr.c +++ b/src/maat_expr.c @@ -975,20 +975,13 @@ int expr_runtime_scan(struct expr_runtime *expr_rt, int thread_id, return -1; } + struct maat_item hit_maat_items[n_hit_item]; + size_t real_hit_item_cnt = 0; + if (0 == n_hit_item) { - return 0; + goto next; } - if (n_hit_item > MAX_SCANNER_HIT_ITEM_NUM) { - log_info(expr_rt->logger, MODULE_EXPR, - "hit expr item count:%d exceed maxium:%d", - n_hit_item, MAX_SCANNER_HIT_ITEM_NUM); - n_hit_item = MAX_SCANNER_HIT_ITEM_NUM; - } - - struct maat_item hit_maat_items[n_hit_item]; - size_t real_hit_item_cnt = 0; - for (size_t i = 0; i < n_hit_item; i++) { int tag_district_id = *(int *)(hit_results[i].user_tag); if (tag_district_id == state->district_id || tag_district_id == DISTRICT_ANY) { @@ -1008,9 +1001,8 @@ int expr_runtime_scan(struct expr_runtime *expr_rt, int thread_id, } } - maat_compile_state_update(vtable_id, hit_maat_items, real_hit_item_cnt, state); - - return real_hit_item_cnt; +next: + return maat_compile_state_update(vtable_id, hit_maat_items, real_hit_item_cnt, state); } struct expr_matcher_stream * @@ -1048,18 +1040,14 @@ int expr_runtime_stream_scan(struct expr_runtime *expr_rt, return -1; } - if (0 == n_hit_item) { - return 0; - } - - if (n_hit_item > MAX_SCANNER_HIT_ITEM_NUM) { - n_hit_item = MAX_SCANNER_HIT_ITEM_NUM; - } - struct maat_item hit_maat_items[n_hit_item]; struct expr_item *expr_item = NULL; size_t real_hit_item_cnt = 0; + if (0 == n_hit_item) { + goto next; + } + for (size_t i = 0; i < n_hit_item; i++) { long long item_id = hit_results[i].rule_id; expr_item = (struct expr_item *)rcu_hash_find(expr_rt->item_hash, @@ -1075,9 +1063,8 @@ int expr_runtime_stream_scan(struct expr_runtime *expr_rt, real_hit_item_cnt++; } - maat_compile_state_update(vtable_id, hit_maat_items, real_hit_item_cnt, state); - - return real_hit_item_cnt; +next: + return maat_compile_state_update(vtable_id, hit_maat_items, real_hit_item_cnt, state); } void expr_runtime_stream_close(struct expr_runtime *expr_rt, int thread_id, |
