Single fcore reference for tus_file_final_birth()

parent 345a6d35
...@@ -204,14 +204,16 @@ tus_file_final_concat(struct VPFX(tus_server) *srv, ...@@ -204,14 +204,16 @@ tus_file_final_concat(struct VPFX(tus_server) *srv,
return (NULL); return (NULL);
} }
struct tus_file_core * void
tus_file_final_birth(struct tus_file_core *fcore, struct concat_embryo *embryo) tus_file_final_birth(struct tus_file_core **fcorep,
struct concat_embryo *embryo)
{ {
struct tus_file_core *fcore;
struct VPFX(tus_server) *srv; struct VPFX(tus_server) *srv;
struct tus_file_disk *fdisk; struct tus_file_disk *fdisk;
struct vsb *vsb; struct vsb *vsb;
CHECK_OBJ_NOTNULL(fcore, VMOD_TUS_FILE_CORE_MAGIC); TAKE_OBJ_NOTNULL(fcore, fcorep, VMOD_TUS_FILE_CORE_MAGIC);
CHECK_OBJ_NOTNULL(embryo, CONCAT_EMBRYO_MAGIC); CHECK_OBJ_NOTNULL(embryo, CONCAT_EMBRYO_MAGIC);
fdisk = fcore->disk; fdisk = fcore->disk;
CHECK_OBJ_NOTNULL(fdisk, VMOD_TUS_FILE_DISK_MAGIC); CHECK_OBJ_NOTNULL(fdisk, VMOD_TUS_FILE_DISK_MAGIC);
...@@ -232,7 +234,7 @@ tus_file_final_birth(struct tus_file_core *fcore, struct concat_embryo *embryo) ...@@ -232,7 +234,7 @@ tus_file_final_birth(struct tus_file_core *fcore, struct concat_embryo *embryo)
} }
VSB_destroy(&vsb); VSB_destroy(&vsb);
memset(embryo, 0, sizeof *embryo); memset(embryo, 0, sizeof *embryo);
return (fcore); *fcorep = fcore;
} }
static void static void
......
...@@ -168,8 +168,7 @@ struct concat_embryo * tus_file_final_concat(struct VPFX(tus_server) *, ...@@ -168,8 +168,7 @@ struct concat_embryo * tus_file_final_concat(struct VPFX(tus_server) *,
struct concat_embryo *, const char *); struct concat_embryo *, const char *);
VCL_BLOB tus_concat_hash(VRT_CTX, const struct VPFX(tus_server) *, VCL_BLOB tus_concat_hash(VRT_CTX, const struct VPFX(tus_server) *,
const struct tus_concat *); const struct tus_concat *);
struct tus_file_core *tus_file_final_birth(struct tus_file_core *, void tus_file_final_birth(struct tus_file_core **, struct concat_embryo *);
struct concat_embryo *);
void tus_file_final_abort(struct concat_embryo *); void tus_file_final_abort(struct concat_embryo *);
VCL_BOOL tus_file_done(struct tus_file_core *, struct tus_file_disk *, VCL_BOOL tus_file_done(struct tus_file_core *, struct tus_file_disk *,
const char *); const char *);
......
...@@ -351,8 +351,8 @@ tus_request(VRT_CTX, struct VPFX(tus_server) *tussrv, ...@@ -351,8 +351,8 @@ tus_request(VRT_CTX, struct VPFX(tus_server) *tussrv,
if (r->fcore == NULL) { if (r->fcore == NULL) {
tus_file_final_abort(&embryo); tus_file_final_abort(&embryo);
} else { } else {
r->fcore = tus_file_final_birth(r->fcore, &embryo); tus_file_final_birth(&r->fcore, &embryo);
r->status = 201; r->status = r->fcore ? 201 : 500;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment