Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnishevent
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
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
varnishevent
Commits
04339dbe
Commit
04339dbe
authored
Dec 07, 2016
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
factor case conversion for a header trie out of the inner loop of HDR_FindIdx()
parent
2624a809
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
40 deletions
+42
-40
hdrtrie.c
src/hdrtrie.c
+12
-10
regress.sh
src/test/regress.sh
+1
-1
test_hdrtrie.c
src/test/test_hdrtrie.c
+29
-29
No files found.
src/hdrtrie.c
View file @
04339dbe
/*-
* Copyright (c) 201
5
UPLEX Nils Goroll Systemoptimierung
* Copyright (c) 201
5
Otto Gmbh & Co KG
* Copyright (c) 201
6
UPLEX Nils Goroll Systemoptimierung
* Copyright (c) 201
6
Otto Gmbh & Co KG
* All rights reserved.
* Use only with permission
*
...
...
@@ -42,18 +42,15 @@
static
inline
int
hdr_next
(
const
char
c
)
{
int
n
=
toupper
(
c
)
-
32
;
if
(
c
==
'~'
)
n
=
':'
-
32
;
return
n
;
return
':'
-
32
;
return
toupper
(
c
)
-
32
;
}
int
HDR_FindIdx
(
struct
hdrt_node
*
hdrt
,
const
char
*
hdr
)
{
const
char
*
h
=
hdr
;
char
*
s
;
int
n
;
if
(
hdrt
==
NULL
)
return
-
1
;
...
...
@@ -62,9 +59,12 @@ HDR_FindIdx(struct hdrt_node *hdrt, const char *hdr)
if
(
*
h
==
'\0'
)
return
-
1
;
while
(
1
)
{
char
*
s
;
int
n
;
CHECK_OBJ
(
hdrt
,
HDRT_NODE_MAGIC
);
s
=
hdrt
->
str
;
while
(
*
h
&&
*
s
&&
(
toupper
(
*
h
)
==
toupper
(
*
s
)
))
{
while
(
*
h
&&
*
s
&&
(
toupper
(
*
h
)
==
*
s
))
{
h
++
;
s
++
;
}
...
...
@@ -97,6 +97,8 @@ HDR_InsertIdx(struct hdrt_node *hdrt, const char *hdr, int idx)
AN
(
hdrt
);
hdrt
->
str
=
strdup
(
hdr
);
AN
(
hdrt
->
str
);
for
(
s
=
hdrt
->
str
;
*
s
;
s
++
)
*
s
=
toupper
(
*
s
);
hdrt
->
next
=
calloc
(
64
,
sizeof
(
struct
hdrt_node
*
));
AN
(
hdrt
->
next
);
hdrt
->
idx
=
idx
;
...
...
@@ -105,7 +107,7 @@ HDR_InsertIdx(struct hdrt_node *hdrt, const char *hdr, int idx)
CHECK_OBJ
(
hdrt
,
HDRT_NODE_MAGIC
);
s
=
hdrt
->
str
;
while
(
*
h
&&
*
s
&&
(
toupper
(
*
h
)
==
toupper
(
*
s
)
))
{
while
(
*
h
&&
*
s
&&
(
toupper
(
*
h
)
==
*
s
))
{
h
++
;
s
++
;
}
...
...
@@ -203,7 +205,7 @@ hdr_traverse(struct hdrt_node *hdrt, struct vsb *sb, struct vsb *prefix)
char
c
=
i
+
32
;
if
(
i
+
32
==
':'
)
c
=
'~'
;
VSB_putc
(
next
,
to
low
er
(
c
));
VSB_putc
(
next
,
to
upp
er
(
c
));
hdr_traverse
(
hdrt
->
next
[
i
],
sb
,
next
);
}
VSB_delete
(
current
);
...
...
src/test/regress.sh
View file @
04339dbe
...
...
@@ -23,7 +23,7 @@ fi
# predictable from one run to the next.
CKSUM
=
$(
sed
-e
's/\(initializing\) \(.*\)/\1/'
$LOG
| egrep
-v
'Writer: returned|Reader: took|^DEBUG: Allocating'
|
cksum
)
if
[
"
$CKSUM
"
!=
'3
648120640
61504698'
]
;
then
if
[
"
$CKSUM
"
!=
'3
946061167
61504698'
]
;
then
echo
"ERROR: Regression test varnishevent log incorrect cksum:
$CKSUM
"
exit
1
fi
...
...
src/test/test_hdrtrie.c
View file @
04339dbe
...
...
@@ -60,7 +60,7 @@ static char
hdrt
[
i
].
next
=
calloc
(
64
,
sizeof
(
struct
hdrt_node
*
));
}
hdrt
[
0
].
str
=
strdup
(
"F
oo
"
);
hdrt
[
0
].
str
=
strdup
(
"F
OO
"
);
hdrt
[
0
].
idx
=
4711
;
MASSERT
(
HDR_FindIdx
(
&
hdrt
[
0
],
"Foo:"
)
==
4711
);
...
...
@@ -80,7 +80,7 @@ static char
MASSERT
(
HDR_FindIdx
(
&
hdrt
[
0
],
" "
)
==
-
1
);
MASSERT
(
HDR_FindIdx
(
&
hdrt
[
0
],
""
)
==
-
1
);
hdrt
[
0
].
str
=
strdup
(
"A
ccept
"
);
hdrt
[
0
].
str
=
strdup
(
"A
CCEPT
"
);
hdrt
[
0
].
next
[
next_idx
(
'-'
)]
=
&
hdrt
[
1
];
hdrt
[
1
].
str
=
strdup
(
""
);
...
...
@@ -90,16 +90,16 @@ static char
hdrt
[
1
].
next
[
next_idx
(
'D'
)]
=
&
hdrt
[
5
];
hdrt
[
1
].
idx
=
-
1
;
hdrt
[
2
].
str
=
strdup
(
"
harset
"
);
hdrt
[
2
].
str
=
strdup
(
"
HARSET
"
);
hdrt
[
2
].
idx
=
1
;
hdrt
[
3
].
str
=
strdup
(
"
ncoding
"
);
hdrt
[
3
].
str
=
strdup
(
"
NCODING
"
);
hdrt
[
3
].
idx
=
2
;
hdrt
[
4
].
str
=
strdup
(
"
anguage
"
);
hdrt
[
4
].
str
=
strdup
(
"
ANGUAGE
"
);
hdrt
[
4
].
idx
=
3
;
hdrt
[
5
].
str
=
strdup
(
"
atetime
"
);
hdrt
[
5
].
str
=
strdup
(
"
ATETIME
"
);
hdrt
[
5
].
idx
=
4
;
MASSERT
(
HDR_FindIdx
(
&
hdrt
[
0
],
"Accept:"
)
==
4711
);
...
...
@@ -120,7 +120,7 @@ static char
MASSERT
(
HDR_FindIdx
(
&
hdrt
[
0
],
"Accept-CharsetFoo:"
)
==
-
1
);
MASSERT
(
HDR_FindIdx
(
&
hdrt
[
0
],
"Accept-Charse:"
)
==
-
1
);
hdrt
[
0
].
str
=
strdup
(
"C
ontent
-"
);
hdrt
[
0
].
str
=
strdup
(
"C
ONTENT
-"
);
memset
(
hdrt
[
0
].
next
,
0
,
64
*
sizeof
(
struct
hdrt_node
*
));
hdrt
[
0
].
next
[
next_idx
(
'D'
)]
=
&
hdrt
[
1
];
hdrt
[
0
].
next
[
next_idx
(
'E'
)]
=
&
hdrt
[
2
];
...
...
@@ -130,11 +130,11 @@ static char
hdrt
[
0
].
next
[
next_idx
(
'T'
)]
=
&
hdrt
[
6
];
hdrt
[
0
].
idx
=
-
1
;
hdrt
[
1
].
str
=
strdup
(
"
isposition
"
);
hdrt
[
1
].
str
=
strdup
(
"
ISPOSITION
"
);
memset
(
hdrt
[
1
].
next
,
0
,
64
*
sizeof
(
struct
hdrt_node
*
));
hdrt
[
1
].
idx
=
1
;
hdrt
[
2
].
str
=
strdup
(
"
ncoding
"
);
hdrt
[
2
].
str
=
strdup
(
"
NCODING
"
);
memset
(
hdrt
[
2
].
next
,
0
,
64
*
sizeof
(
struct
hdrt_node
*
));
hdrt
[
2
].
idx
=
2
;
...
...
@@ -149,20 +149,20 @@ static char
memset
(
hdrt
[
4
].
next
,
0
,
64
*
sizeof
(
struct
hdrt_node
*
));
hdrt
[
4
].
idx
=
3
;
hdrt
[
5
].
str
=
strdup
(
"
ange
"
);
hdrt
[
5
].
str
=
strdup
(
"
ANGE
"
);
memset
(
hdrt
[
5
].
next
,
0
,
64
*
sizeof
(
struct
hdrt_node
*
));
hdrt
[
5
].
idx
=
4
;
hdrt
[
6
].
str
=
strdup
(
"
ype
"
);
hdrt
[
6
].
str
=
strdup
(
"
YPE
"
);
hdrt
[
6
].
idx
=
5
;
hdrt
[
7
].
str
=
strdup
(
"
nguage
"
);
hdrt
[
7
].
str
=
strdup
(
"
NGUAGE
"
);
hdrt
[
7
].
idx
=
6
;
hdrt
[
8
].
str
=
strdup
(
"
ngth
"
);
hdrt
[
8
].
str
=
strdup
(
"
NGTH
"
);
hdrt
[
8
].
idx
=
7
;
hdrt
[
9
].
str
=
strdup
(
"
cation
"
);
hdrt
[
9
].
str
=
strdup
(
"
CATION
"
);
hdrt
[
9
].
idx
=
8
;
MASSERT
(
HDR_FindIdx
(
&
hdrt
[
0
],
"Content-Disposition:"
)
==
1
);
...
...
@@ -188,26 +188,26 @@ static char
hdrt
[
0
].
next
[
next_idx
(
'F'
)]
=
&
hdrt
[
2
];
hdrt
[
0
].
idx
=
-
1
;
hdrt
[
1
].
str
=
strdup
(
"
srf-Token
"
);
hdrt
[
1
].
str
=
strdup
(
"
SRF-TOKEN
"
);
memset
(
hdrt
[
1
].
next
,
0
,
64
*
sizeof
(
struct
hdrt_node
*
));
hdrt
[
1
].
idx
=
1
;
hdrt
[
2
].
str
=
strdup
(
"
orwarded
-"
);
hdrt
[
2
].
str
=
strdup
(
"
ORWARDED
-"
);
memset
(
hdrt
[
2
].
next
,
0
,
64
*
sizeof
(
struct
hdrt_node
*
));
hdrt
[
2
].
next
[
next_idx
(
'F'
)]
=
&
hdrt
[
3
];
hdrt
[
2
].
next
[
next_idx
(
'H'
)]
=
&
hdrt
[
4
];
hdrt
[
2
].
next
[
next_idx
(
'P'
)]
=
&
hdrt
[
5
];
hdrt
[
2
].
idx
=
-
1
;
hdrt
[
3
].
str
=
strdup
(
"
or
"
);
hdrt
[
3
].
str
=
strdup
(
"
OR
"
);
memset
(
hdrt
[
3
].
next
,
0
,
64
*
sizeof
(
struct
hdrt_node
*
));
hdrt
[
3
].
idx
=
2
;
hdrt
[
4
].
str
=
strdup
(
"
ost
"
);
hdrt
[
4
].
str
=
strdup
(
"
OST
"
);
memset
(
hdrt
[
4
].
next
,
0
,
64
*
sizeof
(
struct
hdrt_node
*
));
hdrt
[
4
].
idx
=
3
;
hdrt
[
5
].
str
=
strdup
(
"
roto
"
);
hdrt
[
5
].
str
=
strdup
(
"
ROTO
"
);
memset
(
hdrt
[
5
].
next
,
0
,
64
*
sizeof
(
struct
hdrt_node
*
));
hdrt
[
5
].
idx
=
4
;
...
...
@@ -239,7 +239,7 @@ static char
hdrt
=
HDR_InsertIdx
(
NULL
,
"Foo"
,
4711
);
MCHECK_OBJ_NOTNULL
(
hdrt
,
HDRT_NODE_MAGIC
);
MASSERT
(
strcmp
(
hdrt
->
str
,
"F
oo
"
)
==
0
);
MASSERT
(
strcmp
(
hdrt
->
str
,
"F
OO
"
)
==
0
);
MASSERT
(
hdrt
->
idx
==
4711
);
MASSERT
(
memcmp
(
hdrt
->
next
,
next
,
SIZEOF_NEXTTBL
)
==
0
);
MASSERT
(
HDR_FindIdx
(
hdrt
,
"Foo:"
)
==
4711
);
...
...
@@ -272,12 +272,12 @@ static char
MAZ
(
hdrt
->
next
[
i
]);
hdrt2
=
hdrt
->
next
[
next_idx
(
'B'
)];
MCHECK_OBJ_NOTNULL
(
hdrt2
,
HDRT_NODE_MAGIC
);
MASSERT
(
strcmp
(
hdrt2
->
str
,
"
ar
"
)
==
0
);
MASSERT
(
strcmp
(
hdrt2
->
str
,
"
AR
"
)
==
0
);
MASSERT
(
hdrt2
->
idx
==
1147
);
MASSERT
(
memcmp
(
hdrt2
->
next
,
next
,
SIZEOF_NEXTTBL
)
==
0
);
hdrt2
=
hdrt
->
next
[
next_idx
(
'F'
)];
MCHECK_OBJ_NOTNULL
(
hdrt2
,
HDRT_NODE_MAGIC
);
MASSERT
(
strcmp
(
hdrt2
->
str
,
"
oo
"
)
==
0
);
MASSERT
(
strcmp
(
hdrt2
->
str
,
"
OO
"
)
==
0
);
MASSERT
(
hdrt2
->
idx
==
4711
);
MASSERT
(
memcmp
(
hdrt2
->
next
,
next
,
SIZEOF_NEXTTBL
)
==
0
);
MASSERT
(
HDR_FindIdx
(
hdrt
,
"Foo:"
)
==
4711
);
...
...
@@ -287,14 +287,14 @@ static char
MCHECK_OBJ_NOTNULL
(
hdrt
,
HDRT_NODE_MAGIC
);
hdrt
=
HDR_InsertIdx
(
hdrt
,
"Accept-Encoding"
,
2
);
MCHECK_OBJ_NOTNULL
(
hdrt
,
HDRT_NODE_MAGIC
);
MASSERT
(
strcmp
(
hdrt
->
str
,
"A
ccept
"
)
==
0
);
MASSERT
(
strcmp
(
hdrt
->
str
,
"A
CCEPT
"
)
==
0
);
MASSERT
(
hdrt
->
idx
==
1
);
for
(
int
i
=
0
;
i
<
64
;
i
++
)
if
(
i
!=
next_idx
(
'-'
))
MAZ
(
hdrt
->
next
[
i
]);
hdrt2
=
hdrt
->
next
[
next_idx
(
'-'
)];
MCHECK_OBJ_NOTNULL
(
hdrt2
,
HDRT_NODE_MAGIC
);
MASSERT
(
strcmp
(
hdrt2
->
str
,
"E
ncoding
"
)
==
0
);
MASSERT
(
strcmp
(
hdrt2
->
str
,
"E
NCODING
"
)
==
0
);
MASSERT
(
hdrt2
->
idx
==
2
);
MASSERT
(
memcmp
(
hdrt2
->
next
,
next
,
SIZEOF_NEXTTBL
)
==
0
);
MASSERT
(
HDR_FindIdx
(
hdrt
,
"Accept:"
)
==
1
);
...
...
@@ -306,7 +306,7 @@ static char
MCHECK_OBJ_NOTNULL
(
hdrt
,
HDRT_NODE_MAGIC
);
hdrt
=
HDR_InsertIdx
(
hdrt
,
"Accept-Datetime"
,
5
);
MCHECK_OBJ_NOTNULL
(
hdrt
,
HDRT_NODE_MAGIC
);
MASSERT
(
strcmp
(
hdrt
->
str
,
"A
ccept
"
)
==
0
);
MASSERT
(
strcmp
(
hdrt
->
str
,
"A
CCEPT
"
)
==
0
);
MASSERT
(
hdrt
->
idx
==
1
);
for
(
int
i
=
0
;
i
<
64
;
i
++
)
if
(
i
!=
next_idx
(
'-'
))
...
...
@@ -323,13 +323,13 @@ static char
MCHECK_OBJ_NOTNULL
(
hdrt2
->
next
[
next_idx
(
'D'
)],
HDRT_NODE_MAGIC
);
MCHECK_OBJ_NOTNULL
(
hdrt2
->
next
[
next_idx
(
'E'
)],
HDRT_NODE_MAGIC
);
MCHECK_OBJ_NOTNULL
(
hdrt2
->
next
[
next_idx
(
'L'
)],
HDRT_NODE_MAGIC
);
MASSERT
(
strcmp
(
hdrt2
->
next
[
next_idx
(
'C'
)]
->
str
,
"
harset
"
)
==
0
);
MASSERT
(
strcmp
(
hdrt2
->
next
[
next_idx
(
'C'
)]
->
str
,
"
HARSET
"
)
==
0
);
MASSERT
(
hdrt2
->
next
[
next_idx
(
'C'
)]
->
idx
==
3
);
MASSERT
(
strcmp
(
hdrt2
->
next
[
next_idx
(
'D'
)]
->
str
,
"
atetime
"
)
==
0
);
MASSERT
(
strcmp
(
hdrt2
->
next
[
next_idx
(
'D'
)]
->
str
,
"
ATETIME
"
)
==
0
);
MASSERT
(
hdrt2
->
next
[
next_idx
(
'D'
)]
->
idx
==
5
);
MASSERT
(
strcmp
(
hdrt2
->
next
[
next_idx
(
'E'
)]
->
str
,
"
ncoding
"
)
==
0
);
MASSERT
(
strcmp
(
hdrt2
->
next
[
next_idx
(
'E'
)]
->
str
,
"
NCODING
"
)
==
0
);
MASSERT
(
hdrt2
->
next
[
next_idx
(
'E'
)]
->
idx
==
2
);
MASSERT
(
strcmp
(
hdrt2
->
next
[
next_idx
(
'L'
)]
->
str
,
"
anguage
"
)
==
0
);
MASSERT
(
strcmp
(
hdrt2
->
next
[
next_idx
(
'L'
)]
->
str
,
"
ANGUAGE
"
)
==
0
);
MASSERT
(
hdrt2
->
next
[
next_idx
(
'L'
)]
->
idx
==
4
);
MASSERT
(
HDR_FindIdx
(
hdrt
,
"Accept:"
)
==
1
);
MASSERT
(
HDR_FindIdx
(
hdrt
,
"Accept-Charset:"
)
==
3
);
...
...
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