Skip to content

Commit 82341fb

Browse files
Lucjan BryndzaLucjan Bryndza
andauthored
[EGD-4029] Prevent call handler recursively (#927)
Prevent call notification handler from thread which register notification handler. Co-authored-by: Lucjan Bryndza <[email protected]>
1 parent a91ca2a commit 82341fb

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

module-vfs/vfsNotifier.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <mutex.hpp>
88
#include <functional>
99
#include <string>
10+
#include <thread.hpp>
1011

1112
namespace vfsn::utility
1213
{
@@ -69,6 +70,7 @@ namespace vfsn::utility
6970
auto registerNotificationHandler(NotifyHandler hwnd) -> void
7071
{
7172
notificationCallback = hwnd;
73+
threadHandle = hwnd ? cpp_freertos::Thread::GetCurrentThreadHandle() : nullptr;
7274
}
7375

7476
private:
@@ -80,7 +82,7 @@ namespace vfsn::utility
8082
*/
8183
auto notify(std::string_view file, FsEvent event, std::string_view old_file = "") -> void
8284
{
83-
if (notificationCallback)
85+
if (threadHandle != cpp_freertos::Thread::GetCurrentThreadHandle() && notificationCallback)
8486
notificationCallback(file, event, old_file);
8587
}
8688

@@ -91,5 +93,6 @@ namespace vfsn::utility
9193
cpp_freertos::MutexStandard mMutex;
9294
//! Notification handler callback
9395
NotifyHandler notificationCallback;
96+
TaskHandle_t threadHandle;
9497
};
9598
} // namespace vfsn::utility

0 commit comments

Comments
 (0)