From: Andrew Cooper Date: Mon, 25 Nov 2024 10:53:35 +0000 (+0100) Subject: tools/libxs: Track whether we're using a socket or file X-Git-Tag: RELEASE-4.19.1~26 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=c991b585c47177bf96afc1aa55fb8cb2a7dd20c5;p=xen.git tools/libxs: Track whether we're using a socket or file It will determine whether to use writev() or sendmsg(). Signed-off-by: Andrew Cooper Reviewed-by: Juergen Gross Reviewed-by: Jason Andryuk master commit: 046efe529e82b8b999d8453d4ea49cb817c3f9b5 master date: 2024-07-23 15:11:27 +0100 --- diff --git a/tools/libs/store/xs.c b/tools/libs/store/xs.c index 4d24bf7b0f..ae1f80d5e6 100644 --- a/tools/libs/store/xs.c +++ b/tools/libs/store/xs.c @@ -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 */ /* @@ -140,6 +143,7 @@ static void *read_thread(void *arg); struct xs_handle { int fd; + bool is_socket; /* is @fd a file or socket? */ Xentoolcore__Active_Handle tc_ah; /* for restrict */ XEN_TAILQ_HEAD(, struct xs_stored_msg) reply_list; XEN_TAILQ_HEAD(, struct xs_stored_msg) watch_list; @@ -300,7 +304,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);