mirror of
https://github.com/alsa-project/alsa-utils
synced 2025-01-03 13:29:43 +01:00
axfer: minor code arrangement for container module in a point of nonblocking flag
In internal container module, any file descriptor is expected as non-blocking mode. Current implementation distinguish the case of standard input and output from the case to open actual file since O_NONBLOCK is used for the latter case. However, in both cases, fcntl(2) is available to set non-blocking mode to the file descriptor. This commit arranges to use fcntl(2) for both cases. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
eefc2c61cf
commit
d81a0f93bc
1 changed files with 10 additions and 9 deletions
|
@ -176,16 +176,17 @@ int container_parser_init(struct container_context *cntr,
|
||||||
"should be referred instead.\n");
|
"should be referred instead.\n");
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
err = set_nonblock_flag(cntr->fd);
|
|
||||||
if (err < 0)
|
|
||||||
return err;
|
|
||||||
cntr->stdio = true;
|
cntr->stdio = true;
|
||||||
} else {
|
} else {
|
||||||
cntr->fd = open(path, O_RDONLY | O_NONBLOCK);
|
cntr->fd = open(path, O_RDONLY);
|
||||||
if (cntr->fd < 0)
|
if (cntr->fd < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = set_nonblock_flag(cntr->fd);
|
||||||
|
if (err < 0)
|
||||||
|
return err;
|
||||||
|
|
||||||
// 4 bytes are enough to detect supported containers.
|
// 4 bytes are enough to detect supported containers.
|
||||||
err = container_recursive_read(cntr, cntr->magic, sizeof(cntr->magic));
|
err = container_recursive_read(cntr, cntr->magic, sizeof(cntr->magic));
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
|
@ -260,17 +261,17 @@ int container_builder_init(struct container_context *cntr,
|
||||||
"should be referred instead.\n");
|
"should be referred instead.\n");
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
err = set_nonblock_flag(cntr->fd);
|
|
||||||
if (err < 0)
|
|
||||||
return err;
|
|
||||||
cntr->stdio = true;
|
cntr->stdio = true;
|
||||||
} else {
|
} else {
|
||||||
cntr->fd = open(path, O_RDWR | O_NONBLOCK | O_CREAT | O_TRUNC,
|
cntr->fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0644);
|
||||||
0644);
|
|
||||||
if (cntr->fd < 0)
|
if (cntr->fd < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = set_nonblock_flag(cntr->fd);
|
||||||
|
if (err < 0)
|
||||||
|
return err;
|
||||||
|
|
||||||
builder = builders[format];
|
builder = builders[format];
|
||||||
|
|
||||||
// Allocate private data for the builder.
|
// Allocate private data for the builder.
|
||||||
|
|
Loading…
Reference in a new issue