We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3790e4e commit 1f9196aCopy full SHA for 1f9196a
1 file changed
threadpool.cpp
@@ -207,20 +207,18 @@ void ThreadPool::post_sem(sem_t* const sem)
207
208
void ThreadPool::wait_sem(sem_t* const sem)
209
{
210
- for (;;) {
211
- int ret = sem_wait(sem);
212
- if (0 == ret) {
213
- return;
214
- }
+ int ret = 0;
+ do {
+ ret = sem_wait(sem);
+ } while (0 != ret && EINTR == errno);
215
216
- switch (errno) {
217
- case EINTR:
218
- break;
219
- case EINVAL:
220
- throw Error("EINVAL returned by sem_wait()");
221
- default:
222
- throw Error("UNKNOWN returned by sem_wait()");
223
+ if (0 == ret) return;
+
+ switch (errno) {
+ case EINVAL:
+ throw Error("EINVAL returned by sem_wait()");
+ default:
+ throw Error("UNKNOWN returned by sem_wait()");
224
}
225
226
0 commit comments