]> xenbits.xensource.com Git - xen.git/commitdiff
tools/libxs: Track whether we're using a socket or file
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 28 Jun 2024 18:40:27 +0000 (19:40 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 23 Jul 2024 14:11:27 +0000 (15:11 +0100)
It will determine whether to use writev() or sendmsg().

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>
tools/libs/store/xs.c

index 60f83ff19818a8b1c967e0a068d016144de18d9e..3b3ee3d780cf88ba9dbde8c9ea26bc6c2adb6e87 100644 (file)
@@ -65,6 +65,9 @@ struct xs_stored_msg {
 struct xs_handle {
        /* Communications channel to xenstore daemon. */
        int fd;
+
+       bool is_socket; /* is @fd a file or socket? */
+
        Xentoolcore__Active_Handle tc_ah; /* for restrict */
 
        /*
@@ -297,7 +300,9 @@ static struct xs_handle *get_handle(const char *connect_to)
        if (stat(connect_to, &buf) != 0)
                goto err;
 
-       if (S_ISSOCK(buf.st_mode))
+       h->is_socket = S_ISSOCK(buf.st_mode);
+
+       if (h->is_socket)
                h->fd = get_socket(connect_to);
        else
                h->fd = get_dev(connect_to);