Commit 104106b9 authored by Deomid Ryabkov's avatar Deomid Ryabkov Committed by Cesanta Bot

Invoke tcp_accepted() on the listening pcb

As required by the LWIP API

PUBLISHED_FROM=7bfc6d816aa69f8fdd7592ade48b2d52e2d4991a
parent 474e065a
...@@ -14481,15 +14481,27 @@ void mg_lwip_handle_accept(struct mg_connection *nc) { ...@@ -14481,15 +14481,27 @@ void mg_lwip_handle_accept(struct mg_connection *nc) {
} }
static err_t mg_lwip_accept_cb(void *arg, struct tcp_pcb *newtpcb, err_t err) { static err_t mg_lwip_accept_cb(void *arg, struct tcp_pcb *newtpcb, err_t err) {
struct mg_connection *lc = (struct mg_connection *) arg; struct mg_connection *lc = (struct mg_connection *) arg, *nc;
DBG(("%p conn %p from %s:%u", lc, newtpcb, struct mg_lwip_conn_state *lcs, *cs;
struct tcp_pcb_listen *lpcb;
LOG(LL_INFO,
("%p conn %p from %s:%u", lc, newtpcb,
IPADDR_NTOA(ipX_2_ip(&newtpcb->remote_ip)), newtpcb->remote_port)); IPADDR_NTOA(ipX_2_ip(&newtpcb->remote_ip)), newtpcb->remote_port));
struct mg_connection *nc = mg_if_accept_new_conn(lc); if (lc == NULL) {
tcp_abort(newtpcb);
return ERR_ABRT;
}
lcs = (struct mg_lwip_conn_state *) lc->sock;
lpcb = (struct tcp_pcb_listen *) lcs->pcb.tcp;
#if TCP_LISTEN_BACKLOG
tcp_accepted(lpcb);
#endif
nc = mg_if_accept_new_conn(lc);
if (nc == NULL) { if (nc == NULL) {
tcp_abort(newtpcb); tcp_abort(newtpcb);
return ERR_ABRT; return ERR_ABRT;
} }
struct mg_lwip_conn_state *cs = (struct mg_lwip_conn_state *) nc->sock; cs = (struct mg_lwip_conn_state *) nc->sock;
cs->lc = lc; cs->lc = lc;
cs->pcb.tcp = newtpcb; cs->pcb.tcp = newtpcb;
/* We need to set up callbacks before returning because data may start /* We need to set up callbacks before returning because data may start
...@@ -14503,6 +14515,7 @@ static err_t mg_lwip_accept_cb(void *arg, struct tcp_pcb *newtpcb, err_t err) { ...@@ -14503,6 +14515,7 @@ static err_t mg_lwip_accept_cb(void *arg, struct tcp_pcb *newtpcb, err_t err) {
#endif #endif
mg_lwip_post_signal(MG_SIG_ACCEPT, nc); mg_lwip_post_signal(MG_SIG_ACCEPT, nc);
(void) err; (void) err;
(void) lpcb;
return ERR_OK; return ERR_OK;
} }
......
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