mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-03 13:28:44 +00:00
Fix Windows returning IO_RESET
This commit is contained in:
1 parent
4bbb5008b1
commit
d59f84fbbc
3 files changed
+41
-41
No files matched your search
+3
-3
@@ -8060,7 +8060,7 @@ long mg_io_send(struct mg_connection *c, const void *buf, size_t len) {
|
|||||||
}
|
}
|
||||||
MG_VERBOSE(("%lu %ld %d", c->id, n, MG_SOCK_ERR(n)));
|
MG_VERBOSE(("%lu %ld %d", c->id, n, MG_SOCK_ERR(n)));
|
||||||
if (MG_SOCK_PENDING(n)) return MG_IO_WAIT;
|
if (MG_SOCK_PENDING(n)) return MG_IO_WAIT;
|
||||||
if (MG_SOCK_RESET(n)) return MG_IO_RESET;
|
if (MG_SOCK_RESET(n)) return MG_IO_RESET; // MbedTLS, see #1507
|
||||||
if (n <= 0) return MG_IO_ERR;
|
if (n <= 0) return MG_IO_ERR;
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
@@ -8182,7 +8182,7 @@ static long recv_raw(struct mg_connection *c, void *buf, size_t len) {
|
|||||||
}
|
}
|
||||||
MG_VERBOSE(("%lu %ld %d", c->id, n, MG_SOCK_ERR(n)));
|
MG_VERBOSE(("%lu %ld %d", c->id, n, MG_SOCK_ERR(n)));
|
||||||
if (MG_SOCK_PENDING(n)) return MG_IO_WAIT;
|
if (MG_SOCK_PENDING(n)) return MG_IO_WAIT;
|
||||||
if (MG_SOCK_RESET(n)) return MG_IO_RESET;
|
if (MG_SOCK_RESET(n)) return MG_IO_RESET; // MbedTLS, see #1507
|
||||||
if (n <= 0) return MG_IO_ERR;
|
if (n <= 0) return MG_IO_ERR;
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
@@ -8219,7 +8219,7 @@ static void read_conn(struct mg_connection *c) {
|
|||||||
}
|
}
|
||||||
// there can still be > 16K from last iteration, always mg_tls_recv()
|
// there can still be > 16K from last iteration, always mg_tls_recv()
|
||||||
m = c->is_tls_hs ? (long) MG_IO_WAIT : mg_tls_recv(c, buf, len);
|
m = c->is_tls_hs ? (long) MG_IO_WAIT : mg_tls_recv(c, buf, len);
|
||||||
if (n == MG_IO_ERR) {
|
if (n == MG_IO_ERR || n == MG_IO_RESET) { // Windows, see #3031
|
||||||
if (c->rtls.len == 0 || m < 0) {
|
if (c->rtls.len == 0 || m < 0) {
|
||||||
// Close only when we have fully drained both rtls and TLS buffers
|
// Close only when we have fully drained both rtls and TLS buffers
|
||||||
c->is_closing = 1; // or there's nothing we can do about it.
|
c->is_closing = 1; // or there's nothing we can do about it.
|
||||||
|
|||||||
+35
-35
@@ -3267,6 +3267,41 @@ struct mg_tcpip_driver_tms570_data {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_XMC7) && MG_ENABLE_DRIVER_XMC7
|
||||||
|
|
||||||
|
struct mg_tcpip_driver_xmc7_data {
|
||||||
|
int mdc_cr; // Valid values: -1, 0, 1, 2, 3, 4, 5
|
||||||
|
uint8_t phy_addr;
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifndef MG_TCPIP_PHY_ADDR
|
||||||
|
#define MG_TCPIP_PHY_ADDR 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MG_DRIVER_MDC_CR
|
||||||
|
#define MG_DRIVER_MDC_CR 3
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define MG_TCPIP_DRIVER_INIT(mgr) \
|
||||||
|
do { \
|
||||||
|
static struct mg_tcpip_driver_xmc7_data driver_data_; \
|
||||||
|
static struct mg_tcpip_if mif_; \
|
||||||
|
driver_data_.mdc_cr = MG_DRIVER_MDC_CR; \
|
||||||
|
driver_data_.phy_addr = MG_TCPIP_PHY_ADDR; \
|
||||||
|
mif_.ip = MG_TCPIP_IP; \
|
||||||
|
mif_.mask = MG_TCPIP_MASK; \
|
||||||
|
mif_.gw = MG_TCPIP_GW; \
|
||||||
|
mif_.driver = &mg_tcpip_driver_xmc7; \
|
||||||
|
mif_.driver_data = &driver_data_; \
|
||||||
|
MG_SET_MAC_ADDRESS(mif_.mac); \
|
||||||
|
mg_tcpip_init(mgr, &mif_); \
|
||||||
|
MG_INFO(("Driver: xmc7, MAC: %M", mg_print_mac, mif_.mac)); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_XMC) && MG_ENABLE_DRIVER_XMC
|
#if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_XMC) && MG_ENABLE_DRIVER_XMC
|
||||||
|
|
||||||
struct mg_tcpip_driver_xmc_data {
|
struct mg_tcpip_driver_xmc_data {
|
||||||
@@ -3313,41 +3348,6 @@ struct mg_tcpip_driver_xmc_data {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_XMC7) && MG_ENABLE_DRIVER_XMC7
|
|
||||||
|
|
||||||
struct mg_tcpip_driver_xmc7_data {
|
|
||||||
int mdc_cr; // Valid values: -1, 0, 1, 2, 3, 4, 5
|
|
||||||
uint8_t phy_addr;
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifndef MG_TCPIP_PHY_ADDR
|
|
||||||
#define MG_TCPIP_PHY_ADDR 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef MG_DRIVER_MDC_CR
|
|
||||||
#define MG_DRIVER_MDC_CR 3
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define MG_TCPIP_DRIVER_INIT(mgr) \
|
|
||||||
do { \
|
|
||||||
static struct mg_tcpip_driver_xmc7_data driver_data_; \
|
|
||||||
static struct mg_tcpip_if mif_; \
|
|
||||||
driver_data_.mdc_cr = MG_DRIVER_MDC_CR; \
|
|
||||||
driver_data_.phy_addr = MG_TCPIP_PHY_ADDR; \
|
|
||||||
mif_.ip = MG_TCPIP_IP; \
|
|
||||||
mif_.mask = MG_TCPIP_MASK; \
|
|
||||||
mif_.gw = MG_TCPIP_GW; \
|
|
||||||
mif_.driver = &mg_tcpip_driver_xmc7; \
|
|
||||||
mif_.driver_data = &driver_data_; \
|
|
||||||
MG_SET_MAC_ADDRESS(mif_.mac); \
|
|
||||||
mg_tcpip_init(mgr, &mif_); \
|
|
||||||
MG_INFO(("Driver: xmc7, MAC: %M", mg_print_mac, mif_.mac)); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+3
-3
@@ -128,7 +128,7 @@ long mg_io_send(struct mg_connection *c, const void *buf, size_t len) {
|
|||||||
}
|
}
|
||||||
MG_VERBOSE(("%lu %ld %d", c->id, n, MG_SOCK_ERR(n)));
|
MG_VERBOSE(("%lu %ld %d", c->id, n, MG_SOCK_ERR(n)));
|
||||||
if (MG_SOCK_PENDING(n)) return MG_IO_WAIT;
|
if (MG_SOCK_PENDING(n)) return MG_IO_WAIT;
|
||||||
if (MG_SOCK_RESET(n)) return MG_IO_RESET;
|
if (MG_SOCK_RESET(n)) return MG_IO_RESET; // MbedTLS, see #1507
|
||||||
if (n <= 0) return MG_IO_ERR;
|
if (n <= 0) return MG_IO_ERR;
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
@@ -250,7 +250,7 @@ static long recv_raw(struct mg_connection *c, void *buf, size_t len) {
|
|||||||
}
|
}
|
||||||
MG_VERBOSE(("%lu %ld %d", c->id, n, MG_SOCK_ERR(n)));
|
MG_VERBOSE(("%lu %ld %d", c->id, n, MG_SOCK_ERR(n)));
|
||||||
if (MG_SOCK_PENDING(n)) return MG_IO_WAIT;
|
if (MG_SOCK_PENDING(n)) return MG_IO_WAIT;
|
||||||
if (MG_SOCK_RESET(n)) return MG_IO_RESET;
|
if (MG_SOCK_RESET(n)) return MG_IO_RESET; // MbedTLS, see #1507
|
||||||
if (n <= 0) return MG_IO_ERR;
|
if (n <= 0) return MG_IO_ERR;
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
@@ -287,7 +287,7 @@ static void read_conn(struct mg_connection *c) {
|
|||||||
}
|
}
|
||||||
// there can still be > 16K from last iteration, always mg_tls_recv()
|
// there can still be > 16K from last iteration, always mg_tls_recv()
|
||||||
m = c->is_tls_hs ? (long) MG_IO_WAIT : mg_tls_recv(c, buf, len);
|
m = c->is_tls_hs ? (long) MG_IO_WAIT : mg_tls_recv(c, buf, len);
|
||||||
if (n == MG_IO_ERR) {
|
if (n == MG_IO_ERR || n == MG_IO_RESET) { // Windows, see #3031
|
||||||
if (c->rtls.len == 0 || m < 0) {
|
if (c->rtls.len == 0 || m < 0) {
|
||||||
// Close only when we have fully drained both rtls and TLS buffers
|
// Close only when we have fully drained both rtls and TLS buffers
|
||||||
c->is_closing = 1; // or there's nothing we can do about it.
|
c->is_closing = 1; // or there's nothing we can do about it.
|
||||||
|
|||||||
Reference in new issue
Block a user