Skip to content

Commit 3226cc2

Browse files
committed
fix: bridge.notify not acquiring mutex
1 parent fe524ff commit 3226cc2

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/bridge.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class BridgeClass {
145145
} else {
146146
k_yield();
147147
}
148-
}
148+
}
149149

150150
// Lock read mutex
151151
while(true) {
@@ -168,7 +168,14 @@ class BridgeClass {
168168

169169
template<typename... Args>
170170
void notify(const MsgPack::str_t method, Args&&... args) {
171-
client->notify(method, std::forward<Args>(args)...);
171+
while (true) {
172+
if (k_mutex_lock(&write_mutex, K_MSEC(10)) == 0) {
173+
client->notify(method, std::forward<Args>(args)...);
174+
k_mutex_unlock(&write_mutex);
175+
break;
176+
}
177+
k_yield();
178+
}
172179
}
173180

174181
String get_error_message() const {

0 commit comments

Comments
 (0)