We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 94ee7f6 commit 35087deCopy full SHA for 35087de
porting/npl/linux/src/os_mutex.c
@@ -71,6 +71,14 @@ ble_npl_mutex_pend(struct ble_npl_mutex *mu, uint32_t timeout)
71
mu->wait.tv_sec += timeout / 1000;
72
mu->wait.tv_nsec += (timeout % 1000) * 1000000;
73
74
+ /* struct timespec tv_nsec holds nanosecond and allowed range is
75
+ * 0 - 999999999, otherwise pthread_mutex_timedlock returns EINVAL
76
+ */
77
+ if (mu->wait.tv_nsec >= 1000000000) {
78
+ mu->wait.tv_sec += mu->wait.tv_nsec / 1000000000;
79
+ mu->wait.tv_nsec = mu->wait.tv_nsec % 1000000000;
80
+ }
81
+
82
err = pthread_mutex_timedlock(&mu->lock, &mu->wait);
83
if (err == ETIMEDOUT) {
84
return BLE_NPL_TIMEOUT;
0 commit comments