mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-04 05:39:53 +00:00
tcpip.c tcpip_send_api_msg: Handle core locking case internally
This commit is contained in:
parent
bc51dddcaf
commit
ea174560b1
@ -312,10 +312,11 @@ tcpip_untimeout(sys_timeout_handler h, void *arg)
|
|||||||
#endif /* LWIP_TCPIP_TIMEOUT */
|
#endif /* LWIP_TCPIP_TIMEOUT */
|
||||||
|
|
||||||
|
|
||||||
#if !LWIP_TCPIP_CORE_LOCKING
|
|
||||||
/**
|
/**
|
||||||
* Generic way to dispatch an API message in TCPIP thread and wait for its
|
* Synchronously calls function in TCPIP thread and waits for its completion
|
||||||
* completion by blocking on a semaphore.
|
* by blocking on a provided semaphore pointer.
|
||||||
|
* It is recommended to use LWIP_TCPIP_CORE_LOCKING since this is the way
|
||||||
|
* with least runtime overhead.
|
||||||
*
|
*
|
||||||
* @param fn function to be called from TCPIP thread
|
* @param fn function to be called from TCPIP thread
|
||||||
* @param apimsg argument to API function
|
* @param apimsg argument to API function
|
||||||
@ -327,6 +328,13 @@ tcpip_send_api_msg(tcpip_callback_fn fn, void *apimsg, sys_sem_t* sem)
|
|||||||
{
|
{
|
||||||
LWIP_ASSERT("semaphore not initialized", sys_sem_valid(sem));
|
LWIP_ASSERT("semaphore not initialized", sys_sem_valid(sem));
|
||||||
|
|
||||||
|
#if LWIP_TCPIP_CORE_LOCKING
|
||||||
|
LOCK_TCPIP_CORE();
|
||||||
|
fn(apimsg);
|
||||||
|
UNLOCK_TCPIP_CORE();
|
||||||
|
sys_arch_sem_wait(sem, 0);
|
||||||
|
return ERR_OK;
|
||||||
|
#else /* LWIP_TCPIP_CORE_LOCKING */
|
||||||
if (sys_mbox_valid_val(mbox)) {
|
if (sys_mbox_valid_val(mbox)) {
|
||||||
TCPIP_MSG_VAR_DECLARE(msg);
|
TCPIP_MSG_VAR_DECLARE(msg);
|
||||||
|
|
||||||
@ -340,8 +348,8 @@ tcpip_send_api_msg(tcpip_callback_fn fn, void *apimsg, sys_sem_t* sem)
|
|||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
return ERR_VAL;
|
return ERR_VAL;
|
||||||
|
#endif /* LWIP_TCPIP_CORE_LOCKING */
|
||||||
}
|
}
|
||||||
#endif /* !LWIP_TCPIP_CORE_LOCKING */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Synchronously calls function in TCPIP thread and waits for its completion.
|
* Synchronously calls function in TCPIP thread and waits for its completion.
|
||||||
@ -361,7 +369,7 @@ err_t tcpip_api_call(tcpip_api_call_fn fn, struct tcpip_api_call *call)
|
|||||||
err = fn(call);
|
err = fn(call);
|
||||||
UNLOCK_TCPIP_CORE();
|
UNLOCK_TCPIP_CORE();
|
||||||
return err;
|
return err;
|
||||||
#else
|
#else /* LWIP_TCPIP_CORE_LOCKING */
|
||||||
if (sys_mbox_valid_val(mbox)) {
|
if (sys_mbox_valid_val(mbox)) {
|
||||||
TCPIP_MSG_VAR_DECLARE(msg);
|
TCPIP_MSG_VAR_DECLARE(msg);
|
||||||
err_t err;
|
err_t err;
|
||||||
@ -390,7 +398,7 @@ err_t tcpip_api_call(tcpip_api_call_fn fn, struct tcpip_api_call *call)
|
|||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
return ERR_VAL;
|
return ERR_VAL;
|
||||||
#endif
|
#endif /* LWIP_TCPIP_CORE_LOCKING */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -95,9 +95,7 @@ extern sys_mutex_t lock_tcpip_core;
|
|||||||
#define API_EXPR_DEREF(expr) *(expr)
|
#define API_EXPR_DEREF(expr) *(expr)
|
||||||
#endif /* LWIP_MPU_COMPATIBLE */
|
#endif /* LWIP_MPU_COMPATIBLE */
|
||||||
|
|
||||||
#if !LWIP_TCPIP_CORE_LOCKING
|
|
||||||
err_t tcpip_send_api_msg(tcpip_callback_fn fn, void *apimsg, sys_sem_t* sem);
|
err_t tcpip_send_api_msg(tcpip_callback_fn fn, void *apimsg, sys_sem_t* sem);
|
||||||
#endif /* !LWIP_TCPIP_CORE_LOCKING */
|
|
||||||
|
|
||||||
struct tcpip_api_call;
|
struct tcpip_api_call;
|
||||||
typedef err_t (*tcpip_api_call_fn)(struct tcpip_api_call* call);
|
typedef err_t (*tcpip_api_call_fn)(struct tcpip_api_call* call);
|
||||||
|
Loading…
Reference in New Issue
Block a user