From 9906e4c984afbb9a36cf5ea7f55d9e566dc14be3 Mon Sep 17 00:00:00 2001 From: fbernon Date: Fri, 11 Jan 2008 23:50:10 +0000 Subject: [PATCH] api_msg.c, opt.h: replace DEFAULT_RECVMBOX_SIZE per DEFAULT_TCP_RECVMBOX_SIZE, DEFAULT_UDP_RECVMBOX_SIZE and DEFAULT_RAW_RECVMBOX_SIZE (to optimize queues sizes), like suggested for the task #7490 "Add return value to sys_mbox_post". --- CHANGELOG | 5 +++++ src/api/api_msg.c | 30 +++++++++++++++++++++++++++++- src/include/lwip/opt.h | 28 +++++++++++++++++++++++----- 3 files changed, 57 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 78e42f6d..9e95004a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,6 +19,11 @@ HISTORY ++ New features: + 2008-01-12 Frédéric Bernon + * api_msg.c, opt.h: replace DEFAULT_RECVMBOX_SIZE per DEFAULT_TCP_RECVMBOX_SIZE, + DEFAULT_UDP_RECVMBOX_SIZE and DEFAULT_RAW_RECVMBOX_SIZE (to optimize queues + sizes), like suggested for the task #7490 "Add return value to sys_mbox_post". + 2008-01-10 Frédéric Bernon * tcpip.h, tcpip.c: add tcpip_callback_with_block function for the task #7490 "Add return value to sys_mbox_post". tcpip_callback is always defined as diff --git a/src/api/api_msg.c b/src/api/api_msg.c index 8c63c4c9..508153aa 100644 --- a/src/api/api_msg.c +++ b/src/api/api_msg.c @@ -460,6 +460,7 @@ struct netconn* netconn_alloc(enum netconn_type t, netconn_callback callback) { struct netconn *conn; + int size; conn = memp_malloc(MEMP_NETCONN); if (conn == NULL) { @@ -470,15 +471,42 @@ netconn_alloc(enum netconn_type t, netconn_callback callback) conn->type = t; conn->pcb.tcp = NULL; +#if (DEFAULT_RAW_RECVMBOX_SIZE == DEFAULT_UDP_RECVMBOX_SIZE) && \ + (DEFAULT_RAW_RECVMBOX_SIZE == DEFAULT_TCP_RECVMBOX_SIZE) + size = DEFAULT_RAW_RECVMBOX_SIZE; +#else + switch(NETCONNTYPE_GROUP(t)) { +#if LWIP_RAW + case NETCONN_RAW: + size = DEFAULT_RAW_RECVMBOX_SIZE; + break; +#endif /* LWIP_RAW */ +#if LWIP_UDP + case NETCONN_UDP: + size = DEFAULT_UDP_RECVMBOX_SIZE; + break; +#endif /* LWIP_UDP */ +#if LWIP_TCP + case NETCONN_TCP: + size = DEFAULT_TCP_RECVMBOX_SIZE; + break; +#endif /* LWIP_TCP */ + default: + LWIP_ASSERT("netconn_alloc: undefined netconn_type", 0); + break; + } +#endif + if ((conn->sem = sys_sem_new(0)) == SYS_SEM_NULL) { memp_free(MEMP_NETCONN, conn); return NULL; } - if ((conn->recvmbox = sys_mbox_new(DEFAULT_RECVMBOX_SIZE)) == SYS_MBOX_NULL) { + if ((conn->recvmbox = sys_mbox_new(size)) == SYS_MBOX_NULL) { sys_sem_free(conn->sem); memp_free(MEMP_NETCONN, conn); return NULL; } + conn->acceptmbox = SYS_MBOX_NULL; conn->state = NETCONN_NONE; /* initialize socket to -1 since 0 is a valid socket */ diff --git a/src/include/lwip/opt.h b/src/include/lwip/opt.h index c7edb00a..bb0fce58 100644 --- a/src/include/lwip/opt.h +++ b/src/include/lwip/opt.h @@ -958,12 +958,30 @@ #endif /** - * DEFAULT_RECVMBOX_SIZE: The mailbox size for the incoming packets. - * The queue size value itself is platform-dependent, but is passed to - * sys_mbox_new() when the recvmbox is created. + * DEFAULT_RAW_RECVMBOX_SIZE: The mailbox size for the incoming packets on a + * NETCONN_RAW. The queue size value itself is platform-dependent, but is passed + * to sys_mbox_new() when the recvmbox is created. */ -#ifndef DEFAULT_RECVMBOX_SIZE -#define DEFAULT_RECVMBOX_SIZE 0 +#ifndef DEFAULT_RAW_RECVMBOX_SIZE +#define DEFAULT_RAW_RECVMBOX_SIZE 0 +#endif + +/** + * DEFAULT_UDP_RECVMBOX_SIZE: The mailbox size for the incoming packets on a + * NETCONN_UDP. The queue size value itself is platform-dependent, but is passed + * to sys_mbox_new() when the recvmbox is created. + */ +#ifndef DEFAULT_UDP_RECVMBOX_SIZE +#define DEFAULT_UDP_RECVMBOX_SIZE 0 +#endif + +/** + * DEFAULT_TCP_RECVMBOX_SIZE: The mailbox size for the incoming packets on a + * NETCONN_TCP. The queue size value itself is platform-dependent, but is passed + * to sys_mbox_new() when the recvmbox is created. + */ +#ifndef DEFAULT_TCP_RECVMBOX_SIZE +#define DEFAULT_TCP_RECVMBOX_SIZE 0 #endif /**