Skip to content

Commit

Permalink
Merge branch 'bugfix/sntp_init_can_run_before_net_connection_v3.3' in…
Browse files Browse the repository at this point in the history
…to 'release/v3.3'

lw_ip: Add to sys_arch_protect() a check that the mutex is created before use if not then creates it (v3.3)

See merge request espressif/esp-idf!7758
  • Loading branch information
jack0c committed Mar 18, 2020
2 parents 151b6d9 + 7013d2d commit 9e70825
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion components/lwip/port/esp32/freertos/sys_arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,11 @@ sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stacksize
void
sys_init(void)
{
if (!g_lwip_protect_mutex) {
if (ERR_OK != sys_mutex_new(&g_lwip_protect_mutex)) {
ESP_LOGE(TAG, "sys_init: failed to init lwip protect mutex\n");
ESP_LOGE(TAG, "sys_init: failed to init lwip protect mutex\n");
}
}

// Create the pthreads key for the per-thread semaphore storage
pthread_key_create(&sys_thread_sem_key, sys_thread_sem_free);
Expand Down Expand Up @@ -466,6 +468,9 @@ sys_now(void)
sys_prot_t
sys_arch_protect(void)
{
if (!g_lwip_protect_mutex) {
sys_mutex_new(&g_lwip_protect_mutex);
}
sys_mutex_lock(&g_lwip_protect_mutex);
return (sys_prot_t) 1;
}
Expand Down

0 comments on commit 9e70825

Please sign in to comment.