Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
trackrdrd
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
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
trackrdrd
Commits
41fe97e4
Commit
41fe97e4
authored
Feb 07, 2024
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use PCRE2 instead of PCRE, as in Varnish since 7.x.
parent
d6fb2532
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
46 additions
and
24 deletions
+46
-24
configure.ac
configure.ac
+2
-0
Makefile.am
src/mq/kafka/Makefile.am
+1
-1
mq.c
src/mq/kafka/mq.c
+6
-3
Makefile.am
src/mq/kafka/test/Makefile.am
+3
-3
zookeeper.c
src/mq/kafka/zookeeper.c
+34
-17
No files found.
configure.ac
View file @
41fe97e4
...
...
@@ -91,6 +91,8 @@ AS_IF([test "x$enable_kafka" != xno],
AC_MSG_ERROR([libzookeeper_mt is required]))
AC_CHECK_LIB([rdkafka], [rd_kafka_new], [true],
AC_MSG_ERROR([librdkafka is required]))
AC_CHECK_LIB([pcre2-8], [pcre2_compile_8], [true],
AC_MSG_ERROR([pcre2-8 is required]))
], [])
# From Varnish configure.ac
...
...
src/mq/kafka/Makefile.am
View file @
41fe97e4
...
...
@@ -23,7 +23,7 @@ libtrackrdr_kafka_la_SOURCES = \
libtrackrdr_kafka_la_LIBADD
=
\
${
PTHREAD_LIBS
}
\
-lrdkafka
-lz
-lpthread
-lrt
-lzookeeper_mt
-lpcre
-lrdkafka
-lz
-lpthread
-lrt
-lzookeeper_mt
-lpcre
2-8
libtrackrdr_kafka_la_LDFLAGS
=
-version-info
${
CURRENT
}
:
${
REVISION
}
:
${
AGE
}
...
...
src/mq/kafka/mq.c
View file @
41fe97e4
...
...
@@ -37,8 +37,10 @@
#include <ctype.h>
#include <signal.h>
#define PCRE2_CODE_UNIT_WIDTH 8
#include <zookeeper/zookeeper_version.h>
#include <pcre.h>
#include <pcre
2
.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
...
...
@@ -115,8 +117,9 @@ MQ_GlobalInit(unsigned nworkers, const char *config_fname)
MQ_LOG_SetLevel
(
loglvl
);
}
snprintf
(
_version
,
LINE_MAX
,
"libtrackrdr-kafka %s, rdkafka %s, zookeeper %s, pcre %s"
,
SO_VERSION
,
rd_kafka_version_str
(),
ZOO_VERSION
,
pcre_version
());
"libtrackrdr-kafka %s, rdkafka %s, zookeeper %s, pcre2 %d.%d"
,
SO_VERSION
,
rd_kafka_version_str
(),
ZOO_VERSION
,
PCRE2_MAJOR
,
PCRE2_MINOR
);
MQ_LOG_Log
(
LOG_INFO
,
"initializing (%s)"
,
_version
);
if
(
zookeeper
[
0
]
==
'\0'
&&
brokerlist
[
0
]
==
'\0'
)
{
...
...
src/mq/kafka/test/Makefile.am
View file @
41fe97e4
...
...
@@ -30,7 +30,7 @@ test_kafka_LDADD = \
../callback.
$(OBJEXT)
\
../config.
$(OBJEXT)
\
${
PTHREAD_LIBS
}
\
-lrdkafka
-lz
-lpthread
-lrt
-lzookeeper_mt
-lpcre
-lrdkafka
-lz
-lpthread
-lrt
-lzookeeper_mt
-lpcre
2-8
test_send_SOURCES
=
\
$(top_srcdir)
/src/test/minunit.h
\
...
...
@@ -47,7 +47,7 @@ test_send_LDADD = \
../callback.
$(OBJEXT)
\
../config.
$(OBJEXT)
\
${
PTHREAD_LIBS
}
\
-lrdkafka
-lz
-lpthread
-lrt
-lzookeeper_mt
-lpcre
-lrdkafka
-lz
-lpthread
-lrt
-lzookeeper_mt
-lpcre
2-8
test_send_ssl_SOURCES
=
\
$(top_srcdir)
/src/test/minunit.h
\
...
...
@@ -64,7 +64,7 @@ test_send_ssl_LDADD = \
../callback.
$(OBJEXT)
\
../config.
$(OBJEXT)
\
${
PTHREAD_LIBS
}
\
-lrdkafka
-lz
-lpthread
-lrt
-lzookeeper_mt
-lpcre
-lrdkafka
-lz
-lpthread
-lrt
-lzookeeper_mt
-lpcre
2-8
CLEANFILES
=
kafka.log zoo.log
*
~
...
...
src/mq/kafka/zookeeper.c
View file @
41fe97e4
...
...
@@ -43,8 +43,10 @@
#include <string.h>
#include <syslog.h>
#define PCRE2_CODE_UNIT_WIDTH 8
#include <zookeeper/zookeeper.h>
#include <pcre.h>
#include <pcre
2
.h>
#include "mq_kafka.h"
#include "miniobj.h"
...
...
@@ -52,7 +54,9 @@
#define BROKER_PATH "/brokers/ids"
static
zhandle_t
*
zh
=
NULL
;
static
pcre
*
host_regex
=
NULL
,
*
port_regex
=
NULL
;
static
pcre2_code
*
host_regex
=
NULL
,
*
port_regex
=
NULL
;
static
pcre2_match_data
*
host_data
=
NULL
,
*
port_data
=
NULL
;
static
pcre2_match_context
*
mctx
=
NULL
;
static
char
errmsg
[
LINE_MAX
];
static
FILE
*
zoologf
=
NULL
;
...
...
@@ -61,8 +65,8 @@ static const char
{
struct
String_vector
broker_ids
;
int
result
;
PCRE2_SIZE
offset
;
char
*
brokerptr
=
brokers
;
const
char
*
pcre_err
;
AN
(
zh
);
...
...
@@ -73,20 +77,31 @@ static const char
}
if
(
host_regex
==
NULL
)
{
host_regex
=
pcre_compile
(
"
\"
host
\"\\
s*:
\\
s*
\"
([^
\"
]+)
\"
"
,
0
,
&
pcre_err
,
&
result
,
NULL
);
host_regex
=
pcre2_compile
(
"
\"
host
\"\\
s*:
\\
s*
\"
([^
\"
]+)
\"
"
,
PCRE2_ZERO_TERMINATED
,
0
,
&
result
,
&
offset
,
NULL
);
AN
(
host_regex
);
host_data
=
pcre2_match_data_create_from_pattern
(
host_regex
,
NULL
);
AN
(
host_data
);
}
if
(
port_regex
==
NULL
)
{
port_regex
=
pcre_compile
(
"
\"
port
\"\\
s*:
\\
s*(
\\
d+)"
,
0
,
&
pcre_err
,
&
result
,
NULL
);
port_regex
=
pcre2_compile
(
"
\"
port
\"\\
s*:
\\
s*(
\\
d+)"
,
PCRE2_ZERO_TERMINATED
,
0
,
&
result
,
&
offset
,
NULL
);
AN
(
port_regex
);
port_data
=
pcre2_match_data_create_from_pattern
(
port_regex
,
NULL
);
AN
(
port_data
);
}
if
(
mctx
==
NULL
)
{
mctx
=
pcre2_match_context_create
(
NULL
);
AN
(
mctx
);
}
memset
(
brokers
,
0
,
max
);
for
(
int
i
=
0
;
i
<
broker_ids
.
count
;
i
++
)
{
char
path
[
PATH_MAX
],
broker
[
LINE_MAX
];
int
len
=
LINE_MAX
;
PCRE2_SIZE
ll
;
snprintf
(
path
,
PATH_MAX
,
"/brokers/ids/%s"
,
broker_ids
.
data
[
i
]);
if
((
result
=
zoo_get
(
zh
,
path
,
0
,
broker
,
&
len
,
NULL
))
!=
ZOK
)
{
...
...
@@ -96,31 +111,33 @@ static const char
return
errmsg
;
}
if
(
len
>
0
)
{
int
ovector
[
6
],
r
;
const
char
*
host
=
NULL
,
*
port
=
NULL
;
int
r
;
PCRE2_UCHAR
*
host
=
NULL
,
*
port
=
NULL
;
broker
[
len
]
=
'\0'
;
MQ_LOG_Log
(
LOG_DEBUG
,
"Zookeeper broker id %s config: %s"
,
broker_ids
.
data
[
i
],
broker
);
r
=
pcre
_exec
(
host_regex
,
NULL
,
broker
,
len
,
0
,
0
,
ovector
,
6
);
if
(
r
<=
PCRE_ERROR_NOMATCH
)
{
r
=
pcre
2_match
(
host_regex
,
broker
,
len
,
0
,
0
,
host_data
,
mctx
);
if
(
r
<=
PCRE
2
_ERROR_NOMATCH
)
{
snprintf
(
errmsg
,
LINE_MAX
,
"Host not found in config for broker id %s [%s]"
,
broker_ids
.
data
[
i
],
broker
);
return
errmsg
;
}
pcre_get_substring
(
broker
,
ovector
,
r
,
1
,
&
host
);
(
void
)
pcre2_substring_get_bynumber
(
host_data
,
1
,
&
host
,
&
ll
);
AN
(
host
);
r
=
pcre_exec
(
port_regex
,
NULL
,
broker
,
len
,
0
,
0
,
ovector
,
6
);
if
(
r
<=
PCRE_ERROR_NOMATCH
)
{
AN
(
ll
);
r
=
pcre2_match
(
port_regex
,
broker
,
len
,
0
,
0
,
port_data
,
mctx
);
if
(
r
<=
PCRE2_ERROR_NOMATCH
)
{
snprintf
(
errmsg
,
LINE_MAX
,
"Port not found in config for broker id %s [%s]"
,
broker_ids
.
data
[
i
],
broker
);
return
errmsg
;
}
pcre_get_substring
(
broker
,
ovector
,
r
,
1
,
&
port
);
(
void
)
pcre2_substring_get_bynumber
(
port_data
,
1
,
&
port
,
&
ll
);
AN
(
port
);
AN
(
ll
);
if
(
strlen
(
brokers
)
+
strlen
(
host
)
+
strlen
(
port
)
+
2
>
max
)
{
snprintf
(
errmsg
,
LINE_MAX
,
...
...
@@ -129,8 +146,8 @@ static const char
return
errmsg
;
}
sprintf
(
brokerptr
,
"%s:%s"
,
host
,
port
);
pcre
_free_substring
(
host
);
pcre
_free_substring
(
port
);
pcre
2_substring_free
(
host
);
pcre
2_substring_free
(
port
);
brokerptr
+=
strlen
(
brokerptr
);
if
(
i
<
broker_ids
.
count
-
1
)
*
brokerptr
++
=
','
;
...
...
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