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
ef08fad8
Commit
ef08fad8
authored
Dec 06, 2012
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
trackrdrd: fixed a bug computing the SPMC queue length at UINT overflow
(caught by slink)
parent
a4b6eda4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
6 deletions
+43
-6
configure.ac
trackrdrd/configure.ac
+1
-1
spmcq.c
trackrdrd/src/spmcq.c
+29
-3
Makefile.am
trackrdrd/src/test/Makefile.am
+13
-2
No files found.
trackrdrd/configure.ac
View file @
ef08fad8
AC_PREREQ(2.59)
AC_COPYRIGHT([Copyright (c) 2012 Otto Gmbh & Co KG])
AC_INIT([trackrdrd], [1.0])
AC_INIT([trackrdrd], [1.0
.1_SNAPSHOT
])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR(src/trackrdrd.c)
AM_CONFIG_HEADER(config.h)
...
...
trackrdrd/src/spmcq.c
View file @
ef08fad8
...
...
@@ -43,10 +43,9 @@ static pthread_mutex_t spmcq_deq_lock;
static
inline
unsigned
spmcq_len
(
void
)
{
if
(
spmcq
.
tail
<
spmcq
.
head
)
return
UINT_MAX
-
spmcq
.
head
-
1
-
spmcq
.
tail
;
else
if
(
spmcq
.
tail
>=
spmcq
.
head
)
return
spmcq
.
tail
-
spmcq
.
head
;
return
UINT_MAX
-
spmcq
.
head
+
1
+
spmcq
.
tail
;
}
static
void
...
...
@@ -99,3 +98,30 @@ void
AZ
(
pthread_mutex_unlock
(
&
spmcq_deq_lock
));
return
ptr
;
}
#ifdef TEST_DRIVER
int
main
(
int
argc
,
char
*
const
*
argv
)
{
(
void
)
argc
;
printf
(
"
\n
TEST: %s
\n
"
,
argv
[
0
]);
printf
(
"... test SMPCQ enqueue at UINT_MAX overflow
\n
"
);
config
.
maxopen_scale
=
0
;
SPMCQ_Init
();
spmcq
.
head
=
spmcq
.
tail
=
UINT_MAX
-
2
;
assert
(
SPMCQ_Enq
(
NULL
));
assert
(
SPMCQ_Enq
(
NULL
));
assert
(
SPMCQ_Enq
(
NULL
));
assert
(
SPMCQ_Enq
(
NULL
));
assert
(
SPMCQ_Enq
(
NULL
));
assert
(
SPMCQ_Enq
(
NULL
));
assert
(
SPMCQ_Enq
(
NULL
));
assert
(
spmcq_len
()
==
7
);
printf
(
"%s: 1 test run
\n
"
,
argv
[
0
]);
exit
(
0
);
}
#endif
trackrdrd/src/test/Makefile.am
View file @
ef08fad8
INCLUDES
=
-I
$(VARNISHSRC)
/include
-I
$(VARNISHSRC)
@AMQ_CFLAGS@
TESTS
=
test_parse test_data test_mq test_spmcq test_spmcq_loop.sh
\
test_worker regress.sh
test_
spmcq_len test_
worker regress.sh
check_PROGRAMS
=
test_parse test_data test_mq test_spmcq test_worker
check_PROGRAMS
=
test_parse test_data test_mq test_spmcq test_spmcq_len
\
test_worker
test_parse_SOURCES
=
\
minunit.h
\
...
...
@@ -42,6 +43,16 @@ test_spmcq_LDADD = \
$(VARNISHSRC)
/lib/libvarnish/libvarnish.la
\
../spmcq.
$(OBJEXT)
test_spmcq_len_SOURCES
=
\
$(VARNISHSRC)
/lib/libvarnish/libvarnish.la
\
../spmcq.c
\
../trackrdrd.h
test_spmcq_len_LDADD
=
\
$(VARNISHSRC)
/lib/libvarnish/libvarnish.la
test_spmcq_len_CFLAGS
=
-DTEST_DRIVER
test_worker_SOURCES
=
\
minunit.h
\
test_worker.c
\
...
...
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