mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-09-12 17:55:38 +00:00
altcp: allocate altcp_pcbs from a pool, not from heap (new option MEMP_NUM_ALTCP_PCB defaults to MEMP_NUM_TCP_PCB)
This commit is contained in:
parent
0f4ad57033
commit
b34f2d5605
@ -59,8 +59,7 @@ extern const struct altcp_functions altcp_tcp_functions;
|
|||||||
struct altcp_pcb *
|
struct altcp_pcb *
|
||||||
altcp_alloc(void)
|
altcp_alloc(void)
|
||||||
{
|
{
|
||||||
/* FIXME: pool alloc */
|
struct altcp_pcb *ret = (struct altcp_pcb *)memp_malloc(MEMP_ALTCP_PCB);
|
||||||
struct altcp_pcb *ret = (struct altcp_pcb *)mem_malloc(sizeof(struct altcp_pcb));
|
|
||||||
if (ret != NULL) {
|
if (ret != NULL) {
|
||||||
memset(ret, 0, sizeof(struct altcp_pcb));
|
memset(ret, 0, sizeof(struct altcp_pcb));
|
||||||
}
|
}
|
||||||
@ -70,9 +69,8 @@ altcp_alloc(void)
|
|||||||
void
|
void
|
||||||
altcp_free(struct altcp_pcb *conn)
|
altcp_free(struct altcp_pcb *conn)
|
||||||
{
|
{
|
||||||
/* FIXME: pool alloc */
|
|
||||||
if (conn) {
|
if (conn) {
|
||||||
mem_free(conn);
|
memp_free(MEMP_ALTCP_PCB, conn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,6 +57,7 @@
|
|||||||
#include "lwip/udp.h"
|
#include "lwip/udp.h"
|
||||||
#include "lwip/tcp.h"
|
#include "lwip/tcp.h"
|
||||||
#include "lwip/priv/tcp_priv.h"
|
#include "lwip/priv/tcp_priv.h"
|
||||||
|
#include "lwip/altcp.h"
|
||||||
#include "lwip/ip4_frag.h"
|
#include "lwip/ip4_frag.h"
|
||||||
#include "lwip/netbuf.h"
|
#include "lwip/netbuf.h"
|
||||||
#include "lwip/api.h"
|
#include "lwip/api.h"
|
||||||
|
@ -399,6 +399,16 @@
|
|||||||
#define MEMP_NUM_TCP_SEG 16
|
#define MEMP_NUM_TCP_SEG 16
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MEMP_NUM_ALTCP_PCB: the number of simultaneously active altcp layer pcbs.
|
||||||
|
* (requires the LWIP_ALTCP option)
|
||||||
|
* Connections with multiple layers require more than one altcp_pcb (e.g. TLS
|
||||||
|
* over TCP requires 2 altcp_pcbs, one for TLS and one for TCP).
|
||||||
|
*/
|
||||||
|
#if !defined MEMP_NUM_ALTCP_PCB || defined __DOXYGEN__
|
||||||
|
#define MEMP_NUM_ALTCP_PCB MEMP_NUM_TCP_PCB
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MEMP_NUM_REASSDATA: the number of IP packets simultaneously queued for
|
* MEMP_NUM_REASSDATA: the number of IP packets simultaneously queued for
|
||||||
* reassembly (whole packets, not fragments!)
|
* reassembly (whole packets, not fragments!)
|
||||||
|
@ -52,6 +52,10 @@ LWIP_MEMPOOL(TCP_PCB_LISTEN, MEMP_NUM_TCP_PCB_LISTEN, sizeof(struct tcp_pcb_lis
|
|||||||
LWIP_MEMPOOL(TCP_SEG, MEMP_NUM_TCP_SEG, sizeof(struct tcp_seg), "TCP_SEG")
|
LWIP_MEMPOOL(TCP_SEG, MEMP_NUM_TCP_SEG, sizeof(struct tcp_seg), "TCP_SEG")
|
||||||
#endif /* LWIP_TCP */
|
#endif /* LWIP_TCP */
|
||||||
|
|
||||||
|
#if LWIP_ALTCP && LWIP_TCP
|
||||||
|
LWIP_MEMPOOL(ALTCP_PCB, MEMP_NUM_ALTCP_PCB, sizeof(struct altcp_pcb), "ALTCP_PCB")
|
||||||
|
#endif /* LWIP_ALTCP && LWIP_TCP */
|
||||||
|
|
||||||
#if LWIP_IPV4 && IP_REASSEMBLY
|
#if LWIP_IPV4 && IP_REASSEMBLY
|
||||||
LWIP_MEMPOOL(REASSDATA, MEMP_NUM_REASSDATA, sizeof(struct ip_reassdata), "REASSDATA")
|
LWIP_MEMPOOL(REASSDATA, MEMP_NUM_REASSDATA, sizeof(struct ip_reassdata), "REASSDATA")
|
||||||
#endif /* LWIP_IPV4 && IP_REASSEMBLY */
|
#endif /* LWIP_IPV4 && IP_REASSEMBLY */
|
||||||
|
Loading…
Reference in New Issue
Block a user