mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-30 15:30:11 +01:00
shared: fix returning EAGAIN from nm_utils_fd_read()
We cannot just swallow EAGAIN and pretend that not bytes were read. read() returning zero means end of file. The caller needs to distinguish between end of file and EAGAIN.
This commit is contained in:
parent
8c637e693a
commit
2384033b05
1 changed files with 6 additions and 8 deletions
|
|
@ -434,13 +434,11 @@ nm_utils_fd_read (int fd, GString *out_string)
|
|||
g_string_set_size (out_string, start_len + 1024);
|
||||
|
||||
n_read = read (fd, &out_string->str[start_len], 1024);
|
||||
if (n_read < 0) {
|
||||
if (errno != EAGAIN) {
|
||||
return -NM_ERRNO_NATIVE (errno);
|
||||
}
|
||||
n_read = 0;
|
||||
} else {
|
||||
g_string_set_size (out_string, start_len + n_read);
|
||||
}
|
||||
if (n_read < 0)
|
||||
return -NM_ERRNO_NATIVE (errno);
|
||||
|
||||
if (n_read > 0)
|
||||
g_string_set_size (out_string, start_len + (gsize) n_read);
|
||||
|
||||
return n_read;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue