Skip to content

Commit

Permalink
Regex filter multithreading patch
Browse files Browse the repository at this point in the history
  • Loading branch information
phaag committed Jul 19, 2024
1 parent 9965ceb commit 3f26afa
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/libnfdump/sgregex/sgregex.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ static void rxCompile(rxCompiler* c, const rxChar* str, size_t strsize) {

#define RX_SAFE_INCR(s) \
if (++(s) == strend) { \
c->errpos = (s)-str; \
c->errpos = (s) - str; \
goto reached_end_too_soon; \
}

Expand Down Expand Up @@ -1059,6 +1059,12 @@ int srx_MatchExt(srx_Context* R, const rxChar* str, size_t size, size_t offset)
const rxChar* strstart = str;
const rxChar* strend = str + size;
if (offset > size) return 0;

// need thread local context
srx_Context srxc;
memcpy((void*)&srxc, R, sizeof(srx_Context));
R = &srxc;

R->str = strstart;
str += offset;
rxResetCaptures(R);
Expand Down

0 comments on commit 3f26afa

Please sign in to comment.