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".

This commit is contained in:
fbernon 2008-01-11 23:50:10 +00:00
parent 886cfbe12d
commit 9906e4c984
3 changed files with 57 additions and 6 deletions

View File

@ -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

View File

@ -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 */

View File

@ -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
/**