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
e3570b53
Unverified
Commit
e3570b53
authored
Sep 08, 2020
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make fdatasync() explicit
parent
bcbf8d56
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
4 deletions
+44
-4
tus_file.c
src/tus_file.c
+13
-4
tus_file.h
src/tus_file.h
+1
-0
vmod_tus.c
src/vmod_tus.c
+15
-0
vmod_tus.vcc
src/vmod_tus.vcc
+14
-0
plain.vtc
src/vtc/plain.vtc
+1
-0
No files found.
src/tus_file.c
View file @
e3570b53
...
...
@@ -949,11 +949,9 @@ tus_body_to_file(VRT_CTX, struct tus_file_core *fcore)
if
(
written
<
0
&&
errno
==
EFBIG
)
{
fdisk
->
upload_offset
=
fdisk
->
upload_length
=
suck
.
max
;
AZ
(
ftruncate
(
fcore
->
fd
,
header_size
+
suck
.
max
));
AZ
(
fdatasync
(
fcore
->
fd
));
return
(
413
);
}
AZ
(
fdatasync
(
fcore
->
fd
));
if
(
suck
.
chksum
==
NULL
)
{
if
(
written
>=
0
)
return
(
204
);
...
...
@@ -966,7 +964,6 @@ tus_body_to_file(VRT_CTX, struct tus_file_core *fcore)
fcore
->
disk
->
upload_offset
=
offset_saved
;
AZ
(
ftruncate
(
fcore
->
fd
,
header_size
+
offset_saved
));
AZ
(
fdatasync
(
fcore
->
fd
));
return
(
460
);
}
...
...
@@ -998,8 +995,20 @@ tus_file_done(struct tus_file_core *fcore, struct tus_file_disk *fdisk, const ch
fd
=
tus_file_open
(
fcore
);
if
(
fd
>=
0
)
{
AZ
(
ftruncate
(
fd
,
header_size
));
AZ
(
fdatasync
(
fd
));
tus_file_close
(
fcore
);
}
return
(
1
);
}
void
tus_file_sync
(
struct
tus_file_core
*
fcore
)
{
if
(
fcore
==
NULL
)
return
;
CHECK_OBJ_NOTNULL
(
fcore
,
VMOD_TUS_FILE_CORE_MAGIC
);
if
(
fcore
->
fd
<
0
)
return
;
AZ
(
fdatasync
(
fcore
->
fd
));
}
src/tus_file.h
View file @
e3570b53
...
...
@@ -175,3 +175,4 @@ void
tus_file_final_abort
(
struct
concat_embryo
*
embryo
);
VCL_BOOL
tus_file_done
(
struct
tus_file_core
*
,
struct
tus_file_disk
*
,
const
char
*
);
void
tus_file_sync
(
struct
tus_file_core
*
);
src/vmod_tus.c
View file @
e3570b53
...
...
@@ -532,3 +532,18 @@ tus_server_metadata(VRT_CTX, struct VPFX(tus_server) *tussrv,
return
(
b
);
}
VCL_VOID
tus_server_sync
(
VRT_CTX
,
struct
VPFX
(
tus_server
)
*
tussrv
)
{
struct
tus_response
*
r
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
tussrv
,
VMOD_TUS_SERVER_MAGIC
);
r
=
tus_task_use
(
ctx
,
tussrv
);
if
(
r
==
NULL
)
return
;
tus_file_sync
(
r
->
fcore
);
}
src/vmod_tus.vcc
View file @
e3570b53
...
...
@@ -216,5 +216,19 @@ Extract *key* from metadata and return the corresponding value decoded.
Only available if vmod_blob is available (see `Hashes` _) and on the
client side after `xserver.recv()`_ was called from ``vcl_recv {}``.
$Method VOID .sync()
For lowest latencies, vmod_tus stores data in files opened without any
additional options affecting caching such that the operating system is
free to write data delayed. This could, in turn, lead to upload data
and/or state to be lost or reverted to an earlier state when the
system crashes.
When the `xserver.sync()`_ method is called, an `fdatasync(2)` call is
issued on the file backing the current upload, such that its current
state is flushed to stable storage (given that the underlying file
does provide stable storage).
SEE ALSO
========vcl\(7),varnishd\(1)
src/vtc/plain.vtc
View file @
e3570b53
...
...
@@ -73,6 +73,7 @@ varnish v1 -vcl+backend {
if (resp.status == 4200) {
call meta;
tmp.synth();
tmp.sync();
return (deliver);
}
}
...
...
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