Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
Project
Project
Details
Activity
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
esp
mongoose
Commits
0263e395
Commit
0263e395
authored
Nov 30, 2012
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor refactoring
parent
d8424726
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
upload.c
examples/upload.c
+7
-7
No files found.
examples/upload.c
View file @
0263e395
...
@@ -10,14 +10,9 @@
...
@@ -10,14 +10,9 @@
#include <io.h>
#include <io.h>
#define strtoll strtol
#define strtoll strtol
typedef
__int64
int64_t
;
typedef
__int64
int64_t
;
#define O_CLOEXEC 0
#define O_EXLOCK 0
#else
#else
#include <inttypes.h>
#include <inttypes.h>
#include <unistd.h>
#include <unistd.h>
#ifndef O_BINARY
#define O_BINARY 0
#endif
#endif // !_WIN32
#endif // !_WIN32
#include "mongoose.h"
#include "mongoose.h"
...
@@ -85,8 +80,13 @@ static void handle_file_upload(struct mg_connection *conn) {
...
@@ -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"
);
mg_printf
(
conn
,
"%s%s"
,
HTTP_500
,
"Can't get file name"
);
}
else
if
(
cl
<=
0
)
{
}
else
if
(
cl
<=
0
)
{
mg_printf
(
conn
,
"%s%s"
,
HTTP_500
,
"Empty file"
);
mg_printf
(
conn
,
"%s%s"
,
HTTP_500
,
"Empty file"
);
}
else
if
((
fd
=
open
(
path
,
O_CREAT
|
O_TRUNC
|
O_BINARY
|
}
else
if
((
fd
=
open
(
path
,
O_CREAT
|
O_TRUNC
|
O_WRONLY
|
O_EXLOCK
|
O_CLOEXEC
))
<
0
)
{
#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
// 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.
// there is no other thread can save into the same file simultaneously.
mg_printf
(
conn
,
"%s%s"
,
HTTP_500
,
"Cannot open file"
);
mg_printf
(
conn
,
"%s%s"
,
HTTP_500
,
"Cannot open file"
);
...
...
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