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
d10fb945
Commit
d10fb945
authored
Dec 29, 2017
by
Dmitry Frank
Committed by
Cesanta Bot
Dec 29, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move the recv limit check to mqtt
PUBLISHED_FROM=028d6f56ec1cc15484c995335f00d087b590faef
parent
88ae2eca
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
14 deletions
+16
-14
mongoose.c
mongoose.c
+16
-14
No files found.
mongoose.c
View file @
d10fb945
...
...
@@ -2767,17 +2767,6 @@ MG_INTERNAL void mg_recv_common(struct mg_connection *nc, void *buf, int len,
MG_FREE
(
buf
);
}
mg_call
(
nc
,
NULL
,
nc
->
user_data
,
MG_EV_RECV
,
&
len
);
/* If the buffer is still full after the user callback, fail */
if
(
nc
->
recv_mbuf_limit
>
0
&&
nc
->
recv_mbuf
.
len
>=
nc
->
recv_mbuf_limit
)
{
char
h1
[
50
],
h2
[
50
];
int
flags
=
MG_SOCK_STRINGIFY_IP
|
MG_SOCK_STRINGIFY_PORT
;
mg_conn_addr_to_str
(
nc
,
h1
,
sizeof
(
h1
),
flags
);
mg_conn_addr_to_str
(
nc
,
h2
,
sizeof
(
h2
),
flags
|
MG_SOCK_STRINGIFY_REMOTE
);
LOG
(
LL_ERROR
,
(
"%p %s <-> %s recv buffer %lu bytes, not drained, closing"
,
nc
,
h1
,
h2
,
(
unsigned
long
)
nc
->
recv_mbuf
.
len
));
nc
->
flags
|=
MG_F_CLOSE_IMMEDIATELY
;
}
}
void
mg_if_recv_tcp_cb
(
struct
mg_connection
*
nc
,
void
*
buf
,
int
len
,
int
own
)
{
...
...
@@ -10470,11 +10459,24 @@ static void mqtt_handler(struct mg_connection *nc, int ev,
while
(
1
)
{
int
len
=
parse_mqtt
(
io
,
&
mm
);
if
(
len
<
0
)
{
if
(
len
==
-
1
)
break
;
/* not fully buffered */
/* Protocol error. */
nc
->
flags
|=
MG_F_CLOSE_IMMEDIATELY
;
if
(
len
==
-
2
)
{
/* Protocol error. */
nc
->
flags
|=
MG_F_CLOSE_IMMEDIATELY
;
}
else
if
(
len
==
-
1
)
{
/* Not fully buffered, let's check if we have a chance to get more
* data later */
if
(
nc
->
recv_mbuf_limit
>
0
&&
nc
->
recv_mbuf
.
len
>=
nc
->
recv_mbuf_limit
)
{
LOG
(
LL_ERROR
,
(
"%p recv buffer (%lu bytes) exceeds the limit "
"%lu bytes, and not drained, closing"
,
nc
,
(
unsigned
long
)
nc
->
recv_mbuf
.
len
,
(
unsigned
long
)
nc
->
recv_mbuf_limit
));
nc
->
flags
|=
MG_F_CLOSE_IMMEDIATELY
;
}
}
break
;
}
nc
->
handler
(
nc
,
MG_MQTT_EVENT_BASE
+
mm
.
cmd
,
&
mm
MG_UD_ARG
(
user_data
));
mbuf_remove
(
io
,
len
);
}
...
...
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