Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-tus
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
libvmod-tus
Commits
5a2a0c7d
Unverified
Commit
5a2a0c7d
authored
Jan 05, 2024
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add assertions on srv lock held
parent
3a18bfbd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
0 deletions
+25
-0
tus_file.c
src/tus_file.c
+9
-0
tus_server.h
src/tus_server.h
+4
-0
tus_servers.c
src/tus_servers.c
+12
-0
No files found.
src/tus_file.c
View file @
5a2a0c7d
...
...
@@ -384,6 +384,8 @@ tus_file_core_new(struct VPFX(tus_server) *srv,
{
struct
tus_file_core
*
fcore
;
tus_server_AssertLocked
(
srv
);
ALLOC_OBJ
(
fcore
,
VMOD_TUS_FILE_CORE_MAGIC
);
AN
(
fcore
);
fcore
->
server
=
srv
;
...
...
@@ -581,6 +583,7 @@ ref_transfer(struct tus_file_core *fcore)
{
unsigned
r
;
tus_server_AssertLocked
(
fcore
->
server
);
r
=
fcore
->
srvref
;
fcore
->
srvref
=
0
;
...
...
@@ -597,6 +600,7 @@ tus_file_del_shutdown(struct tus_file_core **fcorep)
const
struct
tus_file_core
*
rm
;
TAKE_OBJ_NOTNULL
(
fcore
,
fcorep
,
VMOD_TUS_FILE_CORE_MAGIC
);
tus_server_AssertLocked
(
fcore
->
server
);
AN
(
ref_transfer
(
fcore
));
rm
=
VSPLAY_REMOVE
(
tus_files
,
tus_server_files
(
fcore
->
server
),
...
...
@@ -675,6 +679,7 @@ tus_file_srvref(struct tus_file_core *fcore)
int
r
;
CHECK_OBJ_NOTNULL
(
fcore
,
VMOD_TUS_FILE_CORE_MAGIC
);
tus_server_AssertLocked
(
fcore
->
server
);
r
=
fcore
->
srvref
++
;
// as long as the object can be found, it has one srvref at least
assert
(
r
>
0
);
...
...
@@ -731,6 +736,8 @@ tus_file_add(struct VPFX(tus_server) *srv, int basefd, const char *filename)
const
char
*
err
;
ssize_t
sz
;
tus_server_AssertLocked
(
srv
);
if
(
fstatat
(
basefd
,
filename
,
&
st
,
AT_SYMLINK_NOFOLLOW
))
{
fprintf
(
stderr
,
"tus add stat %s: %d
\n
"
,
filename
,
errno
);
goto
err
;
...
...
@@ -824,6 +831,8 @@ tus_file_load(struct VPFX(tus_server) *srv)
DIR
*
dir
;
struct
dirent
*
ent
;
tus_server_AssertLocked
(
srv
);
dir
=
fdopendir
(
dup
(
basefd
));
AN
(
dir
);
while
((
ent
=
readdir
(
dir
))
!=
NULL
)
{
...
...
src/tus_server.h
View file @
5a2a0c7d
...
...
@@ -43,6 +43,10 @@ const char * tus_server_basedir(const struct VPFX(tus_server) *);
VCL_DURATION
tus_server_expires
(
const
struct
VPFX
(
tus_server
)
*
);
void
tus_server_lock
(
struct
VPFX
(
tus_server
)
*
);
void
tus_server_unlock
(
struct
VPFX
(
tus_server
)
*
);
void
tus_server__assertlocked
(
struct
VPFX
(
tus_server
)
*
s
,
const
char
*
func
,
const
char
*
file
,
int
line
);
#define tus_server_AssertLocked(s) \
tus_server__assertlocked(s, __func__, __FILE__, __LINE__)
VCL_BYTES
tus_server_max
(
const
struct
VPFX
(
tus_server
)
*
s
);
VCL_BYTES
tus_server_multipart
(
const
struct
VPFX
(
tus_server
)
*
s
);
struct
vmod_blobdigest_digest
*
tus_server_digest
(
...
...
src/tus_servers.c
View file @
5a2a0c7d
...
...
@@ -95,6 +95,18 @@ tus_server_unlock(struct VPFX(tus_server) *s)
Lck_Unlock
(
&
s
->
mtx
);
}
void
tus_server__assertlocked
(
struct
VPFX
(
tus_server
)
*
s
,
const
char
*
func
,
const
char
*
file
,
int
line
)
{
CHECK_OBJ_NOTNULL
(
s
,
VMOD_TUS_SERVER_MAGIC
);
if
(
!
Lck__Held
(
&
s
->
mtx
))
VAS_Fail
(
func
,
file
,
line
,
"Lck__Held(&s->mtx)"
,
VAS_ASSERT
);
if
(
!
Lck__Owned
(
&
s
->
mtx
))
VAS_Fail
(
func
,
file
,
line
,
"Lck__Owned(&s->mtx)"
,
VAS_ASSERT
);
}
VCL_BYTES
tus_server_max
(
const
struct
VPFX
(
tus_server
)
*
s
)
{
...
...
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