From d72d11c2006feecddde25122828e41a79f55c869 Mon Sep 17 00:00:00 2001
From: Rutger Huijgen <rn.huijgen@gmail.com>
Date: Fri, 17 Jul 2020 15:48:57 +0200
Subject: [PATCH] Added thread lock around timezone update function

---
 extras/sntp/sntp_fun.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/extras/sntp/sntp_fun.c b/extras/sntp/sntp_fun.c
index 9b952d7..a704697 100644
--- a/extras/sntp/sntp_fun.c
+++ b/extras/sntp/sntp_fun.c
@@ -49,12 +49,14 @@ void sntp_init(void);
 // Sets time zone.
 // NOTE: Settings do not take effect until SNTP time is updated.
 void sntp_set_timezone(const struct timezone *tz) {
+    xSemaphoreTake(sntp_sem, portMAX_DELAY);
     if (tz) {
         stz = *tz;
     } else {
         stz.tz_minuteswest = 0;
         stz.tz_dsttime = 0;
     }
+    xSemaphoreGive(sntp_sem);
 }
 
 // Initialization