Commit 24567077 authored by Sergey Ulanov's avatar Sergey Ulanov

Use O_NONBLOCK when opening audio pipe on linux.

By default open() blocks when opening a fifo until the writer also
opens the fifo. In the past AudioPipeReader was using O_NONBLOCK
when opening the pipe for reading, but that was changed in r277315,
and may result in host hanging if pulseaudio doesn't open the pipe
for some reason. Fixed AudioPipeReader to always pass O_NONBLOCK
to open().

BUG=420090
R=lambroslambrou@chromium.org

Review URL: https://codereview.chromium.org/820123002

Cr-Commit-Position: refs/heads/master@{#309592}
parent fc38eeb3
...@@ -107,10 +107,8 @@ void AudioPipeReader::OnDirectoryChanged(const base::FilePath& path, ...@@ -107,10 +107,8 @@ void AudioPipeReader::OnDirectoryChanged(const base::FilePath& path,
void AudioPipeReader::TryOpenPipe() { void AudioPipeReader::TryOpenPipe() {
DCHECK(task_runner_->BelongsToCurrentThread()); DCHECK(task_runner_->BelongsToCurrentThread());
base::File new_pipe; base::File new_pipe(
new_pipe.Initialize( HANDLE_EINTR(open(pipe_path_.value().c_str(), O_RDONLY | O_NONBLOCK)));
pipe_path_,
base::File::FLAG_OPEN | base::File::FLAG_READ | base::File::FLAG_ASYNC);
// If both |pipe_| and |new_pipe| are valid then compare inodes for the two // If both |pipe_| and |new_pipe| are valid then compare inodes for the two
// file descriptors. Don't need to do anything if inode hasn't changed. // file descriptors. Don't need to do anything if inode hasn't changed.
...@@ -130,13 +128,6 @@ void AudioPipeReader::TryOpenPipe() { ...@@ -130,13 +128,6 @@ void AudioPipeReader::TryOpenPipe() {
pipe_ = new_pipe.Pass(); pipe_ = new_pipe.Pass();
if (pipe_.IsValid()) { if (pipe_.IsValid()) {
// Set O_NONBLOCK flag.
if (HANDLE_EINTR(fcntl(pipe_.GetPlatformFile(), F_SETFL, O_NONBLOCK)) < 0) {
PLOG(ERROR) << "fcntl";
pipe_.Close();
return;
}
// Set buffer size for the pipe. // Set buffer size for the pipe.
if (HANDLE_EINTR(fcntl( if (HANDLE_EINTR(fcntl(
pipe_.GetPlatformFile(), F_SETPIPE_SZ, kPipeBufferSizeBytes)) < 0) { pipe_.GetPlatformFile(), F_SETPIPE_SZ, kPipeBufferSizeBytes)) < 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment