mirror of
https://github.com/cesanta/mongoose.git
synced 2024-11-24 19:19:00 +08:00
Minor refactoring
This commit is contained in:
parent
d8424726bb
commit
0263e39584
@ -10,14 +10,9 @@
|
||||
#include <io.h>
|
||||
#define strtoll strtol
|
||||
typedef __int64 int64_t;
|
||||
#define O_CLOEXEC 0
|
||||
#define O_EXLOCK 0
|
||||
#else
|
||||
#include <inttypes.h>
|
||||
#include <unistd.h>
|
||||
#ifndef O_BINARY
|
||||
#define O_BINARY 0
|
||||
#endif
|
||||
#endif // !_WIN32
|
||||
|
||||
#include "mongoose.h"
|
||||
@ -85,8 +80,13 @@ static void handle_file_upload(struct mg_connection *conn) {
|
||||
mg_printf(conn, "%s%s", HTTP_500, "Can't get file name");
|
||||
} else if (cl <= 0) {
|
||||
mg_printf(conn, "%s%s", HTTP_500, "Empty file");
|
||||
} else if ((fd = open(path, O_CREAT | O_TRUNC | O_BINARY |
|
||||
O_WRONLY | O_EXLOCK | O_CLOEXEC)) < 0) {
|
||||
} else if ((fd = open(path, O_CREAT | O_TRUNC |
|
||||
#ifdef _WIN32
|
||||
O_BINARY |
|
||||
#else
|
||||
O_EXLOCK | O_CLOEXEC |
|
||||
#endif
|
||||
O_WRONLY)) < 0) {
|
||||
// We're opening the file with exclusive lock held. This guarantee us that
|
||||
// there is no other thread can save into the same file simultaneously.
|
||||
mg_printf(conn, "%s%s", HTTP_500, "Cannot open file");
|
||||
|
Loading…
Reference in New Issue
Block a user