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
bd297993
Unverified
Commit
bd297993
authored
Jan 03, 2021
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish based on Flexelint analysis
parent
5ea6e972
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
118 additions
and
78 deletions
+118
-78
Makefile.am
src/Makefile.am
+1
-0
tus_blob.c
src/tus_blob.c
+2
-0
tus_file.c
src/tus_file.c
+26
-16
tus_file.h
src/tus_file.h
+2
-4
tus_file_exp.c
src/tus_file_exp.c
+14
-13
tus_file_exp_setup.h
src/tus_file_exp_setup.h
+30
-0
tus_hdr.c
src/tus_hdr.c
+2
-0
tus_hex.c
src/tus_hex.c
+1
-1
tus_hex.h
src/tus_hex.h
+0
-1
tus_request.c
src/tus_request.c
+4
-6
tus_response.c
src/tus_response.c
+4
-7
tus_response.h
src/tus_response.h
+1
-2
tus_server.h
src/tus_server.h
+1
-1
tus_servers.c
src/tus_servers.c
+2
-3
tus_servers.h
src/tus_servers.h
+2
-2
tus_stv.c
src/tus_stv.c
+5
-6
vmod_get_h.c
src/vmod_get_h.c
+11
-3
vmod_tus.c
src/vmod_tus.c
+10
-13
No files found.
src/Makefile.am
View file @
bd297993
...
...
@@ -52,6 +52,7 @@ libvmod_tus_la_SOURCES += \
tus_file.h
\
tus_file_exp.c
\
tus_file_exp.h
\
tus_file_exp_setup.h
\
tus_hdr.c
\
tus_hdr.h
\
tus_hex.c
\
...
...
src/tus_blob.c
View file @
bd297993
...
...
@@ -136,6 +136,8 @@ tus_chksum_init(VRT_CTX) {
int
tus_chksum_fini
(
VRT_CTX
)
{
(
void
)
ctx
;
#define HENUM(t, b) if (digest_ ## t != NULL) \
vmod_blobdigest->digest__fini(&digest_ ## t);
#include "tbl_hash_enum.h"
...
...
src/tus_file.c
View file @
bd297993
...
...
@@ -47,13 +47,16 @@
#include "tus_hex.h"
#include "tus_file_exp.h"
VSPLAY_GENERATE
(
tus_files
,
tus_file_core
,
entry
,
tus_file_cmp
)
;
VSPLAY_GENERATE
(
tus_files
,
tus_file_core
,
entry
,
tus_file_cmp
)
#define TUS_FILE_PFX "tus_"
#define TUS_FILE_RAND 16
#define TUS_FILE_SUFF "_XXXXXX"
static
uintmax_t
header_size
;
static
unsigned
tus_file_ref
(
struct
tus_file_core
*
);
static
unsigned
tus_file_unref
(
struct
tus_file_core
*
);
/*
* ------------------------------------------------------------
...
...
@@ -101,7 +104,7 @@ tus_file_final_concat_parse(const char *spec)
spec
=
strchr
(
spec
,
' '
);
}
VSB_bcat
(
vsb
,
"
\0
"
,
1
);
VSB_finish
(
vsb
);
AZ
(
VSB_finish
(
vsb
)
);
return
(
vsb
);
...
...
@@ -114,14 +117,13 @@ struct concat_embryo *
tus_file_final_concat
(
struct
VPFX
(
tus_server
)
*
srv
,
struct
concat_embryo
*
embryo
,
const
char
*
spec
)
{
struct
tus_file_core
*
part
,
*
parts
[
MAX_CONCAT
];
struct
tus_file_core
*
part
,
*
parts
[
MAX_CONCAT
]
=
{
NULL
}
;
struct
tus_concat
*
concat
;
const
struct
tus_file_disk
*
pdisk
;
struct
vsb
*
vsb
;
unsigned
i
,
n
=
0
;
struct
timespec
ts
;
ssize_t
length
=
0
;
int
errno
;
size_t
l
,
ml
;
vsb
=
tus_file_final_concat_parse
(
spec
);
...
...
@@ -155,6 +157,7 @@ tus_file_final_concat(struct VPFX(tus_server) *srv,
ts
.
tv_sec
+=
READY_TIMEOUT
;
for
(
i
=
0
;
i
<
n
;
i
++
)
{
part
=
parts
[
i
];
AN
(
part
);
pdisk
=
part
->
disk
;
AN
(
pdisk
);
if
(
part
->
ptr
!=
NULL
)
{
...
...
@@ -485,13 +488,13 @@ void
tus_file_del
(
struct
tus_file_core
**
fcorep
)
{
struct
tus_file_core
*
fcore
;
const
struct
tus_file_core
*
r
emove
;
const
struct
tus_file_core
*
r
m
;
TAKE_OBJ_NOTNULL
(
fcore
,
fcorep
,
VMOD_TUS_FILE_CORE_MAGIC
);
r
emove
=
VSPLAY_REMOVE
(
tus_files
,
tus_server_files
(
fcore
->
server
),
r
m
=
VSPLAY_REMOVE
(
tus_files
,
tus_server_files
(
fcore
->
server
),
fcore
);
assert
(
r
emove
==
fcore
);
assert
(
r
m
==
fcore
);
tus_exp_delete
(
fcore
);
(
void
)
tus_file_unref_locked
(
fcore
);
...
...
@@ -502,8 +505,9 @@ void
tus_file_shutdown
(
struct
VPFX
(
tus_server
)
*
srv
)
{
struct
tus_file_core
*
fcore
;
struct
tus_files
*
files
=
tus_server_files
(
srv
);
VSPLAY_FOREACH
(
fcore
,
tus_files
,
tus_server_files
(
srv
)
)
{
VSPLAY_FOREACH
(
fcore
,
tus_files
,
files
)
{
REPLACE
(
fcore
->
filename
,
NULL
);
// prevent unlink
AZ
(
pthread_mutex_lock
(
&
fcore
->
mtx
));
tus_file_del
(
&
fcore
);
...
...
@@ -547,7 +551,7 @@ tus_file_rename_base(struct tus_file_core *fcore, const char *basename)
}
#endif
unsigned
static
unsigned
tus_file_ref
(
struct
tus_file_core
*
fcore
)
{
unsigned
r
;
...
...
@@ -572,7 +576,8 @@ tus_file_unref_locked(struct tus_file_core *fcore)
tus_file_fini
(
fcore
);
return
(
r
);
}
unsigned
static
unsigned
tus_file_unref
(
struct
tus_file_core
*
fcore
)
{
...
...
@@ -698,7 +703,7 @@ tus_file_load(struct VPFX(tus_server) *srv)
}
static
void
tus_touch
(
struct
tus_file_core
*
fcore
,
VCL_DURATION
expires
)
tus_touch
(
const
struct
tus_file_core
*
fcore
,
VCL_DURATION
expires
)
{
struct
tus_file_disk
*
fdisk
;
VCL_TIME
t
=
VTIM_real
();
...
...
@@ -759,7 +764,7 @@ tus_name_rnd(struct vsb *vsb)
char
rnd
[
TUS_FILE_RAND
];
struct
vrt_blob
b
;
VRND_RandomCrypto
(
rnd
,
sizeof
rnd
);
AZ
(
VRND_RandomCrypto
(
rnd
,
sizeof
rnd
)
);
b
.
type
=
0x1055
;
b
.
blob
=
rnd
;
b
.
len
=
sizeof
rnd
;
...
...
@@ -778,7 +783,7 @@ tus_file_new(VRT_CTX, struct VPFX(tus_server) *srv, enum tus_f_type type,
struct
vsb
vsb_path
[
1
];
const
char
*
path
;
const
char
*
filename
;
// relative to base
int
fd
=
-
1
;
int
fd
;
size_t
l
;
if
(
id
!=
NULL
)
{
...
...
@@ -988,12 +993,17 @@ tus_body_to_file(VRT_CTX, struct tus_file_core *fcore)
}
VCL_BOOL
tus_file_done
(
struct
tus_file_core
*
fcore
,
struct
tus_file_disk
*
fdisk
,
const
char
*
url
)
tus_file_done
(
struct
tus_file_core
*
fcore
,
struct
tus_file_disk
*
fdisk
,
const
char
*
url
)
{
int
fd
,
need_truncate
;
size_t
l
=
strlen
(
url
);
size_t
l
;
if
(
url
==
NULL
)
return
(
0
);
if
(
l
>=
TUS_PATH_MAX
)
l
=
strlen
(
url
);
if
(
l
==
0
||
l
>=
TUS_PATH_MAX
)
return
(
0
);
need_truncate
=
(
fdisk
->
location_length
==
0
);
...
...
src/tus_file.h
View file @
bd297993
...
...
@@ -128,10 +128,10 @@ tus_file_cmp(const struct tus_file_core *a,
CHECK_TUS_FILE_DISK
(
aa
);
CHECK_TUS_FILE_DISK
(
bb
);
return
(
strcmp
(
aa
->
url_path
,
bb
->
url_path
));
}
;
}
VSPLAY_HEAD
(
tus_files
,
tus_file_core
);
VSPLAY_PROTOTYPE
(
tus_files
,
tus_file_core
,
entry
,
tus_file_cmp
)
;
VSPLAY_PROTOTYPE
(
tus_files
,
tus_file_core
,
entry
,
tus_file_cmp
)
// tus_file.c
void
tus_file_init
(
void
);
...
...
@@ -143,8 +143,6 @@ struct tus_file_core *tus_file_new(VRT_CTX, struct VPFX(tus_server) *,
struct
tus_file_core
*
tus_file_lookup
(
struct
VPFX
(
tus_server
)
*
,
const
char
*
);
unsigned
tus_body_to_file
(
VRT_CTX
,
struct
tus_file_core
*
);
void
tus_file_mmap
(
struct
tus_file_core
*
);
unsigned
tus_file_ref
(
struct
tus_file_core
*
);
unsigned
tus_file_unref
(
struct
tus_file_core
*
);
#ifdef BAD_IDEA
void
...
...
src/tus_file_exp.c
View file @
bd297993
...
...
@@ -39,6 +39,7 @@
#include "tus_file.h"
#include "tus_file_exp.h"
#include "tus_file_exp_setup.h"
struct
tus_exp
{
unsigned
magic
;
...
...
@@ -62,7 +63,7 @@ fcore_when(const void *p)
return
(
fdisk
->
upload_expires
);
}
void
*
static
void
*
tus_exp_thread
(
void
*
p
)
{
struct
VPFX
(
tus_server
)
*
srv
;
...
...
@@ -72,11 +73,11 @@ tus_exp_thread(void *p)
vtim_real
now
,
when
,
t
;
CAST_OBJ_NOTNULL
(
e
,
p
,
TUS_EXP_MAGIC
);
pthread_mutex_lock
(
&
e
->
mtx
);
AZ
(
pthread_mutex_lock
(
&
e
->
mtx
)
);
while
(
!
e
->
die
)
{
fcore
=
VBH_root
(
e
->
heap
);
if
(
fcore
==
NULL
)
{
pthread_cond_wait
(
&
e
->
cond
,
&
e
->
mtx
);
AZ
(
pthread_cond_wait
(
&
e
->
cond
,
&
e
->
mtx
)
);
continue
;
}
...
...
@@ -93,7 +94,7 @@ tus_exp_thread(void *p)
continue
;
}
pthread_mutex_unlock
(
&
e
->
mtx
);
AZ
(
pthread_mutex_unlock
(
&
e
->
mtx
)
);
srv
=
fcore
->
server
;
tus_server_lock
(
srv
);
...
...
@@ -101,9 +102,9 @@ tus_exp_thread(void *p)
tus_file_del
(
&
fcore
);
tus_server_unlock
(
srv
);
pthread_mutex_lock
(
&
e
->
mtx
);
AZ
(
pthread_mutex_lock
(
&
e
->
mtx
)
);
}
pthread_mutex_unlock
(
&
e
->
mtx
);
AZ
(
pthread_mutex_unlock
(
&
e
->
mtx
)
);
return
(
NULL
);
}
...
...
@@ -114,10 +115,10 @@ tus_exp_delete(const struct tus_file_core *fcore)
CHECK_OBJ_NOTNULL
(
e
,
TUS_EXP_MAGIC
);
pthread_mutex_lock
(
&
e
->
mtx
);
AZ
(
pthread_mutex_lock
(
&
e
->
mtx
)
);
assert
(
fcore
->
exp_idx
!=
VBH_NOIDX
);
VBH_delete
(
e
->
heap
,
fcore
->
exp_idx
);
pthread_mutex_unlock
(
&
e
->
mtx
);
AZ
(
pthread_mutex_unlock
(
&
e
->
mtx
)
);
}
void
...
...
@@ -127,11 +128,11 @@ tus_exp_insert(struct tus_file_core *fcore)
CHECK_OBJ_NOTNULL
(
e
,
TUS_EXP_MAGIC
);
pthread_mutex_lock
(
&
e
->
mtx
);
AZ
(
pthread_mutex_lock
(
&
e
->
mtx
)
);
VBH_insert
(
e
->
heap
,
fcore
);
if
(
VBH_root
(
e
->
heap
)
==
fcore
)
pthread_cond_signal
(
&
e
->
cond
);
pthread_mutex_unlock
(
&
e
->
mtx
);
AZ
(
pthread_cond_signal
(
&
e
->
cond
)
);
AZ
(
pthread_mutex_unlock
(
&
e
->
mtx
)
);
}
void
...
...
@@ -141,9 +142,9 @@ tus_exp_touch(const struct tus_file_core *fcore)
CHECK_OBJ_NOTNULL
(
e
,
TUS_EXP_MAGIC
);
pthread_mutex_lock
(
&
e
->
mtx
);
AZ
(
pthread_mutex_lock
(
&
e
->
mtx
)
);
VBH_reorder
(
e
->
heap
,
fcore
->
exp_idx
);
pthread_mutex_unlock
(
&
e
->
mtx
);
AZ
(
pthread_mutex_unlock
(
&
e
->
mtx
)
);
}
static
int
...
...
src/tus_file_exp_setup.h
0 → 100644
View file @
bd297993
/*-
* Copyright 2020 UPLEX Nils Goroll Systemoptimierung
* All rights reserved.
*
* Author: Nils Goroll <nils.goroll@uplex.de>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
struct
tus_exp
*
tus_file_exp_new
(
void
);
void
tus_file_exp_destroy
(
struct
tus_exp
**
);
src/tus_hdr.c
View file @
bd297993
...
...
@@ -26,6 +26,8 @@
* SUCH DAMAGE.
*/
#include "tus_hdr.h"
const
char
*
const
hdr_resum
=
"
\016
Tus-Resumable:"
;
const
char
*
const
hdr_vers
=
"
\014
Tus-Version:"
;
const
char
*
const
hdr_ext
=
"
\016
Tus-Extension:"
;
...
...
src/tus_hex.c
View file @
bd297993
...
...
@@ -41,7 +41,7 @@ hexnibble(unsigned char n)
return
(
n
<
0xa
?
'0'
+
n
:
'a'
+
n
-
0xa
);
}
VCL_STRING
static
VCL_STRING
tus_hex_buf
(
char
*
buf
,
size_t
bufl
,
VCL_BLOB
b
)
{
VCL_STRING
r
=
buf
;
...
...
src/tus_hex.h
View file @
bd297993
...
...
@@ -26,6 +26,5 @@
* SUCH DAMAGE.
*/
VCL_STRING
tus_hex_buf
(
char
*
,
size_t
,
VCL_BLOB
);
VCL_STRING
tus_hex
(
VRT_CTX
,
VCL_BLOB
);
void
tus_vsbhex
(
struct
vsb
*
,
VCL_BLOB
);
src/tus_request.c
View file @
bd297993
...
...
@@ -64,6 +64,7 @@ validhdr(const char *p)
/* ------------------------------------------------------------
*/
/*lint -esym(749, met_e::_MET_MAX) */
enum
met_e
{
_INVALID
=
0
,
#define MET(x) x,
...
...
@@ -82,7 +83,7 @@ parse_met(const char *s)
// everything for a tus upload to the backend is complete
static
VCL_BOOL
tus_request_complete
(
VRT_CTX
,
const
struct
VPFX
(
tus_server
)
*
srv
,
struct
tus_concat
*
c
,
struct
tus_file_disk
*
fdisk
)
struct
tus_concat
*
c
,
const
struct
tus_file_disk
*
fdisk
)
{
VCL_BLOB
b
=
NULL
;
struct
vsb
vsb
[
1
];
...
...
@@ -163,7 +164,7 @@ tus_meta_key_unique(struct test_meta *this, size_t l)
// from vmod_blob base64.c
#define ILL ((int8_t) 127)
#define PAD ((int8_t) 126)
const
int8_t
i64
[
256
]
=
{
static
const
int8_t
i64
[
256
]
=
{
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
ILL
,
...
...
@@ -368,6 +369,7 @@ tus_request(VRT_CTX, struct VPFX(tus_server) *tussrv,
}
if
(
m
==
GET
)
{
AN
(
fdisk
);
if
(
fdisk
->
location_length
>
0
)
{
/* done file */
r
->
fcore
=
fcore
;
...
...
@@ -449,10 +451,6 @@ tus_request(VRT_CTX, struct VPFX(tus_server) *tussrv,
r
->
status
=
415
;
return
(
0
);
}
if
(
fcore
==
NULL
)
{
r
->
status
=
404
;
return
(
0
);
}
if
(
off
!=
fdisk
->
upload_offset
)
{
r
->
status
=
409
;
return
(
0
);
...
...
src/tus_response.c
View file @
bd297993
...
...
@@ -44,9 +44,8 @@
const
unsigned
s_MULT
=
1000
;
const
unsigned
s_OPTIONS
=
1
;
const
unsigned
s_HEAD
=
2
;
const
char
*
const
allow
=
"POST, GET, HEAD, PATCH, DELETE, OPTIONS"
;
static
const
char
*
const
allow
=
"POST, GET, HEAD, PATCH, DELETE, OPTIONS"
;
static
VCL_BYTES
tus_upload_length
(
const
struct
VPFX
(
tus_server
)
*
tussrv
,
...
...
@@ -91,7 +90,7 @@ tus_cors(VCL_HTTP r, unsigned status, const char *origin)
void
tus_response
(
VRT_CTX
,
const
struct
VPFX
(
tus_server
)
*
tussrv
,
struct
tus_response
*
resp
)
const
struct
tus_response
*
resp
)
{
const
struct
tus_file_disk
*
fdisk
=
NULL
;
const
struct
tus_file_core
*
fcore
=
NULL
;
...
...
@@ -161,10 +160,8 @@ tus_response(VRT_CTX, const struct VPFX(tus_server) *tussrv,
if
(
resp
->
origin
!=
NULL
&&
*
resp
->
origin
!=
'\0'
)
tus_cors
(
r
,
resp
->
status
,
resp
->
origin
);
if
(
tussrv
)
{
http_PrintfHeader
(
r
,
"Tus-Max-Size: %ju"
,
tus_upload_length
(
tussrv
,
fcore
));
}
http_PrintfHeader
(
r
,
"Tus-Max-Size: %ju"
,
tus_upload_length
(
tussrv
,
fcore
));
while
(
fdisk
)
{
AN
(
fcore
);
...
...
src/tus_response.h
View file @
bd297993
...
...
@@ -38,7 +38,7 @@ struct tus_response {
void
tus_response
(
VRT_CTX
,
const
struct
VPFX
(
tus_server
)
*
tussrv
,
struct
tus_response
*
resp
);
const
struct
tus_response
*
resp
);
VCL_BOOL
tus_done
(
VRT_CTX
,
const
struct
VPFX
(
tus_server
)
*
tussrv
,
const
struct
tus_response
*
resp
,
const
char
*
url
);
...
...
@@ -47,4 +47,3 @@ tus_meta(VRT_CTX, const struct tus_response *resp, const char *k, VCL_BLOB *b);
extern
const
unsigned
s_MULT
;
extern
const
unsigned
s_OPTIONS
;
extern
const
unsigned
s_HEAD
;
src/tus_server.h
View file @
bd297993
...
...
@@ -36,7 +36,7 @@ struct tus_exp;
struct
vmod_blobdigest_digest
;
// tus_servers.c
const
char
*
tus_server_name
(
struct
VPFX
(
tus_server
)
*
);
const
char
*
tus_server_name
(
const
struct
VPFX
(
tus_server
)
*
);
struct
tus_files
*
tus_server_files
(
struct
VPFX
(
tus_server
)
*
);
int
tus_server_basefd
(
const
struct
VPFX
(
tus_server
)
*
);
const
char
*
tus_server_basedir
(
const
struct
VPFX
(
tus_server
)
*
);
...
...
src/tus_servers.c
View file @
bd297993
...
...
@@ -33,15 +33,14 @@
#include "vcc_tus_if.h"
#include "tus_file.h"
#include "tus_server.h"
#include "tus_servers.h"
struct
tus_servers
tus_servers
[
1
]
=
{
VSPLAY_INITIALIZER
(
tus_servers
)
};
VSPLAY_GENERATE
(
tus_servers
,
VPFX
(
tus_server
),
entry
,
tus_server_cmp
)
;
VSPLAY_GENERATE
(
tus_servers
,
VPFX
(
tus_server
),
entry
,
tus_server_cmp
)
const
char
*
tus_server_name
(
struct
VPFX
(
tus_server
)
*
s
)
tus_server_name
(
const
struct
VPFX
(
tus_server
)
*
s
)
{
CHECK_OBJ_NOTNULL
(
s
,
VMOD_TUS_SERVER_MAGIC
);
...
...
src/tus_servers.h
View file @
bd297993
...
...
@@ -64,5 +64,5 @@ tus_server_cmp(const struct VPFX(tus_server) *a,
return
(
strcmp
(
a
->
vcl_name
,
b
->
vcl_name
));
}
VSPLAY_HEAD
(
tus_servers
,
VPFX
(
tus_server
));
struct
tus_servers
tus_servers
[
1
];
VSPLAY_PROTOTYPE
(
tus_servers
,
VPFX
(
tus_server
),
entry
,
tus_server_cmp
)
;
extern
struct
tus_servers
tus_servers
[
1
];
VSPLAY_PROTOTYPE
(
tus_servers
,
VPFX
(
tus_server
),
entry
,
tus_server_cmp
)
src/tus_stv.c
View file @
bd297993
...
...
@@ -57,7 +57,7 @@ static void *
tus_objsetattr
(
struct
worker
*
wrk
,
struct
objcore
*
oc
,
enum
obj_attr
attr
,
ssize_t
len
,
const
void
*
ptr
);
const
struct
obj_methods
obj_tus
=
{
static
const
struct
obj_methods
obj_tus
=
{
.
objfree
=
tus_objfree
,
.
objiterator
=
tus_objiterator
,
.
objgetspace
=
tus_objgetspace
,
...
...
@@ -76,10 +76,9 @@ tus_allocobj(struct worker *wrk, const struct stevedore *stv,
(
void
)
oc
;
(
void
)
l
;
INCOMPL
();
return
(
0
);
// USELESS
}
const
struct
stevedore
stv_tus
=
{
static
const
struct
stevedore
stv_tus
=
{
.
magic
=
STEVEDORE_MAGIC
,
.
name
=
"tus"
,
...
...
@@ -150,10 +149,13 @@ tus_objiterator(struct worker *wrk, struct objcore *oc,
int
r
=
-
1
;
(
void
)
wrk
;
(
void
)
final
;
CHECK_OBJ_NOTNULL
(
oc
,
OBJCORE_MAGIC
);
assert
(
oc
->
stobj
->
stevedore
==
&
stv_tus
);
CAST_OBJ_NOTNULL
(
c
,
oc
->
stobj
->
priv
,
TUS_CONCAT_MAGIC
);
oc
=
NULL
;
(
void
)
oc
;
// flexelint
for
(
i
=
0
;
i
<
c
->
n
;
i
++
)
{
fcore
=
c
->
cores
[
i
];
...
...
@@ -195,7 +197,6 @@ tus_objgetspace(struct worker *wrk, struct objcore *oc,
(
void
)
sz
;
(
void
)
ptr
;
INCOMPL
();
return
(
0
);
// USELESS
}
static
void
...
...
@@ -216,7 +217,6 @@ enum obj_attr attr, ssize_t *len)
(
void
)
attr
;
(
void
)
len
;
INCOMPL
();
return
(
NULL
);
// USELESS
}
static
void
*
...
...
@@ -229,7 +229,6 @@ enum obj_attr attr, ssize_t len, const void *ptr)
(
void
)
len
;
(
void
)
ptr
;
INCOMPL
();
return
(
NULL
);
// USELESS
}
// helper
...
...
src/vmod_get_h.c
View file @
bd297993
...
...
@@ -41,8 +41,16 @@ main(int argc, char **argv) {
void
*
dlhdl
;
char
buf
[
256
];
const
struct
vmod_data
*
d
;
const
char
*
name
=
argv
[
1
];
const
char
*
file
=
argv
[
2
];
const
char
*
name
;
const
char
*
file
;
if
(
argc
<
3
)
{
fprintf
(
stderr
,
"need 2 arguments
\n
"
);
return
(
1
);
}
name
=
argv
[
1
];
file
=
argv
[
2
];
dlhdl
=
dlopen
(
file
,
RTLD_LAZY
|
RTLD_LOCAL
);
...
...
@@ -57,7 +65,7 @@ main(int argc, char **argv) {
return
(
1
);
}
printf
(
d
->
proto
);
printf
(
"%s"
,
d
->
proto
);
printf
(
"
\n
static const struct vmod_data import_%s = {
\n
"
,
buf
);
printf
(
"
\t
.name =
\t\t\"
%s
\"
,
\n
"
,
d
->
name
);
printf
(
"
\t
.file_id =
\t\"
%s
\"
,
\n
"
,
d
->
file_id
);
...
...
src/vmod_tus.c
View file @
bd297993
...
...
@@ -46,12 +46,9 @@
#include "tus_response.h"
#include "tus_request.h"
#include "tus_blob.h"
#include "tus_file_exp_setup.h"
// tus_file_exp.c
struct
tus_exp
*
tus_file_exp_new
(
void
);
void
tus_file_exp_destroy
(
struct
tus_exp
**
ep
);
unsigned
refcnt
=
0
;
static
unsigned
refcnt
=
0
;
/* ============================================================
* vmod init/fini
...
...
@@ -131,7 +128,7 @@ tus_dir_chk(const char *dir)
return
(
0
);
}
int
static
int
tus_basefd
(
const
char
*
dir
)
{
if
(
tus_dir_chk
(
dir
))
{
...
...
@@ -158,7 +155,8 @@ tus_schemeauth_valid(const char *schemeauth, const char **p)
*
p
+=
3
;
if
(
**
p
==
'\0'
)
return
(
0
);
if
((
*
p
=
strchr
(
*
p
,
'/'
)))
*
p
=
strchr
(
*
p
,
'/'
);
if
(
*
p
)
return
(
0
);
return
(
1
);
}
...
...
@@ -322,8 +320,8 @@ static const struct vmod_priv_methods priv_task_methods[1] = {{
.
fini
=
tus_task_free
}};
struct
tus_response
*
tus_task_new
(
VRT_CTX
,
struct
VPFX
(
tus_server
)
*
tussrv
)
st
atic
st
ruct
tus_response
*
tus_task_new
(
VRT_CTX
,
const
struct
VPFX
(
tus_server
)
*
tussrv
)
{
struct
tus_response
*
r
;
struct
vmod_priv
*
task
;
...
...
@@ -351,8 +349,8 @@ tus_task_new(VRT_CTX, struct VPFX(tus_server) *tussrv)
return
(
r
);
}
struct
tus_response
*
tus_task_use
(
VRT_CTX
,
struct
VPFX
(
tus_server
)
*
tussrv
)
st
atic
st
ruct
tus_response
*
tus_task_use
(
VRT_CTX
,
const
struct
VPFX
(
tus_server
)
*
tussrv
)
{
struct
tus_response
*
r
;
struct
vmod_priv
*
task
;
...
...
@@ -487,8 +485,7 @@ VCL_BOOL tus_server_done(VRT_CTX, struct VPFX(tus_server) *tussrv,
if
(
args
->
valid_location
)
url
=
args
->
location
;
tus_done
(
ctx
,
tussrv
,
r
,
url
);
return
(
0
);
return
(
tus_done
(
ctx
,
tussrv
,
r
,
url
));
}
VCL_BOOL
...
...
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