From f120cacc03abe5c2b669e86f8918917de04eade5 Mon Sep 17 00:00:00 2001 From: Unbit Date: Tue, 3 Sep 2013 07:15:22 +0200 Subject: [PATCH] added support for O_TMPFILE --- core/utils.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/utils.c b/core/utils.c index 37e2e079..fa635b16 100644 --- a/core/utils.c +++ b/core/utils.c @@ -3027,12 +3027,20 @@ char *uwsgi_chomp2(char *str) { int uwsgi_tmpfd() { + int fd = -1; char *tmpdir = getenv("TMPDIR"); if (!tmpdir) { tmpdir = "/tmp"; } +#ifdef O_TMPFILE + fd = open(tmpdir, O_TMPFILE | O_RDWR); + if (fd >= 0) { + return fd; + } + // fallback to old style +#endif char *template = uwsgi_concat2(tmpdir, "/uwsgiXXXXXX"); - int fd = mkstemp(template); + fd = mkstemp(template); unlink(template); free(template); return fd;