mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
core, modules: Remove useless EINTR tests
Since commit ad447d1468 (in 2009) pa_read and pa_write take care of
handling EINTR error.
So, pa_read, pa_write, pa_iochannel_read and pa_iochannel_write can not
exit with errno set to EINTR, and testing it is useless.
This commit is contained in:
parent
8342c12339
commit
05f3e8bf9a
10 changed files with 31 additions and 82 deletions
|
|
@ -279,10 +279,6 @@ static int sco_process_render(struct userdata *u) {
|
||||||
|
|
||||||
saved_errno = errno;
|
saved_errno = errno;
|
||||||
|
|
||||||
if (saved_errno == EINTR)
|
|
||||||
/* Retry right away if we got interrupted */
|
|
||||||
continue;
|
|
||||||
|
|
||||||
pa_memblock_unref(memchunk.memblock);
|
pa_memblock_unref(memchunk.memblock);
|
||||||
|
|
||||||
if (saved_errno == EAGAIN) {
|
if (saved_errno == EAGAIN) {
|
||||||
|
|
@ -462,11 +458,7 @@ static int a2dp_write_buffer(struct userdata *u, size_t nbytes) {
|
||||||
|
|
||||||
if (l < 0) {
|
if (l < 0) {
|
||||||
|
|
||||||
if (errno == EINTR)
|
if (errno == EAGAIN) {
|
||||||
/* Retry right away if we got interrupted */
|
|
||||||
continue;
|
|
||||||
|
|
||||||
else if (errno == EAGAIN) {
|
|
||||||
/* Hmm, apparently the socket was not writable, give up for now */
|
/* Hmm, apparently the socket was not writable, give up for now */
|
||||||
pa_log_debug("Got EAGAIN on write() after POLLOUT, probably there is a temporary connection loss.");
|
pa_log_debug("Got EAGAIN on write() after POLLOUT, probably there is a temporary connection loss.");
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -249,9 +249,7 @@ static void thread_func(void *userdata) {
|
||||||
|
|
||||||
if (l < 0) {
|
if (l < 0) {
|
||||||
|
|
||||||
if (errno == EINTR)
|
if (errno == EAGAIN) {
|
||||||
continue;
|
|
||||||
else if (errno == EAGAIN) {
|
|
||||||
|
|
||||||
/* OK, we filled all socket buffers up
|
/* OK, we filled all socket buffers up
|
||||||
* now. */
|
* now. */
|
||||||
|
|
|
||||||
|
|
@ -199,14 +199,13 @@ static ssize_t pipe_sink_write(struct userdata *u, pa_memchunk *pchunk) {
|
||||||
if (l < 0) {
|
if (l < 0) {
|
||||||
if (errno == EAGAIN)
|
if (errno == EAGAIN)
|
||||||
break;
|
break;
|
||||||
else if (errno != EINTR) {
|
|
||||||
if (!u->fifo_error) {
|
if (!u->fifo_error) {
|
||||||
pa_log("Failed to write data to FIFO: %s", pa_cstrerror(errno));
|
pa_log("Failed to write data to FIFO: %s", pa_cstrerror(errno));
|
||||||
u->fifo_error = true;
|
u->fifo_error = true;
|
||||||
}
|
|
||||||
count = -1 - count;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
count = -1 - count;
|
||||||
|
break;
|
||||||
} else {
|
} else {
|
||||||
if (u->fifo_error) {
|
if (u->fifo_error) {
|
||||||
pa_log_debug("Recovered from FIFO error");
|
pa_log_debug("Recovered from FIFO error");
|
||||||
|
|
@ -288,9 +287,7 @@ static int process_render(struct userdata *u) {
|
||||||
|
|
||||||
if (l < 0) {
|
if (l < 0) {
|
||||||
|
|
||||||
if (errno == EINTR)
|
if (errno == EAGAIN)
|
||||||
continue;
|
|
||||||
else if (errno == EAGAIN)
|
|
||||||
return 0;
|
return 0;
|
||||||
else {
|
else {
|
||||||
pa_log("Failed to write data to FIFO: %s", pa_cstrerror(errno));
|
pa_log("Failed to write data to FIFO: %s", pa_cstrerror(errno));
|
||||||
|
|
|
||||||
|
|
@ -155,9 +155,7 @@ static void thread_func(void *userdata) {
|
||||||
|
|
||||||
if (l < 0) {
|
if (l < 0) {
|
||||||
|
|
||||||
if (errno == EINTR)
|
if (errno != EAGAIN) {
|
||||||
continue;
|
|
||||||
else if (errno != EAGAIN) {
|
|
||||||
pa_log("Failed to read data from FIFO: %s", pa_cstrerror(errno));
|
pa_log("Failed to read data from FIFO: %s", pa_cstrerror(errno));
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -714,9 +714,7 @@ static void thread_func(void *userdata) {
|
||||||
pa_memblock_release(u->memchunk.memblock);
|
pa_memblock_release(u->memchunk.memblock);
|
||||||
|
|
||||||
if (w <= 0) {
|
if (w <= 0) {
|
||||||
if (errno == EINTR) {
|
if (errno == EAGAIN) {
|
||||||
continue;
|
|
||||||
} else if (errno == EAGAIN) {
|
|
||||||
/* We may have realtime priority so yield the CPU to ensure that fd can become writable again. */
|
/* We may have realtime priority so yield the CPU to ensure that fd can become writable again. */
|
||||||
pa_log_debug("EAGAIN with %llu bytes buffered.", buffered_bytes);
|
pa_log_debug("EAGAIN with %llu bytes buffered.", buffered_bytes);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -980,10 +980,7 @@ static void thread_func(void *userdata) {
|
||||||
|
|
||||||
if (t < 0) {
|
if (t < 0) {
|
||||||
|
|
||||||
if (errno == EINTR)
|
if (errno == EAGAIN) {
|
||||||
continue;
|
|
||||||
|
|
||||||
else if (errno == EAGAIN) {
|
|
||||||
pa_log_debug("EAGAIN");
|
pa_log_debug("EAGAIN");
|
||||||
|
|
||||||
revents &= ~POLLOUT;
|
revents &= ~POLLOUT;
|
||||||
|
|
@ -1087,10 +1084,7 @@ static void thread_func(void *userdata) {
|
||||||
if (t < 0) {
|
if (t < 0) {
|
||||||
pa_memblock_unref(memchunk.memblock);
|
pa_memblock_unref(memchunk.memblock);
|
||||||
|
|
||||||
if (errno == EINTR)
|
if (errno == EAGAIN) {
|
||||||
continue;
|
|
||||||
|
|
||||||
else if (errno == EAGAIN) {
|
|
||||||
pa_log_debug("EAGAIN");
|
pa_log_debug("EAGAIN");
|
||||||
|
|
||||||
revents &= ~POLLIN;
|
revents &= ~POLLIN;
|
||||||
|
|
|
||||||
|
|
@ -151,26 +151,16 @@ static void flush(pa_fdsem *f) {
|
||||||
uint64_t u;
|
uint64_t u;
|
||||||
|
|
||||||
if ((r = pa_read(f->efd, &u, sizeof(u), NULL)) != sizeof(u)) {
|
if ((r = pa_read(f->efd, &u, sizeof(u), NULL)) != sizeof(u)) {
|
||||||
|
pa_log_error("Invalid read from eventfd: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
|
||||||
if (r >= 0 || errno != EINTR) {
|
pa_assert_not_reached();
|
||||||
pa_log_error("Invalid read from eventfd: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
|
|
||||||
pa_assert_not_reached();
|
|
||||||
}
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
r = (ssize_t) u;
|
r = (ssize_t) u;
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((r = pa_read(f->fds[0], &x, sizeof(x), NULL)) <= 0) {
|
if ((r = pa_read(f->fds[0], &x, sizeof(x), NULL)) <= 0) {
|
||||||
|
pa_log_error("Invalid read from pipe: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
|
||||||
if (r >= 0 || errno != EINTR) {
|
pa_assert_not_reached();
|
||||||
pa_log_error("Invalid read from pipe: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
|
|
||||||
pa_assert_not_reached();
|
|
||||||
}
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (pa_atomic_sub(&f->data->in_pipe, (int) r) > (int) r);
|
} while (pa_atomic_sub(&f->data->in_pipe, (int) r) > (int) r);
|
||||||
|
|
@ -194,23 +184,15 @@ void pa_fdsem_post(pa_fdsem *f) {
|
||||||
uint64_t u = 1;
|
uint64_t u = 1;
|
||||||
|
|
||||||
if ((r = pa_write(f->efd, &u, sizeof(u), &f->write_type)) != sizeof(u)) {
|
if ((r = pa_write(f->efd, &u, sizeof(u), &f->write_type)) != sizeof(u)) {
|
||||||
if (r >= 0 || errno != EINTR) {
|
pa_log_error("Invalid write to eventfd: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
|
||||||
pa_log_error("Invalid write to eventfd: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
|
pa_assert_not_reached();
|
||||||
pa_assert_not_reached();
|
|
||||||
}
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((r = pa_write(f->fds[1], &x, 1, &f->write_type)) != 1) {
|
if ((r = pa_write(f->fds[1], &x, 1, &f->write_type)) != 1) {
|
||||||
if (r >= 0 || errno != EINTR) {
|
pa_log_error("Invalid write to pipe: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
|
||||||
pa_log_error("Invalid write to pipe: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
|
pa_assert_not_reached();
|
||||||
pa_assert_not_reached();
|
|
||||||
}
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
@ -238,13 +220,8 @@ void pa_fdsem_wait(pa_fdsem *f) {
|
||||||
uint64_t u;
|
uint64_t u;
|
||||||
|
|
||||||
if ((r = pa_read(f->efd, &u, sizeof(u), NULL)) != sizeof(u)) {
|
if ((r = pa_read(f->efd, &u, sizeof(u), NULL)) != sizeof(u)) {
|
||||||
|
pa_log_error("Invalid read from eventfd: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
|
||||||
if (r >= 0 || errno != EINTR) {
|
pa_assert_not_reached();
|
||||||
pa_log_error("Invalid read from eventfd: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
|
|
||||||
pa_assert_not_reached();
|
|
||||||
}
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
r = (ssize_t) u;
|
r = (ssize_t) u;
|
||||||
|
|
@ -252,13 +229,8 @@ void pa_fdsem_wait(pa_fdsem *f) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((r = pa_read(f->fds[0], &x, sizeof(x), NULL)) <= 0) {
|
if ((r = pa_read(f->fds[0], &x, sizeof(x), NULL)) <= 0) {
|
||||||
|
pa_log_error("Invalid read from pipe: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
|
||||||
if (r >= 0 || errno != EINTR) {
|
pa_assert_not_reached();
|
||||||
pa_log_error("Invalid read from pipe: %s", r < 0 ? pa_cstrerror(errno) : "EOF");
|
|
||||||
pa_assert_not_reached();
|
|
||||||
}
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pa_atomic_sub(&f->data->in_pipe, (int) r);
|
pa_atomic_sub(&f->data->in_pipe, (int) r);
|
||||||
|
|
|
||||||
|
|
@ -227,7 +227,7 @@ ssize_t pa_iochannel_write(pa_iochannel*io, const void*data, size_t l) {
|
||||||
return r; /* Fast path - we almost always successfully write everything */
|
return r; /* Fast path - we almost always successfully write everything */
|
||||||
|
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
if (errno == EINTR || errno == EAGAIN)
|
if (errno == EAGAIN)
|
||||||
r = 0;
|
r = 0;
|
||||||
else
|
else
|
||||||
return r;
|
return r;
|
||||||
|
|
|
||||||
|
|
@ -1010,7 +1010,7 @@ static int do_read(connection *c) {
|
||||||
((uint8_t*) &c->request) + c->read_data_length,
|
((uint8_t*) &c->request) + c->read_data_length,
|
||||||
sizeof(c->request) - c->read_data_length)) <= 0) {
|
sizeof(c->request) - c->read_data_length)) <= 0) {
|
||||||
|
|
||||||
if (r < 0 && (errno == EINTR || errno == EAGAIN))
|
if (r < 0 && errno == EAGAIN)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
pa_log_debug("read(): %s", r < 0 ? pa_cstrerror(errno) : "EOF");
|
pa_log_debug("read(): %s", r < 0 ? pa_cstrerror(errno) : "EOF");
|
||||||
|
|
@ -1066,7 +1066,7 @@ static int do_read(connection *c) {
|
||||||
(uint8_t*) c->read_data + c->read_data_length,
|
(uint8_t*) c->read_data + c->read_data_length,
|
||||||
handler->data_length - c->read_data_length)) <= 0) {
|
handler->data_length - c->read_data_length)) <= 0) {
|
||||||
|
|
||||||
if (r < 0 && (errno == EINTR || errno == EAGAIN))
|
if (r < 0 && errno == EAGAIN)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
pa_log_debug("read(): %s", r < 0 ? pa_cstrerror(errno) : "EOF");
|
pa_log_debug("read(): %s", r < 0 ? pa_cstrerror(errno) : "EOF");
|
||||||
|
|
@ -1097,7 +1097,7 @@ static int do_read(connection *c) {
|
||||||
pa_memblock_release(c->scache.memchunk.memblock);
|
pa_memblock_release(c->scache.memchunk.memblock);
|
||||||
|
|
||||||
if (r <= 0) {
|
if (r <= 0) {
|
||||||
if (r < 0 && (errno == EINTR || errno == EAGAIN))
|
if (r < 0 && errno == EAGAIN)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
pa_log_debug("read(): %s", r < 0 ? pa_cstrerror(errno) : "EOF");
|
pa_log_debug("read(): %s", r < 0 ? pa_cstrerror(errno) : "EOF");
|
||||||
|
|
@ -1165,7 +1165,7 @@ static int do_read(connection *c) {
|
||||||
|
|
||||||
if (r <= 0) {
|
if (r <= 0) {
|
||||||
|
|
||||||
if (r < 0 && (errno == EINTR || errno == EAGAIN))
|
if (r < 0 && errno == EAGAIN)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
pa_log_debug("read(): %s", r < 0 ? pa_cstrerror(errno) : "EOF");
|
pa_log_debug("read(): %s", r < 0 ? pa_cstrerror(errno) : "EOF");
|
||||||
|
|
|
||||||
|
|
@ -183,7 +183,7 @@ static int do_read(connection *c) {
|
||||||
|
|
||||||
if (r <= 0) {
|
if (r <= 0) {
|
||||||
|
|
||||||
if (r < 0 && (errno == EINTR || errno == EAGAIN))
|
if (r < 0 && errno == EAGAIN)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
pa_log_debug("read(): %s", r == 0 ? "EOF" : pa_cstrerror(errno));
|
pa_log_debug("read(): %s", r == 0 ? "EOF" : pa_cstrerror(errno));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue