diff --git a/CHANGES b/CHANGES index 702c89a..398032e 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,8 @@ Changes ======= +v3.1.11.4 +- Fixed potential busy loop for mainloop applications + v3.1.11.3 - Fixed reading empty unions diff --git a/src/CommonAPI/SomeIP/Watch.cpp b/src/CommonAPI/SomeIP/Watch.cpp index a5fa0ab..0f12e53 100644 --- a/src/CommonAPI/SomeIP/Watch.cpp +++ b/src/CommonAPI/SomeIP/Watch.cpp @@ -228,8 +228,12 @@ void Watch::pushQueue(std::shared_ptr _queueEntry) { } } #else - if(write(pipeFileDescriptors_[1], &pipeValue_, sizeof(pipeValue_)) == -1) { - std::perror(__func__); + while (write(pipeFileDescriptors_[1], &pipeValue_, sizeof(pipeValue_)) == -1) { + if (errno != EAGAIN && errno != EINTR) { + std::perror(__func__); + break; + } + std::this_thread::yield(); } #endif } @@ -253,8 +257,12 @@ void Watch::popQueue() { } #else int readValue = 0; - if(read(pipeFileDescriptors_[0], &readValue, sizeof(readValue)) == -1) { - std::perror(__func__); + while (read(pipeFileDescriptors_[0], &readValue, sizeof(readValue)) == -1) { + if (errno != EAGAIN && errno != EINTR) { + std::perror(__func__); + break; + } + std::this_thread::yield(); } #endif