mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
Use gnulib set_nonblocking_flag function instead of fcntl.
The previous code: fcntl (fd, F_SETFL, O_NONBLOCK) was technically incorrect, because it would have reset any other flags on the file descriptor. Thanks: Eric Blake
This commit is contained in:
@@ -75,6 +75,7 @@ mkdtemp
|
||||
mkstemps
|
||||
netdb
|
||||
netinet_in
|
||||
nonblocking
|
||||
openat
|
||||
perror
|
||||
pipe2
|
||||
|
||||
@@ -29,6 +29,8 @@
|
||||
#include <sys/inotify.h>
|
||||
#endif
|
||||
|
||||
#include "nonblocking.h"
|
||||
|
||||
#include "guestfs_protocol.h"
|
||||
#include "daemon.h"
|
||||
#include "actions.h"
|
||||
@@ -112,8 +114,8 @@ do_inotify_init (int max_events)
|
||||
reply_with_perror ("inotify_init");
|
||||
return -1;
|
||||
}
|
||||
if (fcntl (inotify_fd, F_SETFL, O_NONBLOCK) == -1) {
|
||||
reply_with_perror ("fcntl: O_NONBLOCK");
|
||||
if (set_nonblocking_flag (inotify_fd, 1) == -1) {
|
||||
reply_with_perror ("set_nonblocking_flag");
|
||||
close (inotify_fd);
|
||||
inotify_fd = -1;
|
||||
return -1;
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <libintl.h>
|
||||
|
||||
#include "ignore-value.h"
|
||||
#include "nonblocking.h"
|
||||
|
||||
#include "guestfs.h"
|
||||
#include "guestfs-internal.h"
|
||||
@@ -129,8 +130,8 @@ accept_connection (guestfs_h *g, struct connection *connv)
|
||||
conn->daemon_sock = sock;
|
||||
|
||||
/* Make sure the new socket is non-blocking. */
|
||||
if (fcntl (conn->daemon_sock, F_SETFL, O_NONBLOCK) == -1) {
|
||||
perrorf (g, "accept_connection: fcntl");
|
||||
if (set_nonblocking_flag (conn->daemon_sock, 1) == -1) {
|
||||
perrorf (g, "accept_connection: set_nonblocking_flag");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -438,14 +439,14 @@ guestfs_int_new_conn_socket_listening (guestfs_h *g,
|
||||
|
||||
assert (daemon_accept_sock >= 0);
|
||||
|
||||
if (fcntl (daemon_accept_sock, F_SETFL, O_NONBLOCK) == -1) {
|
||||
perrorf (g, "new_conn_socket_listening: fcntl");
|
||||
if (set_nonblocking_flag (daemon_accept_sock, 1) == -1) {
|
||||
perrorf (g, "new_conn_socket_listening: set_nonblocking_flag");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (console_sock >= 0) {
|
||||
if (fcntl (console_sock, F_SETFL, O_NONBLOCK) == -1) {
|
||||
perrorf (g, "new_conn_socket_listening: fcntl");
|
||||
if (set_nonblocking_flag (console_sock, 1) == -1) {
|
||||
perrorf (g, "new_conn_socket_listening: set_nonblocking_flag");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -478,14 +479,14 @@ guestfs_int_new_conn_socket_connected (guestfs_h *g,
|
||||
|
||||
assert (daemon_sock >= 0);
|
||||
|
||||
if (fcntl (daemon_sock, F_SETFL, O_NONBLOCK) == -1) {
|
||||
perrorf (g, "new_conn_socket_connected: fcntl");
|
||||
if (set_nonblocking_flag (daemon_sock, 1) == -1) {
|
||||
perrorf (g, "new_conn_socket_connected: set_nonblocking_flag");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (console_sock >= 0) {
|
||||
if (fcntl (console_sock, F_SETFL, O_NONBLOCK) == -1) {
|
||||
perrorf (g, "new_conn_socket_connected: fcntl");
|
||||
if (set_nonblocking_flag (console_sock, 1) == -1) {
|
||||
perrorf (g, "new_conn_socket_connected: set_nonblocking_flag");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
9
m4/.gitignore
vendored
9
m4/.gitignore
vendored
@@ -41,6 +41,7 @@
|
||||
/exponentd.m4
|
||||
/extensions.m4
|
||||
/extern-inline.m4
|
||||
/fatal-signal.m4
|
||||
/fchdir.m4
|
||||
/fclose.m4
|
||||
/fcntl_h.m4
|
||||
@@ -156,6 +157,7 @@
|
||||
/netdb_h.m4
|
||||
/netinet_in_h.m4
|
||||
/nocrash.m4
|
||||
/nonblocking.m4
|
||||
/off_t.m4
|
||||
/onceonly.m4
|
||||
/openat.m4
|
||||
@@ -165,6 +167,7 @@
|
||||
/perror.m4
|
||||
/pipe2.m4
|
||||
/pipe.m4
|
||||
/posix_spawn.m4
|
||||
/pread.m4
|
||||
/printf.m4
|
||||
/priv-set.m4
|
||||
@@ -186,12 +189,14 @@
|
||||
/safe-read.m4
|
||||
/safe-write.m4
|
||||
/save-cwd.m4
|
||||
/sched_h.m4
|
||||
/secure_getenv.m4
|
||||
/select.m4
|
||||
/servent.m4
|
||||
/setenv.m4
|
||||
/setlocale.m4
|
||||
/sigaction.m4
|
||||
/sig_atomic_t.m4
|
||||
/signalblocking.m4
|
||||
/signal_h.m4
|
||||
/signed.m4
|
||||
@@ -202,6 +207,7 @@
|
||||
/sockets.m4
|
||||
/socklen.m4
|
||||
/sockpfaf.m4
|
||||
/spawn_h.m4
|
||||
/ssize_t.m4
|
||||
/stat.m4
|
||||
/stat-time.m4
|
||||
@@ -256,6 +262,9 @@
|
||||
/utimes.m4
|
||||
/vasnprintf.m4
|
||||
/vasprintf.m4
|
||||
/vsnprintf.m4
|
||||
/waitpid.m4
|
||||
/wait-process.m4
|
||||
/warnings.m4
|
||||
/warn-on-use.m4
|
||||
/wchar_h.m4
|
||||
|
||||
Reference in New Issue
Block a user