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
cdb65889
Commit
cdb65889
authored
Jan 09, 2013
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix to stop misbehaving clients to DoS mongoose
parent
eecf24b2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
2 deletions
+7
-2
mongoose.c
mongoose.c
+7
-2
No files found.
mongoose.c
View file @
cdb65889
...
@@ -4632,9 +4632,12 @@ static void reset_per_request_attributes(struct mg_connection *conn) {
...
@@ -4632,9 +4632,12 @@ static void reset_per_request_attributes(struct mg_connection *conn) {
}
}
static
void
close_socket_gracefully
(
struct
mg_connection
*
conn
)
{
static
void
close_socket_gracefully
(
struct
mg_connection
*
conn
)
{
#if defined(_WIN32)
char
buf
[
MG_BUF_LEN
];
char
buf
[
MG_BUF_LEN
];
int
n
;
#endif
struct
linger
linger
;
struct
linger
linger
;
int
n
,
sock
=
conn
->
client
.
sock
;
int
sock
=
conn
->
client
.
sock
;
// Set linger option to avoid socket hanging out after close. This prevent
// Set linger option to avoid socket hanging out after close. This prevent
// ephemeral port exhaust problem under high QPS.
// ephemeral port exhaust problem under high QPS.
...
@@ -4646,6 +4649,7 @@ static void close_socket_gracefully(struct mg_connection *conn) {
...
@@ -4646,6 +4649,7 @@ static void close_socket_gracefully(struct mg_connection *conn) {
(
void
)
shutdown
(
sock
,
SHUT_WR
);
(
void
)
shutdown
(
sock
,
SHUT_WR
);
set_non_blocking_mode
(
sock
);
set_non_blocking_mode
(
sock
);
#if defined(_WIN32)
// Read and discard pending incoming data. If we do not do that and close the
// Read and discard pending incoming data. If we do not do that and close the
// socket, the data in the send buffer may be discarded. This
// socket, the data in the send buffer may be discarded. This
// behaviour is seen on Windows, when client keeps sending data
// behaviour is seen on Windows, when client keeps sending data
...
@@ -4654,6 +4658,7 @@ static void close_socket_gracefully(struct mg_connection *conn) {
...
@@ -4654,6 +4658,7 @@ static void close_socket_gracefully(struct mg_connection *conn) {
do
{
do
{
n
=
pull
(
NULL
,
conn
,
buf
,
sizeof
(
buf
));
n
=
pull
(
NULL
,
conn
,
buf
,
sizeof
(
buf
));
}
while
(
n
>
0
);
}
while
(
n
>
0
);
#endif
// Now we know that our FIN is ACK-ed, safe to close
// Now we know that our FIN is ACK-ed, safe to close
(
void
)
closesocket
(
sock
);
(
void
)
closesocket
(
sock
);
...
...
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