Skip to content

Commit d4cae3a

Browse files
committed
mod: RpcResult _executed guard moved inside result method. result method must be executed exactly once
1 parent eab384e commit d4cae3a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/bridge.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ class RpcResult {
3636
RpcResult(uint32_t id, RPCClient* c, struct k_mutex* m, int timeout) : msg_id_wait(id), client(c), read_mutex(m), _timeout(timeout) {}
3737

3838
template<typename RType> bool result(RType& result, int timeout = -1) {
39+
if (_executed) return client->lastError.code == NO_ERR;
40+
3941
if (timeout > 0) _timeout = timeout;
4042

4143
int start = millis();
@@ -61,7 +63,6 @@ class RpcResult {
6163
}
6264

6365
operator bool() {
64-
if (_executed) return client->lastError.code == NO_ERR;
6566
MsgPack::object::nil_t nil;
6667
return result(nil, FALLBACK_TIMEOUT);
6768
}

0 commit comments

Comments
 (0)