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 "blocking" ("block" parameter = 1).

This commit is contained in:
fbernon 2008-01-10 21:47:52 +00:00
parent bceff76c70
commit 4e40fee1db
3 changed files with 18 additions and 3 deletions

View File

@ -19,6 +19,11 @@ HISTORY
++ New features:
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
"blocking" ("block" parameter = 1).
2008-01-10 Frédéric Bernon
* tcpip.h, tcpip.c, api.h, api_lib.c, api_msg.c, sockets.c: replace the field
netconn::mbox (sys_mbox_t) per netconn::sem (sys_sem_t) for the task #7490

View File

@ -349,10 +349,11 @@ tcpip_input(struct pbuf *p, struct netif *inp)
*
* @param f the function to call
* @param ctx parameter passed to f
* @param block 1 to block until the request is posted, 0 to non-blocking mode
* @return ERR_OK if the function was called, another err_t if not
*/
err_t
tcpip_callback(void (*f)(void *ctx), void *ctx)
tcpip_callback_with_block(void (*f)(void *ctx), void *ctx, u8_t block)
{
struct tcpip_msg *msg;
@ -365,7 +366,14 @@ tcpip_callback(void (*f)(void *ctx), void *ctx)
msg->type = TCPIP_MSG_CALLBACK;
msg->msg.cb.f = f;
msg->msg.cb.ctx = ctx;
sys_mbox_post(mbox, msg);
if (block) {
sys_mbox_post(mbox, msg);
} else {
if (sys_mbox_trypost(mbox, msg) != ERR_OK) {
memp_free(MEMP_TCPIP_MSG_API, msg);
return ERR_MEM;
}
}
return ERR_OK;
}
return ERR_VAL;

View File

@ -82,7 +82,9 @@ err_t tcpip_netifapi_lock(struct netifapi_msg *netifapimsg);
#endif /* LWIP_TCPIP_CORE_LOCKING */
#endif /* LWIP_NETIF_API */
err_t tcpip_callback(void (*f)(void *ctx), void *ctx);
err_t tcpip_callback_with_block(void (*f)(void *ctx), void *ctx, u8_t block);
#define tcpip_callback(f,ctx) tcpip_callback_with_block(f,ctx,1)
err_t tcpip_timeout(u32_t msecs, sys_timeout_handler h, void *arg);
#define tcpip_untimeout(h, arg) tcpip_timeout(0xffffffff, h, arg)