Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
mongoose
Commits
acf72a61
Commit
acf72a61
authored
Jan 09, 2013
by
Benoît Amiaux
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add request_timeout option
parent
20ce55eb
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
1 deletion
+20
-1
mongoose.c
mongoose.c
+20
-1
No files found.
mongoose.c
View file @
acf72a61
...
...
@@ -449,7 +449,7 @@ enum {
ACCESS_LOG_FILE
,
ENABLE_DIRECTORY_LISTING
,
ERROR_LOG_FILE
,
GLOBAL_PASSWORDS_FILE
,
INDEX_FILES
,
ENABLE_KEEP_ALIVE
,
ACCESS_CONTROL_LIST
,
EXTRA_MIME_TYPES
,
LISTENING_PORTS
,
DOCUMENT_ROOT
,
SSL_CERTIFICATE
,
NUM_THREADS
,
RUN_AS_USER
,
REWRITE
,
HIDE_FILES
,
NUM_THREADS
,
RUN_AS_USER
,
REWRITE
,
HIDE_FILES
,
REQUEST_TIMEOUT
,
NUM_OPTIONS
};
...
...
@@ -477,6 +477,7 @@ static const char *config_options[] = {
"u"
,
"run_as_user"
,
NULL
,
"w"
,
"url_rewrite_patterns"
,
NULL
,
"x"
,
"hide_files_patterns"
,
NULL
,
"z"
,
"request_timeout"
,
NULL
,
NULL
};
#define ENTRIES_PER_CONFIG_OPTION 3
...
...
@@ -4314,6 +4315,23 @@ static int parse_port_string(const struct vec *vec, struct socket *so) {
return
1
;
}
static
int
set_timeout
(
struct
mg_context
*
ctx
,
SOCKET
sock
)
{
#ifndef _WIN32
struct
timeval
timeout
;
if
(
!
ctx
->
config
[
REQUEST_TIMEOUT
]
)
return
0
;
timeout
.
tv_sec
=
0
;
timeout
.
tv_usec
=
atoi
(
ctx
->
config
[
REQUEST_TIMEOUT
])
*
1000
;
#else
DWORD
timeout
;
if
(
!
ctx
->
config
[
REQUEST_TIMEOUT
]
)
return
0
;
timeout
=
atoi
(
ctx
->
config
[
REQUEST_TIMEOUT
]);
#endif
return
setsockopt
(
sock
,
SOL_SOCKET
,
SO_RCVTIMEO
,
(
void
*
)
&
timeout
,
sizeof
(
timeout
))
||
setsockopt
(
sock
,
SOL_SOCKET
,
SO_SNDTIMEO
,
(
void
*
)
&
timeout
,
sizeof
(
timeout
));
}
static
int
set_ports_option
(
struct
mg_context
*
ctx
)
{
const
char
*
list
=
ctx
->
config
[
LISTENING_PORTS
];
int
on
=
1
,
success
=
1
;
...
...
@@ -4332,6 +4350,7 @@ static int set_ports_option(struct mg_context *ctx) {
success
=
0
;
}
else
if
((
sock
=
socket
(
so
.
lsa
.
sa
.
sa_family
,
SOCK_STREAM
,
6
))
==
INVALID_SOCKET
||
set_timeout
(
ctx
,
sock
)
||
// On Windows, SO_REUSEADDR is recommended only for
// broadcast UDP sockets
setsockopt
(
sock
,
SOL_SOCKET
,
SO_REUSEADDR
,
(
const
char
*
)
&
on
,
...
...
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