Commit 987bc1d5 authored by Sergey Lyubka's avatar Sergey Lyubka Committed by Cesanta Bot

Use 8k iobuf limit for aws

PUBLISHED_FROM=971951e1eeb82078b986cd6e25e52cfc1ccef286
parent ddd35c0c
......@@ -176,7 +176,7 @@ static void mg_init(struct mg_mgr *mgr) {
memset(&ver, 0, sizeof(ver));
sl_DevGet(SL_DEVICE_GENERAL_CONFIGURATION, &opt, &len,
(unsigned char *) (&ver));
LOG(LL_INFO, ("NWP v%d.%d.%d.%d started, host v%d.%d.%d.%d",
LOG(LL_INFO, ("NWP v%ld.%ld.%ld.%ld started, host v%ld.%ld.%ld.%ld",
ver.NwpVersion[0], ver.NwpVersion[1], ver.NwpVersion[2],
ver.NwpVersion[3], SL_MAJOR_VERSION_NUM, SL_MINOR_VERSION_NUM,
SL_VERSION_NUM, SL_SUB_VERSION_NUM));
......
......@@ -2185,8 +2185,8 @@ void mg_tun_destroy_client(struct mg_tun_client *client);
/* Amalgamated: #include "mongoose/src/dns.h" */
/* Amalgamated: #include "mongoose/src/internal.h" */
/* Amalgamated: #include "mongoose/src/resolv.h" */
/* Amalgamated: #include "mongoose/src/util.h" */
/* Amalgamated: #include "mongoose/src/tun.h" */
/* Amalgamated: #include "mongoose/src/util.h" */
#define MG_MAX_HOST_LEN 200
......@@ -2703,6 +2703,17 @@ 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) {
......@@ -15754,14 +15765,6 @@ uint32_t mg_lwip_get_poll_delay_ms(struct mg_mgr *mgr) {
#define MG_LWIP_SSL_IO_SIZE 1024
#endif
/*
* Stop processing incoming SSL traffic when recv_mbuf.size is this big.
* It'a a uick solution for SSL recv pushback.
*/
#ifndef MG_LWIP_SSL_RECV_MBUF_LIMIT
#define MG_LWIP_SSL_RECV_MBUF_LIMIT 3072
#endif
#ifndef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
......@@ -15842,7 +15845,7 @@ void mg_lwip_ssl_recv(struct mg_connection *nc) {
struct mg_lwip_conn_state *cs = (struct mg_lwip_conn_state *) nc->sock;
/* Don't deliver data before connect callback */
if (nc->flags & MG_F_CONNECTING) return;
while (nc->recv_mbuf.len < MG_LWIP_SSL_RECV_MBUF_LIMIT) {
while (nc->recv_mbuf.len < nc->recv_mbuf_limit) {
char *buf = (char *) MG_MALLOC(MG_LWIP_SSL_IO_SIZE);
if (buf == NULL) return;
int ret = mg_ssl_if_read(nc, buf, MG_LWIP_SSL_IO_SIZE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment