mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-11-18 20:10:53 +00:00
call accept-callback with ERR_MEM when allocating a pcb fails on passive open to inform the application about this error; ATTENTION: applications have to handle NULL pcb in accept callback!
This commit is contained in:
parent
c6b742812d
commit
7721b20179
@ -6,6 +6,11 @@ HISTORY
|
|||||||
|
|
||||||
++ New features:
|
++ New features:
|
||||||
|
|
||||||
|
2016-03-23: Simon Goldschmidt
|
||||||
|
* tcp: call accept-callback with ERR_MEM when allocating a pcb fails on
|
||||||
|
passive open to inform the application about this error
|
||||||
|
ATTENTION: applications have to handle NULL pcb in accept callback!
|
||||||
|
|
||||||
2016-02-22: Ivan Delamer
|
2016-02-22: Ivan Delamer
|
||||||
* Initial 6LoWPAN support
|
* Initial 6LoWPAN support
|
||||||
|
|
||||||
|
@ -468,6 +468,14 @@ accept_function(void *arg, struct tcp_pcb *newpcb, err_t err)
|
|||||||
|
|
||||||
LWIP_DEBUGF(API_MSG_DEBUG, ("accept_function: newpcb->tate: %s\n", tcp_debug_state_str(newpcb->state)));
|
LWIP_DEBUGF(API_MSG_DEBUG, ("accept_function: newpcb->tate: %s\n", tcp_debug_state_str(newpcb->state)));
|
||||||
|
|
||||||
|
if ((err != ERR_OK) || (arg == NULL)) {
|
||||||
|
return ERR_VAL;
|
||||||
|
}
|
||||||
|
if (newpcb == NULL) {
|
||||||
|
/* @todo: out-of-pcbs during connect: pass on this error to the application */
|
||||||
|
return ERR_VAL;
|
||||||
|
}
|
||||||
|
|
||||||
if (!sys_mbox_valid(&conn->acceptmbox)) {
|
if (!sys_mbox_valid(&conn->acceptmbox)) {
|
||||||
LWIP_DEBUGF(API_MSG_DEBUG, ("accept_function: acceptmbox already deleted\n"));
|
LWIP_DEBUGF(API_MSG_DEBUG, ("accept_function: acceptmbox already deleted\n"));
|
||||||
return ERR_VAL;
|
return ERR_VAL;
|
||||||
|
@ -2290,6 +2290,10 @@ http_accept(void *arg, struct tcp_pcb *pcb, err_t err)
|
|||||||
LWIP_UNUSED_ARG(err);
|
LWIP_UNUSED_ARG(err);
|
||||||
LWIP_DEBUGF(HTTPD_DEBUG, ("http_accept %p / %p\n", (void*)pcb, arg));
|
LWIP_DEBUGF(HTTPD_DEBUG, ("http_accept %p / %p\n", (void*)pcb, arg));
|
||||||
|
|
||||||
|
if ((err != ERR_OK) || (pcb == NULL)) {
|
||||||
|
return ERR_VAL;
|
||||||
|
}
|
||||||
|
|
||||||
/* Set priority */
|
/* Set priority */
|
||||||
tcp_setprio(pcb, HTTPD_TCP_PRIO);
|
tcp_setprio(pcb, HTTPD_TCP_PRIO);
|
||||||
|
|
||||||
|
@ -562,8 +562,10 @@ tcp_listen_input(struct tcp_pcb_listen *pcb)
|
|||||||
we don't do anything, but rely on the sender will retransmit the
|
we don't do anything, but rely on the sender will retransmit the
|
||||||
SYN at a time when we have more memory available. */
|
SYN at a time when we have more memory available. */
|
||||||
if (npcb == NULL) {
|
if (npcb == NULL) {
|
||||||
|
err_t err;
|
||||||
LWIP_DEBUGF(TCP_DEBUG, ("tcp_listen_input: could not allocate PCB\n"));
|
LWIP_DEBUGF(TCP_DEBUG, ("tcp_listen_input: could not allocate PCB\n"));
|
||||||
TCP_STATS_INC(tcp.memerr);
|
TCP_STATS_INC(tcp.memerr);
|
||||||
|
TCP_EVENT_ACCEPT(pcb, NULL, pcb->callback_arg, ERR_MEM, err);
|
||||||
return ERR_MEM;
|
return ERR_MEM;
|
||||||
}
|
}
|
||||||
#if TCP_LISTEN_BACKLOG
|
#if TCP_LISTEN_BACKLOG
|
||||||
@ -794,7 +796,7 @@ tcp_process(struct tcp_pcb *pcb)
|
|||||||
{
|
{
|
||||||
tcp_backlog_accepted(pcb);
|
tcp_backlog_accepted(pcb);
|
||||||
/* Call the accept function. */
|
/* Call the accept function. */
|
||||||
TCP_EVENT_ACCEPT(pcb, ERR_OK, err);
|
TCP_EVENT_ACCEPT(pcb->listener, pcb, pcb->callback_arg, ERR_OK, err);
|
||||||
}
|
}
|
||||||
if (err != ERR_OK) {
|
if (err != ERR_OK) {
|
||||||
/* If the accept function returns with an error, we abort
|
/* If the accept function returns with an error, we abort
|
||||||
|
@ -199,7 +199,7 @@ PACK_STRUCT_END
|
|||||||
|
|
||||||
#if LWIP_EVENT_API
|
#if LWIP_EVENT_API
|
||||||
|
|
||||||
#define TCP_EVENT_ACCEPT(pcb,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
|
#define TCP_EVENT_ACCEPT(lpcb,pcb,arg,err,ret) ret = lwip_tcp_event(arg, (pcb),\
|
||||||
LWIP_EVENT_ACCEPT, NULL, 0, err)
|
LWIP_EVENT_ACCEPT, NULL, 0, err)
|
||||||
#define TCP_EVENT_SENT(pcb,space,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
|
#define TCP_EVENT_SENT(pcb,space,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
|
||||||
LWIP_EVENT_SENT, NULL, space, ERR_OK)
|
LWIP_EVENT_SENT, NULL, space, ERR_OK)
|
||||||
@ -216,11 +216,11 @@ PACK_STRUCT_END
|
|||||||
|
|
||||||
#else /* LWIP_EVENT_API */
|
#else /* LWIP_EVENT_API */
|
||||||
|
|
||||||
#define TCP_EVENT_ACCEPT(pcb,err,ret) \
|
#define TCP_EVENT_ACCEPT(lpcb,pcb,arg,err,ret) \
|
||||||
do { \
|
do { \
|
||||||
if(((pcb)->listener != NULL) && ((pcb)->listener->accept != NULL)) \
|
if((lpcb != NULL) && ((lpcb)->accept != NULL)) \
|
||||||
(ret) = (pcb)->listener->accept((pcb)->callback_arg,(pcb),(err)); \
|
(ret) = (lpcb)->accept((arg),(pcb),(err)); \
|
||||||
else (ret) = ERR_ARG; \
|
else (ret) = ERR_ARG; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define TCP_EVENT_SENT(pcb,space,ret) \
|
#define TCP_EVENT_SENT(pcb,space,ret) \
|
||||||
|
Loading…
Reference in New Issue
Block a user