Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
mongoose
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ganil-acq
GANILinux
linux-service
library
mongoose
Commits
0263e395
Commit
0263e395
authored
12 years ago
by
Sergey Lyubka
Browse files
Options
Downloads
Patches
Plain Diff
Minor refactoring
parent
d8424726
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/upload.c
+7
-7
7 additions, 7 deletions
examples/upload.c
with
7 additions
and
7 deletions
examples/upload.c
+
7
−
7
View file @
0263e395
...
...
@@ -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"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment