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
a92058b2
Unverified
Commit
a92058b2
authored
Jan 05, 2024
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Straighten fcore locking
parent
ec06de08
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
0 deletions
+23
-0
tus_file.c
src/tus_file.c
+23
-0
No files found.
src/tus_file.c
View file @
a92058b2
...
...
@@ -58,6 +58,8 @@ static unsigned tus_file_srvref(struct tus_file_core *);
static
unsigned
tus_file_unref
(
struct
tus_file_core
*
);
static
void
tus_touch
(
const
struct
tus_file_core
*
,
VCL_DURATION
);
#define Lck_AssertUnlocked(a) AZ(Lck__Held(a))
/*
* ------------------------------------------------------------
* specific to TUS_CONCAT
...
...
@@ -211,6 +213,7 @@ tus_file_final_birth(struct tus_file_core **fcorep,
struct
vsb
*
vsb
;
TAKE_OBJ_NOTNULL
(
fcore
,
fcorep
,
VMOD_TUS_FILE_CORE_MAGIC
);
Lck_AssertHeld
(
&
fcore
->
mtx
);
CHECK_OBJ_NOTNULL
(
embryo
,
CONCAT_EMBRYO_MAGIC
);
fdisk
=
fcore
->
disk
;
CHECK_OBJ_NOTNULL
(
fdisk
,
VMOD_TUS_FILE_DISK_MAGIC
);
...
...
@@ -258,6 +261,9 @@ tus_file_final_fini(struct tus_file_core *fcore)
{
struct
tus_concat
*
concat
;
CHECK_OBJ_NOTNULL
(
fcore
,
VMOD_TUS_FILE_CORE_MAGIC
);
Lck_AssertHeld
(
&
fcore
->
mtx
);
if
(
fcore
->
ptr
==
NULL
)
return
;
...
...
@@ -312,6 +318,9 @@ tus_file_final_urls(VRT_CTX, const struct tus_file_core *fcore, const char *pfx)
struct
vsb
vsb
[
1
];
unsigned
i
;
CHECK_OBJ_NOTNULL
(
fcore
,
VMOD_TUS_FILE_CORE_MAGIC
);
Lck_AssertHeld
(
&
fcore
->
mtx
);
if
(
fcore
->
ptr
==
NULL
)
return
(
NULL
);
...
...
@@ -343,6 +352,7 @@ tus_file_open(struct tus_file_core *fcore)
int
basefd
;
CHECK_OBJ_NOTNULL
(
fcore
,
VMOD_TUS_FILE_CORE_MAGIC
);
Lck_AssertHeld
(
&
fcore
->
mtx
);
if
(
fcore
->
fd
<
0
)
{
basefd
=
tus_server_basefd
(
fcore
->
server
);
...
...
@@ -357,6 +367,7 @@ static void
tus_file_close
(
struct
tus_file_core
*
fcore
)
{
CHECK_OBJ_NOTNULL
(
fcore
,
VMOD_TUS_FILE_CORE_MAGIC
);
Lck_AssertHeld
(
&
fcore
->
mtx
);
if
(
fcore
->
fd
==
-
1
)
return
;
...
...
@@ -425,6 +436,7 @@ tus_file_complete(struct tus_file_core *fcore)
struct
tus_file_disk
*
fdisk
;
CHECK_OBJ_NOTNULL
(
fcore
,
VMOD_TUS_FILE_CORE_MAGIC
);
Lck_AssertHeld
(
&
fcore
->
mtx
);
fdisk
=
fcore
->
disk
;
CHECK_TUS_FILE_DISK
(
fdisk
);
...
...
@@ -451,6 +463,7 @@ tus_file_mmap(struct tus_file_core *fcore)
int
prot
=
PROT_READ
;
CHECK_OBJ_NOTNULL
(
fcore
,
VMOD_TUS_FILE_CORE_MAGIC
);
Lck_AssertHeld
(
&
fcore
->
mtx
);
fdisk
=
fcore
->
disk
;
CHECK_TUS_FILE_DISK
(
fdisk
);
...
...
@@ -511,6 +524,9 @@ tus_file_fini(struct tus_file_core *fcore)
{
struct
tus_file_disk
*
fdisk
;
CHECK_OBJ_NOTNULL
(
fcore
,
VMOD_TUS_FILE_CORE_MAGIC
);
Lck_AssertUnlocked
(
&
fcore
->
mtx
);
fdisk
=
fcore
->
disk
;
CHECK_TUS_FILE_DISK
(
fdisk
);
AZ
(
fcore
->
srvref
);
...
...
@@ -583,7 +599,10 @@ ref_transfer(struct tus_file_core *fcore)
{
unsigned
r
;
CHECK_OBJ_NOTNULL
(
fcore
,
VMOD_TUS_FILE_CORE_MAGIC
);
tus_server_AssertLocked
(
fcore
->
server
);
Lck_AssertHeld
(
&
fcore
->
mtx
);
r
=
fcore
->
srvref
;
fcore
->
srvref
=
0
;
...
...
@@ -601,6 +620,7 @@ tus_file_del_shutdown(struct tus_file_core **fcorep)
TAKE_OBJ_NOTNULL
(
fcore
,
fcorep
,
VMOD_TUS_FILE_CORE_MAGIC
);
tus_server_AssertLocked
(
fcore
->
server
);
Lck_AssertHeld
(
&
fcore
->
mtx
);
AN
(
ref_transfer
(
fcore
));
rm
=
VSPLAY_REMOVE
(
tus_files
,
tus_server_files
(
fcore
->
server
),
...
...
@@ -707,6 +727,7 @@ tus_file_unref_locked(struct tus_file_core *fcore)
int
r
;
CHECK_OBJ_NOTNULL
(
fcore
,
VMOD_TUS_FILE_CORE_MAGIC
);
Lck_AssertHeld
(
&
fcore
->
mtx
);
r
=
--
fcore
->
ref
+
fcore
->
srvref
;
Lck_Unlock
(
&
fcore
->
mtx
);
...
...
@@ -810,7 +831,9 @@ tus_file_add(struct VPFX(tus_server) *srv, int basefd, const char *filename)
fcore
=
tus_file_core_new
(
srv
,
fd
,
filename
,
fdisk
);
if
(
fcore
!=
NULL
)
{
Lck_Lock
(
&
fcore
->
mtx
);
tus_file_close
(
fcore
);
Lck_Unlock
(
&
fcore
->
mtx
);
return
;
}
...
...
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