Attempt to make the main thread wait for network mutex.

This commit is contained in:
OBattler
2022-02-20 01:22:28 +01:00
parent ee5630f9c4
commit bd32abf94e
3 changed files with 12 additions and 1 deletions

View File

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

View File

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

View File

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