Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-pcre2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
libvmod-pcre2
Commits
de676c22
Commit
de676c22
authored
Jul 01, 2017
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lock initialization of PRIV_CALL-scoped data.
parent
4d9878cb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
6 deletions
+22
-6
pcre2.c
src/pcre2.c
+22
-5
vmod_pcre2.c
src/vmod_pcre2.c
+0
-1
No files found.
src/pcre2.c
View file @
de676c22
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
*/
*/
#include <locale.h>
#include <locale.h>
#include <pthread.h>
#include "vmod_pcre2.h"
#include "vmod_pcre2.h"
...
@@ -36,6 +37,9 @@
...
@@ -36,6 +37,9 @@
AZ(pcre2_set_##param((ctx), (type)(param))); \
AZ(pcre2_set_##param((ctx), (type)(param))); \
} while(0)
} while(0)
/* Locks initialization of PRIV_CALL-scoped data. */
static
pthread_mutex_t
call_lock
=
PTHREAD_MUTEX_INITIALIZER
;
void
void
errmsg
(
VRT_CTX
,
const
char
*
fmt
,
...)
errmsg
(
VRT_CTX
,
const
char
*
fmt
,
...)
{
{
...
@@ -245,20 +249,28 @@ get_match_opts(VRT_CTX, struct vmod_priv *priv, MATCH_CTX_OPTS, MATCH_FLAGS,
...
@@ -245,20 +249,28 @@ get_match_opts(VRT_CTX, struct vmod_priv *priv, MATCH_CTX_OPTS, MATCH_FLAGS,
struct
match_call
*
match_opts
;
struct
match_call
*
match_opts
;
pcre2_match_context
*
mctx
;
pcre2_match_context
*
mctx
;
AZ
(
pthread_mutex_lock
(
&
call_lock
));
if
(
priv
->
priv
!=
NULL
)
{
/* Someone beat us to it. */
AZ
(
pthread_mutex_unlock
(
&
call_lock
));
CAST_OBJ
(
match_opts
,
priv
->
priv
,
VMOD_PCRE2_MATCH_CALL_MAGIC
);
return
match_opts
;
}
if
(
!
check_uint32_range
(
ctx
,
match_limit
,
"match_limit"
,
context
,
if
(
!
check_uint32_range
(
ctx
,
match_limit
,
"match_limit"
,
context
,
caller
))
caller
))
return
NULL
;
goto
fail
;
if
(
!
check_uint32_range
(
ctx
,
offset_limit
,
"offset_limit"
,
context
,
if
(
!
check_uint32_range
(
ctx
,
offset_limit
,
"offset_limit"
,
context
,
caller
))
caller
))
return
NULL
;
goto
fail
;
if
(
!
check_uint32_range
(
ctx
,
recursion_limit
,
"recursion_limit"
,
if
(
!
check_uint32_range
(
ctx
,
recursion_limit
,
"recursion_limit"
,
context
,
caller
))
context
,
caller
))
return
NULL
;
goto
fail
;
if
((
mctx
=
pcre2_match_context_create
(
NULL
))
==
NULL
)
{
if
((
mctx
=
pcre2_match_context_create
(
NULL
))
==
NULL
)
{
VERRNOMEM
(
ctx
,
"creating match context in %s%s"
,
context
,
VERRNOMEM
(
ctx
,
"creating match context in %s%s"
,
context
,
caller
);
caller
);
return
NULL
;
goto
fail
;
}
}
SET_CTX_PARAM
(
mctx
,
match_limit
,
uint32_t
);
SET_CTX_PARAM
(
mctx
,
match_limit
,
uint32_t
);
SET_CTX_PARAM
(
mctx
,
offset_limit
,
uint32_t
);
SET_CTX_PARAM
(
mctx
,
offset_limit
,
uint32_t
);
...
@@ -268,7 +280,7 @@ get_match_opts(VRT_CTX, struct vmod_priv *priv, MATCH_CTX_OPTS, MATCH_FLAGS,
...
@@ -268,7 +280,7 @@ get_match_opts(VRT_CTX, struct vmod_priv *priv, MATCH_CTX_OPTS, MATCH_FLAGS,
if
(
match_opts
==
NULL
)
{
if
(
match_opts
==
NULL
)
{
VERRNOMEM
(
ctx
,
"allocating call-scoped match options in %s%s"
,
VERRNOMEM
(
ctx
,
"allocating call-scoped match options in %s%s"
,
context
,
caller
);
context
,
caller
);
return
NULL
;
goto
fail
;
}
}
match_opts
->
mctx
=
mctx
;
match_opts
->
mctx
=
mctx
;
set_match_flags
(
&
match_opts
->
match_options
,
MATCH_SUB_FLAGS_PARAMS
);
set_match_flags
(
&
match_opts
->
match_options
,
MATCH_SUB_FLAGS_PARAMS
);
...
@@ -277,5 +289,10 @@ get_match_opts(VRT_CTX, struct vmod_priv *priv, MATCH_CTX_OPTS, MATCH_FLAGS,
...
@@ -277,5 +289,10 @@ get_match_opts(VRT_CTX, struct vmod_priv *priv, MATCH_CTX_OPTS, MATCH_FLAGS,
priv
->
free
=
match_call_free
;
priv
->
free
=
match_call_free
;
priv
->
len
=
sizeof
(
*
match_opts
);
priv
->
len
=
sizeof
(
*
match_opts
);
AZ
(
pthread_mutex_unlock
(
&
call_lock
));
return
match_opts
;
return
match_opts
;
fail:
AZ
(
pthread_mutex_unlock
(
&
call_lock
));
return
NULL
;
}
}
src/vmod_pcre2.c
View file @
de676c22
...
@@ -546,7 +546,6 @@ vmod_match(VRT_CTX, struct vmod_priv *call, struct vmod_priv *task,
...
@@ -546,7 +546,6 @@ vmod_match(VRT_CTX, struct vmod_priv *call, struct vmod_priv *task,
}
}
/* Compile and match options saved in PRIV_CALL scope */
/* Compile and match options saved in PRIV_CALL scope */
/* XXX need a lock */
if
(
call
->
priv
!=
NULL
)
if
(
call
->
priv
!=
NULL
)
CAST_OBJ
(
match_call
,
call
->
priv
,
VMOD_PCRE2_MATCH_CALL_MAGIC
);
CAST_OBJ
(
match_call
,
call
->
priv
,
VMOD_PCRE2_MATCH_CALL_MAGIC
);
else
if
((
match_call
=
get_match_opts
(
ctx
,
call
,
MATCH_CTX_PARAMS
,
else
if
((
match_call
=
get_match_opts
(
ctx
,
call
,
MATCH_CTX_PARAMS
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment