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
8e116613
Unverified
Commit
8e116613
authored
May 20, 2022
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Give the fcore ptr a type
parent
d2bec9e9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
+22
-0
tus_file.c
src/tus_file.c
+11
-0
tus_file.h
src/tus_file.h
+11
-0
No files found.
src/tus_file.c
View file @
8e116613
...
...
@@ -162,6 +162,7 @@ tus_file_final_concat(struct VPFX(tus_server) *srv,
pdisk
=
part
->
disk
;
AN
(
pdisk
);
if
(
part
->
ptr
!=
NULL
)
{
assert
(
TFCP_READABLE
(
part
->
ptr_type
));
length
+=
pdisk
->
upload_length
;
continue
;
}
...
...
@@ -175,6 +176,7 @@ tus_file_final_concat(struct VPFX(tus_server) *srv,
AZ
(
pthread_mutex_unlock
(
&
part
->
mtx
));
if
(
part
->
ptr
==
NULL
)
goto
err
;
assert
(
TFCP_READABLE
(
part
->
ptr_type
));
length
+=
pdisk
->
upload_length
;
}
...
...
@@ -218,10 +220,12 @@ tus_file_final_birth(struct tus_file_core **fcorep,
fdisk
=
fcore
->
disk
;
CHECK_OBJ_NOTNULL
(
fdisk
,
VMOD_TUS_FILE_DISK_MAGIC
);
assert
(
fcore
->
ptr_type
==
TFCP_INVALID
);
AZ
(
fcore
->
ptr
);
AZ
(
fcore
->
len
);
fcore
->
ptr
=
embryo
->
concat
;
fcore
->
len
=
embryo
->
concat_l
;
fcore
->
ptr_type
=
TFCP_CONCAT
;
fdisk
->
upload_length
=
fdisk
->
upload_offset
=
embryo
->
upload_length
;
vsb
=
embryo
->
spec_vsb
;
...
...
@@ -262,8 +266,10 @@ tus_file_final_fini(struct tus_file_core *fcore)
if
(
fcore
->
ptr
==
NULL
)
return
;
assert
(
fcore
->
ptr_type
==
TFCP_CONCAT
);
CAST_OBJ_NOTNULL
(
concat
,
fcore
->
ptr
,
TUS_CONCAT_MAGIC
);
fcore
->
ptr
=
NULL
;
fcore
->
ptr_type
==
TFCP_INVALID
;
assert
(
fcore
->
len
>=
sizeof
*
concat
);
fcore
->
len
=
0
;
...
...
@@ -294,6 +300,7 @@ tus_concat_hash(VRT_CTX, const struct VPFX(tus_server) *srv,
part
=
concat
->
cores
[
i
];
if
(
part
->
len
==
0
)
continue
;
assert
(
TFCP_READABLE
(
part
->
ptr_type
));
AN
(
part
->
ptr
);
tus_chksum_update
(
ctx
,
c
,
part
->
ptr
,
part
->
len
);
}
...
...
@@ -315,6 +322,7 @@ tus_file_final_urls(VRT_CTX, const struct tus_file_core *fcore, const char *pfx)
WS_VSB_new
(
vsb
,
ctx
->
ws
);
VSB_cat
(
vsb
,
"final;"
);
assert
(
fcore
->
ptr_type
==
TFCP_CONCAT
);
CAST_OBJ_NOTNULL
(
concat
,
fcore
->
ptr
,
TUS_CONCAT_MAGIC
);
for
(
i
=
0
;
i
<
concat
->
n
;
i
++
)
{
part
=
concat
->
cores
[
i
];
...
...
@@ -420,12 +428,14 @@ tus_file_mmap(struct tus_file_core *fcore)
CHECK_TUS_FILE_DISK
(
fdisk
);
assert
(
fdisk
->
upload_length
==
fdisk
->
upload_offset
);
assert
(
fcore
->
ptr_type
==
TFCP_INVALID
);
AZ
(
fcore
->
ptr
);
AZ
(
fcore
->
len
);
fcore
->
ptr
=
mmap
(
NULL
,
fdisk
->
upload_length
,
PROT_READ
,
MAP_SHARED
|
MAP_NORESERVE
,
fcore
->
fd
,
header_size
);
AN
(
fcore
->
ptr
);
fcore
->
ptr_type
=
TFCP_MMAP_RO
;
tus_file_close
(
fcore
);
fcore
->
len
=
fdisk
->
upload_length
;
}
...
...
@@ -467,6 +477,7 @@ tus_file_fini(struct tus_file_core *fcore)
if
(
fdisk
->
type
==
TUS_FINAL
)
{
tus_file_final_fini
(
fcore
);
}
else
if
(
fcore
->
ptr
!=
NULL
)
{
fcore
->
ptr_type
=
TFCP_INVALID
;
(
void
)
munmap
(
fcore
->
ptr
,
fcore
->
len
);
fcore
->
ptr
=
NULL
;
fcore
->
len
=
0
;
...
...
src/tus_file.h
View file @
8e116613
...
...
@@ -65,6 +65,16 @@ struct tus_file_disk {
enum
tus_f_type
type
;
};
/* what ptr points to */
enum
tus_file_core_ptr
{
TFCP_INVALID
=
0
,
TFCP_CONCAT
,
#define TFCP_READABLE(tfcp) ((tfcp) >= TFCP_ZERO)
TFCP_ZERO
,
TFCP_MMAP_RO
,
TFCP_MMAP_RW
};
struct
tus_file_core
{
unsigned
magic
;
#define VMOD_TUS_FILE_CORE_MAGIC 0x105f11e0
...
...
@@ -95,6 +105,7 @@ struct tus_file_core {
*/
int
ref
;
enum
tus_file_core_ptr
ptr_type
;
/* final mmap or concats list */
void
*
ptr
;
size_t
len
;
...
...
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