On Wed, Feb 15, 2023 at 03:11:47PM +0100, Laszlo Ersek wrote:
A comment currently states that "*the* socket must be set to
non-blocking
only in the parent" (emphasis mine). This is a thinko: it implies that we
have just one file descriptor, and that the underlying file description
(which is manipulated by fcntl()'s F_GETFL and F_SETFL) is shared by the
parent and the child processes. That's not the case: we have *two* sockets
here (a socket pair), one of which is used by the parent exclusively, and
the other is used by the child exclusively.
Clarify the comment: say that we set the parent-side end of the socket
pair to non-blocking.
This clarification will play a role in a subsequent patch.
Signed-off-by: Laszlo Ersek <lersek(a)redhat.com>
---
Notes:
context:-U5
generator/states-connect.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/generator/states-connect.c b/generator/states-connect.c
index 8a286e6630ff..95a96b9114c6 100644
--- a/generator/states-connect.c
+++ b/generator/states-connect.c
@@ -281,11 +281,11 @@ CONNECT_COMMAND.START:
/* Parent. */
close (sv[1]);
h->pid = pid;
- /* The socket must be set to non-blocking only in the parent,
+ /* Only the parent-side end of the socket pair must be set to non-blocking,
* because the child may not be expecting a non-blocking socket.
*/
flags = fcntl (sv[0], F_GETFL, 0);
if (flags == -1 ||
fcntl (sv[0], F_SETFL, flags|O_NONBLOCK) == -1) {
Reviewed-by: Richard W.M. Jones <rjones(a)redhat.com>
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
virt-top is 'top' for virtual machines. Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top