mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-26 20:38:25 +00:00
can_write() honors link state
This commit is contained in:
1 parent
dc91248aca
commit
b30acaaabb
3 files changed
+12
-6
No files matched your search
+5
-3
@@ -12008,7 +12008,7 @@ static void mg_tcpip_poll(struct mg_tcpip_if *ifp, uint64_t now) {
|
|||||||
if (expired_1000ms) { // ifp->state rules over state6
|
if (expired_1000ms) { // ifp->state rules over state6
|
||||||
mg_ip_link(ifp, drv_up, l2_up); // Handle IPv4
|
mg_ip_link(ifp, drv_up, l2_up); // Handle IPv4
|
||||||
mg_ip6_link(ifp, drv_up, l2_up); // Handle IPv6
|
mg_ip6_link(ifp, drv_up, l2_up); // Handle IPv6
|
||||||
if (ifp->state < MG_TCPIP_STATE_UP) MG_ERROR(("Network is down"));
|
if (ifp->state < MG_TCPIP_STATE_UP) MG_ERROR(("Network is down, state %hhu", ifp->state));
|
||||||
mg_tcpip_call(ifp, MG_TCPIP_EV_TIMER_1S, NULL);
|
mg_tcpip_call(ifp, MG_TCPIP_EV_TIMER_1S, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12254,8 +12254,10 @@ static void write_conn(struct mg_connection *c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool can_write(struct mg_connection *c) {
|
static bool can_write(struct mg_connection *c) {
|
||||||
return c->is_connecting == 0 && c->is_resolving == 0 && c->send.len > 0 &&
|
struct mg_tcpip_if *ifp = c->mgr->ifp;
|
||||||
c->is_tls_hs == 0 && c->is_arplooking == 0;
|
bool ready = (ifp->ip != 0 && ifp->state == MG_TCPIP_STATE_READY);
|
||||||
|
return ready && c->is_connecting == 0 && c->is_resolving == 0 &&
|
||||||
|
c->send.len > 0 && c->is_tls_hs == 0 && c->is_arplooking == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mg_mgr_poll(struct mg_mgr *mgr, int ms) {
|
void mg_mgr_poll(struct mg_mgr *mgr, int ms) {
|
||||||
|
|||||||
+5
-3
@@ -2200,7 +2200,7 @@ static void mg_tcpip_poll(struct mg_tcpip_if *ifp, uint64_t now) {
|
|||||||
if (expired_1000ms) { // ifp->state rules over state6
|
if (expired_1000ms) { // ifp->state rules over state6
|
||||||
mg_ip_link(ifp, drv_up, l2_up); // Handle IPv4
|
mg_ip_link(ifp, drv_up, l2_up); // Handle IPv4
|
||||||
mg_ip6_link(ifp, drv_up, l2_up); // Handle IPv6
|
mg_ip6_link(ifp, drv_up, l2_up); // Handle IPv6
|
||||||
if (ifp->state < MG_TCPIP_STATE_UP) MG_ERROR(("Network is down"));
|
if (ifp->state < MG_TCPIP_STATE_UP) MG_ERROR(("Network is down, state %hhu", ifp->state));
|
||||||
mg_tcpip_call(ifp, MG_TCPIP_EV_TIMER_1S, NULL);
|
mg_tcpip_call(ifp, MG_TCPIP_EV_TIMER_1S, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2446,8 +2446,10 @@ static void write_conn(struct mg_connection *c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool can_write(struct mg_connection *c) {
|
static bool can_write(struct mg_connection *c) {
|
||||||
return c->is_connecting == 0 && c->is_resolving == 0 && c->send.len > 0 &&
|
struct mg_tcpip_if *ifp = c->mgr->ifp;
|
||||||
c->is_tls_hs == 0 && c->is_arplooking == 0;
|
bool ready = (ifp->ip != 0 && ifp->state == MG_TCPIP_STATE_READY);
|
||||||
|
return ready && c->is_connecting == 0 && c->is_resolving == 0 &&
|
||||||
|
c->send.len > 0 && c->is_tls_hs == 0 && c->is_arplooking == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mg_mgr_poll(struct mg_mgr *mgr, int ms) {
|
void mg_mgr_poll(struct mg_mgr *mgr, int ms) {
|
||||||
|
|||||||
@@ -1280,6 +1280,8 @@ static void test_frag_send_path(void) {
|
|||||||
mif.driver = &driver;
|
mif.driver = &driver;
|
||||||
mif.driver_data = &s_driver_data;
|
mif.driver_data = &s_driver_data;
|
||||||
mg_tcpip_init(&mgr, &mif);
|
mg_tcpip_init(&mgr, &mif);
|
||||||
|
mif.ip = mg_htonl(0xa00001);
|
||||||
|
mif.state = MG_TCPIP_STATE_READY; // so can_write() lets the data out
|
||||||
mif.mtu = 500; // force ad hoc small MTU to fragment IP
|
mif.mtu = 500; // force ad hoc small MTU to fragment IP
|
||||||
mg_http_listen(&mgr, "http://0.0.0.0:80", frag_send_fn, NULL);
|
mg_http_listen(&mgr, "http://0.0.0.0:80", frag_send_fn, NULL);
|
||||||
mgr.conns->pfn = NULL;
|
mgr.conns->pfn = NULL;
|
||||||
|
|||||||
Reference in new issue
Block a user