mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 23:33:54 -06:00
Replace fcntl(O_NONBLOCK) with g_unix_set_fd_nonblocking()
Suggested-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
parent
d640b59eb3
commit
22e135fca3
6 changed files with 9 additions and 21 deletions
|
@ -226,24 +226,12 @@ void qemu_anon_ram_free(void *ptr, size_t size)
|
|||
|
||||
void qemu_set_block(int fd)
|
||||
{
|
||||
int f;
|
||||
f = fcntl(fd, F_GETFL);
|
||||
assert(f != -1);
|
||||
f = fcntl(fd, F_SETFL, f & ~O_NONBLOCK);
|
||||
assert(f != -1);
|
||||
g_unix_set_fd_nonblocking(fd, false, NULL);
|
||||
}
|
||||
|
||||
int qemu_try_set_nonblock(int fd)
|
||||
{
|
||||
int f;
|
||||
f = fcntl(fd, F_GETFL);
|
||||
if (f == -1) {
|
||||
return -errno;
|
||||
}
|
||||
if (fcntl(fd, F_SETFL, f | O_NONBLOCK) == -1) {
|
||||
return -errno;
|
||||
}
|
||||
return 0;
|
||||
return g_unix_set_fd_nonblocking(fd, true, NULL) ? 0 : -errno;
|
||||
}
|
||||
|
||||
void qemu_set_nonblock(int fd)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue