Attempt to make the main thread wait for network mutex.
This commit is contained in:
@@ -203,6 +203,7 @@ extern void thread_destroy_event(event_t *arg);
|
||||
|
||||
extern mutex_t *thread_create_mutex(void);
|
||||
extern void thread_close_mutex(mutex_t *arg);
|
||||
extern int thread_test_mutex(mutex_t *arg);
|
||||
extern int thread_wait_mutex(mutex_t *arg);
|
||||
extern int thread_release_mutex(mutex_t *mutex);
|
||||
|
||||
|
@@ -348,7 +348,7 @@ network_rx_queue(void *priv)
|
||||
{
|
||||
int ret = 1;
|
||||
|
||||
if (network_rx_pause) {
|
||||
if (network_rx_pause || !thread_test_mutex(network_mutex)) {
|
||||
timer_on_auto(&network_rx_queue_timer, 0.762939453125 * 2.0 * 128.0);
|
||||
return;
|
||||
}
|
||||
|
@@ -37,6 +37,16 @@ thread_create_mutex(void)
|
||||
return mutex;
|
||||
}
|
||||
|
||||
int
|
||||
thread_test_mutex(mutex_t *_mutex)
|
||||
{
|
||||
if (_mutex == nullptr)
|
||||
return 0;
|
||||
|
||||
auto mutex = reinterpret_cast<std::mutex*>(_mutex);
|
||||
return mutex->try_lock() ? 1 : 0;
|
||||
}
|
||||
|
||||
int
|
||||
thread_wait_mutex(mutex_t *_mutex)
|
||||
{
|
||||
|
Reference in New Issue
Block a user