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
797ae6a3
Unverified
Commit
797ae6a3
authored
Sep 09, 2021
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move locking to tus_file_del()
parent
2966db6a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
17 deletions
+28
-17
tus_file.c
src/tus_file.c
+28
-9
tus_file_exp.c
src/tus_file_exp.c
+0
-4
tus_request.c
src/tus_request.c
+0
-4
No files found.
src/tus_file.c
View file @
797ae6a3
...
...
@@ -209,7 +209,6 @@ tus_file_final_birth(struct tus_file_core **fcorep,
struct
concat_embryo
*
embryo
)
{
struct
tus_file_core
*
fcore
;
struct
VPFX
(
tus_server
)
*
srv
;
struct
tus_file_disk
*
fdisk
;
struct
vsb
*
vsb
;
...
...
@@ -226,12 +225,8 @@ tus_file_final_birth(struct tus_file_core **fcorep,
vsb
=
embryo
->
spec_vsb
;
assert
(
fcore
->
fd
>=
0
);
if
(
write
(
fcore
->
fd
,
VSB_data
(
vsb
),
VSB_len
(
vsb
))
<
0
)
{
srv
=
fcore
->
server
;
tus_server_lock
(
srv
);
if
(
write
(
fcore
->
fd
,
VSB_data
(
vsb
),
VSB_len
(
vsb
))
<
0
)
tus_file_del
(
&
fcore
);
tus_server_unlock
(
srv
);
}
VSB_destroy
(
&
vsb
);
memset
(
embryo
,
0
,
sizeof
*
embryo
);
*
fcorep
=
fcore
;
...
...
@@ -519,17 +514,39 @@ tus_file_unlock(struct tus_file_core **fcorep)
AZ
(
pthread_mutex_unlock
(
&
fcore
->
mtx
));
}
/* caller holds tus_server mtx */
static
void
tus_file_del_locked
(
struct
tus_file_core
**
fcorep
)
{
struct
tus_file_core
*
fcore
;
const
struct
tus_file_core
*
rm
;
TAKE_OBJ_NOTNULL
(
fcore
,
fcorep
,
VMOD_TUS_FILE_CORE_MAGIC
);
rm
=
VSPLAY_REMOVE
(
tus_files
,
tus_server_files
(
fcore
->
server
),
fcore
);
assert
(
rm
==
fcore
);
tus_exp_delete
(
fcore
);
(
void
)
tus_file_unref_locked
(
fcore
);
}
/* under tus_server mtx to protect tus_files */
void
tus_file_del
(
struct
tus_file_core
**
fcorep
)
{
struct
VPFX
(
tus_server
)
*
srv
;
struct
tus_file_core
*
fcore
;
const
struct
tus_file_core
*
rm
;
TAKE_OBJ_NOTNULL
(
fcore
,
fcorep
,
VMOD_TUS_FILE_CORE_MAGIC
);
srv
=
fcore
->
server
;
tus_server_lock
(
srv
);
rm
=
VSPLAY_REMOVE
(
tus_files
,
tus_server_files
(
srv
),
fcore
);
tus_server_unlock
(
srv
);
rm
=
VSPLAY_REMOVE
(
tus_files
,
tus_server_files
(
fcore
->
server
),
fcore
);
assert
(
rm
==
fcore
);
tus_exp_delete
(
fcore
);
...
...
@@ -543,12 +560,14 @@ tus_file_shutdown(struct VPFX(tus_server) *srv)
struct
tus_file_core
*
fcore
;
struct
tus_files
*
files
=
tus_server_files
(
srv
);
tus_server_lock
(
srv
);
VSPLAY_FOREACH
(
fcore
,
tus_files
,
files
)
{
REPLACE
(
fcore
->
filename
,
NULL
);
// prevent unlink
AZ
(
pthread_mutex_lock
(
&
fcore
->
mtx
));
tus_file_del
(
&
fcore
);
tus_file_del
_locked
(
&
fcore
);
AZ
(
fcore
);
}
tus_server_unlock
(
srv
);
}
#ifdef BAD_IDEA
...
...
src/tus_file_exp.c
View file @
797ae6a3
...
...
@@ -70,7 +70,6 @@ fcore_when(const void *p)
static
void
*
tus_exp_thread
(
void
*
p
)
{
struct
VPFX
(
tus_server
)
*
srv
;
struct
tus_file_core
*
fcore
;
struct
timespec
ts
;
struct
tus_exp
*
e
;
...
...
@@ -101,16 +100,13 @@ tus_exp_thread(void *p)
AZ
(
pthread_mutex_unlock
(
&
e
->
mtx
));
AN
(
fcore
);
srv
=
fcore
->
server
;
while
(
fcore
!=
NULL
)
{
struct
tus_file_core
*
has_lock
=
fcore
;
tus_server_lock
(
srv
);
(
void
)
tus_file_trylock
(
&
has_lock
);
if
(
has_lock
!=
NULL
)
tus_file_del
(
&
fcore
);
tus_server_unlock
(
srv
);
if
(
has_lock
==
NULL
)
{
fprintf
(
stderr
,
"tus expiry: fcore %p locked
\n
"
,
...
...
src/tus_request.c
View file @
797ae6a3
...
...
@@ -362,9 +362,7 @@ tus_request(VRT_CTX, struct VPFX(tus_server) *tussrv,
return
(
0
);
}
AZ
(
pthread_mutex_lock
(
&
tussrv
->
mtx
));
tus_file_del
(
&
r
->
fcore
);
AZ
(
pthread_mutex_unlock
(
&
tussrv
->
mtx
));
AZ
(
r
->
fcore
);
r
->
status
=
204
;
}
...
...
@@ -492,9 +490,7 @@ tus_request(VRT_CTX, struct VPFX(tus_server) *tussrv,
}
if
(
r
->
status
==
413
)
{
AZ
(
pthread_mutex_lock
(
&
tussrv
->
mtx
));
tus_file_del
(
&
r
->
fcore
);
AZ
(
pthread_mutex_unlock
(
&
tussrv
->
mtx
));
AZ
(
r
->
fcore
);
return
(
0
);
}
...
...
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