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
67148994
Unverified
Commit
67148994
authored
Jan 05, 2024
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use a varnish lock for struct fcore
to be able to use Lck_AssertHeld()
parent
945e754f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
23 deletions
+22
-23
tus_file.c
src/tus_file.c
+15
-20
tus_file.h
src/tus_file.h
+6
-1
tus_file_exp.c
src/tus_file_exp.c
+1
-2
No files found.
src/tus_file.c
View file @
67148994
...
...
@@ -58,7 +58,6 @@ 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
);
/*
* ------------------------------------------------------------
* specific to TUS_CONCAT
...
...
@@ -123,7 +122,6 @@ tus_file_final_concat(struct VPFX(tus_server) *srv,
const
struct
tus_file_disk
*
pdisk
;
struct
vsb
*
vsb
;
unsigned
i
,
n
=
0
;
struct
timespec
ts
;
ssize_t
length
=
0
;
size_t
l
,
ml
;
...
...
@@ -153,9 +151,6 @@ tus_file_final_concat(struct VPFX(tus_server) *srv,
if
(
n
==
0
)
goto
err
;
// wait for parts to become ready
AZ
(
clock_gettime
(
CLOCK_REALTIME
,
&
ts
));
ts
.
tv_sec
+=
READY_TIMEOUT
;
for
(
i
=
0
;
i
<
n
;
i
++
)
{
part
=
parts
[
i
];
AN
(
part
);
...
...
@@ -167,13 +162,13 @@ tus_file_final_concat(struct VPFX(tus_server) *srv,
continue
;
}
AZ
(
pthread_mutex_lock
(
&
part
->
mtx
)
);
Lck_Lock
(
&
part
->
mtx
);
errno
=
EINTR
;
while
(
part
->
ptr
==
NULL
&&
errno
==
EINTR
)
{
errno
=
pthread_cond_timedwai
t
(
&
part
->
cond
,
&
part
->
mtx
,
&
ts
);
errno
=
Lck_CondWaitTimeou
t
(
&
part
->
cond
,
&
part
->
mtx
,
READY_TIMEOUT
);
}
AZ
(
pthread_mutex_unlock
(
&
part
->
mtx
)
);
Lck_Unlock
(
&
part
->
mtx
);
if
(
part
->
ptr
==
NULL
)
goto
err
;
assert
(
TFCP_READABLE
(
part
->
ptr_type
));
...
...
@@ -394,7 +389,7 @@ tus_file_core_new(struct VPFX(tus_server) *srv,
fcore
->
server
=
srv
;
fcore
->
fd
=
fd
;
REPLACE
(
fcore
->
filename
,
filename
);
AZ
(
pthread_mutex_init
(
&
fcore
->
mtx
,
NULL
)
);
Lck_New
(
&
fcore
->
mtx
,
lck_fcore
);
AZ
(
pthread_cond_init
(
&
fcore
->
cond
,
NULL
));
fcore
->
disk
=
fdisk
;
fcore
->
srvref
=
1
;
...
...
@@ -404,7 +399,7 @@ tus_file_core_new(struct VPFX(tus_server) *srv,
return
(
fcore
);
}
AZ
(
pthread_mutex_destroy
(
&
fcore
->
mtx
)
);
Lck_Delete
(
&
fcore
->
mtx
);
AZ
(
pthread_cond_destroy
(
&
fcore
->
cond
));
REPLACE
(
fcore
->
filename
,
NULL
);
FREE_OBJ
(
fcore
);
...
...
@@ -541,7 +536,7 @@ tus_file_fini(struct tus_file_core *fcore)
AZ
(
fdisk
);
assert
(
fcore
->
fd
==
-
1
);
AZ
(
pthread_mutex_destroy
(
&
fcore
->
mtx
)
);
Lck_Delete
(
&
fcore
->
mtx
);
AZ
(
pthread_cond_destroy
(
&
fcore
->
cond
));
REPLACE
(
fcore
->
filename
,
NULL
);
FREE_OBJ
(
fcore
);
...
...
@@ -561,7 +556,7 @@ tus_file_trylock(struct tus_file_core **fcorep)
CHECK_OBJ
(
fcore
,
VMOD_TUS_FILE_CORE_MAGIC
);
do
{
err
=
pthread_mutex_t
rylock
(
&
fcore
->
mtx
);
err
=
Lck_T
rylock
(
&
fcore
->
mtx
);
if
(
err
==
0
)
return
(
err
);
}
while
(
err
==
EINTR
);
...
...
@@ -577,7 +572,7 @@ tus_file_unlock(struct tus_file_core **fcorep)
struct
tus_file_core
*
fcore
;
TAKE_OBJ_NOTNULL
(
fcore
,
fcorep
,
VMOD_TUS_FILE_CORE_MAGIC
);
AZ
(
pthread_mutex_unlock
(
&
fcore
->
mtx
)
);
Lck_Unlock
(
&
fcore
->
mtx
);
}
/* under both fcore and server mtx */
...
...
@@ -651,7 +646,7 @@ tus_file_exp(struct tus_file_core **fcorep)
TAKE_OBJ_NOTNULL
(
fcore
,
fcorep
,
VMOD_TUS_FILE_CORE_MAGIC
);
AZ
(
pthread_mutex_lock
(
&
fcore
->
mtx
)
);
Lck_Lock
(
&
fcore
->
mtx
);
tus_file_remove
(
fcore
);
(
void
)
tus_file_unref_locked
(
fcore
);
}
...
...
@@ -666,7 +661,7 @@ tus_file_shutdown(struct VPFX(tus_server) *srv)
tus_server_lock
(
srv
);
VSPLAY_FOREACH
(
fcore
,
tus_files
,
files
)
{
REPLACE
(
fcore
->
filename
,
NULL
);
// prevent unlink
AZ
(
pthread_mutex_lock
(
&
fcore
->
mtx
)
);
Lck_Lock
(
&
fcore
->
mtx
);
tus_file_del_shutdown
(
&
fcore
);
AZ
(
fcore
);
}
...
...
@@ -693,9 +688,9 @@ tus_file_ref(struct tus_file_core *fcore)
int
r
;
CHECK_OBJ_NOTNULL
(
fcore
,
VMOD_TUS_FILE_CORE_MAGIC
);
AZ
(
pthread_mutex_lock
(
&
fcore
->
mtx
)
);
Lck_Lock
(
&
fcore
->
mtx
);
r
=
fcore
->
ref
++
+
fcore
->
srvref
;
AZ
(
pthread_mutex_unlock
(
&
fcore
->
mtx
)
);
Lck_Unlock
(
&
fcore
->
mtx
);
assert
(
r
>=
0
);
return
(
r
);
}
...
...
@@ -709,7 +704,7 @@ tus_file_unref_locked(struct tus_file_core *fcore)
CHECK_OBJ_NOTNULL
(
fcore
,
VMOD_TUS_FILE_CORE_MAGIC
);
r
=
--
fcore
->
ref
+
fcore
->
srvref
;
AZ
(
pthread_mutex_unlock
(
&
fcore
->
mtx
)
);
Lck_Unlock
(
&
fcore
->
mtx
);
assert
(
r
>=
0
);
if
(
r
==
0
)
tus_file_fini
(
fcore
);
...
...
@@ -721,7 +716,7 @@ tus_file_unref(struct tus_file_core *fcore)
{
CHECK_OBJ_NOTNULL
(
fcore
,
VMOD_TUS_FILE_CORE_MAGIC
);
AZ
(
pthread_mutex_lock
(
&
fcore
->
mtx
)
);
Lck_Lock
(
&
fcore
->
mtx
);
return
(
tus_file_unref_locked
(
fcore
));
}
...
...
src/tus_file.h
View file @
67148994
...
...
@@ -35,6 +35,11 @@
#include "tus_server.h"
/* ============================================================
* vmod shared object globals in vmod_tus.c
*/
extern
struct
VSC_lck
*
lck_fcore
;
#define TUS_PATH_MAX PATH_MAX
#define TUS_METADATA_MAX 2048u // ballpark of AWS S3 metadata
...
...
@@ -84,7 +89,7 @@ struct tus_file_core {
VSPLAY_ENTRY
(
tus_file_core
)
entry
;
pthread_mutex_t
mtx
;
struct
lock
mtx
;
pthread_cond_t
cond
;
struct
tus_file_disk
*
disk
;
unsigned
exp_idx
;
...
...
src/tus_file_exp.c
View file @
67148994
...
...
@@ -33,8 +33,7 @@
#include <unistd.h>
#include <stdio.h>
#include "vdef.h"
#include "vrt.h"
#include "cache/cache.h" // for struct lock
#include "miniobj.h"
#include "vas.h"
#include "vbh.h"
...
...
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