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
30c0a3f2
Commit
30c0a3f2
authored
Jun 04, 2015
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Propagate select() and socketpair() errors to the user
parent
08fe9ac5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
7 deletions
+21
-7
mongoose.c
mongoose.c
+21
-7
No files found.
mongoose.c
View file @
30c0a3f2
...
@@ -334,6 +334,7 @@ int ns_resolve(const char *domain_name, char *ip_addr_buf, size_t buf_len);
...
@@ -334,6 +334,7 @@ int ns_resolve(const char *domain_name, char *ip_addr_buf, size_t buf_len);
#define NS_CALLOC calloc
#define NS_CALLOC calloc
#endif
#endif
#define NS_MAX_SOCKETPAIR_ATTEMPTS 10
#define NS_CTL_MSG_MESSAGE_SIZE (8 * 1024)
#define NS_CTL_MSG_MESSAGE_SIZE (8 * 1024)
#define NS_READ_BUFFER_SIZE 2048
#define NS_READ_BUFFER_SIZE 2048
#define NS_UDP_RECEIVE_BUFFER_SIZE 2000
#define NS_UDP_RECEIVE_BUFFER_SIZE 2000
...
@@ -1107,7 +1108,9 @@ time_t ns_mgr_poll(struct ns_mgr *mgr, int milli) {
...
@@ -1107,7 +1108,9 @@ time_t ns_mgr_poll(struct ns_mgr *mgr, int milli) {
tv
.
tv_sec
=
milli
/
1000
;
tv
.
tv_sec
=
milli
/
1000
;
tv
.
tv_usec
=
(
milli
%
1000
)
*
1000
;
tv
.
tv_usec
=
(
milli
%
1000
)
*
1000
;
if
(
select
((
int
)
max_fd
+
1
,
&
read_set
,
&
write_set
,
NULL
,
&
tv
)
>
0
)
{
if
(
select
((
int
)
max_fd
+
1
,
&
read_set
,
&
write_set
,
NULL
,
&
tv
)
<
0
)
{
return
0
;
}
else
{
// select() might have been waiting for a long time, reset current_time
// select() might have been waiting for a long time, reset current_time
// now to prevent last_io_time being set to the past.
// now to prevent last_io_time being set to the past.
current_time
=
time
(
NULL
);
current_time
=
time
(
NULL
);
...
@@ -1258,9 +1261,12 @@ void ns_mgr_init(struct ns_mgr *s, void *user_data) {
...
@@ -1258,9 +1261,12 @@ void ns_mgr_init(struct ns_mgr *s, void *user_data) {
#endif
#endif
#ifndef NS_DISABLE_SOCKETPAIR
#ifndef NS_DISABLE_SOCKETPAIR
do
{
{
ns_socketpair2
(
s
->
ctl
,
SOCK_DGRAM
);
int
attempts
=
0
,
max_attempts
=
NS_MAX_SOCKETPAIR_ATTEMPTS
;
}
while
(
s
->
ctl
[
0
]
==
INVALID_SOCKET
);
do
{
ns_socketpair2
(
s
->
ctl
,
SOCK_DGRAM
);
}
while
(
s
->
ctl
[
0
]
==
INVALID_SOCKET
&&
++
attempts
<
max_attempts
);
}
#endif
#endif
#ifdef NS_ENABLE_SSL
#ifdef NS_ENABLE_SSL
...
@@ -2325,9 +2331,17 @@ static void open_cgi_endpoint(struct connection *conn, const char *prog) {
...
@@ -2325,9 +2331,17 @@ static void open_cgi_endpoint(struct connection *conn, const char *prog) {
// Try to create socketpair in a loop until success. ns_socketpair()
// Try to create socketpair in a loop until success. ns_socketpair()
// can be interrupted by a signal and fail.
// can be interrupted by a signal and fail.
// TODO(lsm): use sigaction to restart interrupted syscall
// TODO(lsm): use sigaction to restart interrupted syscall
do
{
{
ns_socketpair
(
fds
);
int
attempts
=
0
,
max_attempts
=
NS_MAX_SOCKETPAIR_ATTEMPTS
;
}
while
(
fds
[
0
]
==
INVALID_SOCKET
);
do
{
ns_socketpair
(
fds
);
}
while
(
fds
[
0
]
==
INVALID_SOCKET
&&
++
attempts
<
max_attempts
);
if
(
fds
[
0
]
==
INVALID_SOCKET
)
{
closesocket
(
fds
[
0
]);
send_http_error
(
conn
,
500
,
"ns_socketpair() failed"
);
}
}
if
(
start_process
(
conn
->
server
->
config_options
[
CGI_INTERPRETER
],
if
(
start_process
(
conn
->
server
->
config_options
[
CGI_INTERPRETER
],
prog
,
blk
.
buf
,
blk
.
vars
,
dir
,
fds
[
1
])
!=
0
)
{
prog
,
blk
.
buf
,
blk
.
vars
,
dir
,
fds
[
1
])
!=
0
)
{
...
...
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