This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch master in repository sanlock.
commit 3a646ecdb7ec484be2496903f66735957c05dd79 Author: David Teigland teigland@redhat.com AuthorDate: Wed Mar 19 15:05:34 2025 -0500
sanlock: fix acquire2 owner data recv --- src/client.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/src/client.c b/src/client.c index e2a85a5..0428b53 100644 --- a/src/client.c +++ b/src/client.c @@ -167,24 +167,19 @@ retry: return (int)h.data; }
-static int recv_header(int fd, uint32_t *h_data) +static int recv_header(int fd, struct sm_header *h) { - struct sm_header h; ssize_t rv;
- memset(&h, 0, sizeof(h)); retry: - rv = recv(fd, &h, sizeof(h), MSG_WAITALL); + rv = recv(fd, h, sizeof(struct sm_header), MSG_WAITALL); if (rv == -1 && errno == EINTR) goto retry; if (rv < 0) return -errno; - if (rv != sizeof(h)) + if (rv != sizeof(struct sm_header)) return -1;
- if (h_data) - *h_data = h.data; - return 0; }
@@ -1142,11 +1137,11 @@ int sanlock_acquire2(int sock, int pid, uint32_t flags, struct sanlk_host *owner_host, char **owner_name) { + struct sm_header h = { 0 }; struct sanlk_options opt = {0}; char namebuf[SANLK_NAME_LEN+1] = {0}; char *nameret; - uint32_t cmd_result = 0; - int rv, fd, data2; + int result, rv, fd, data2; int datalen;
if (res->num_disks != 1) @@ -1196,10 +1191,15 @@ int sanlock_acquire2(int sock, int pid, uint32_t flags, goto out; }
- rv = recv_header(fd, &cmd_result); + rv = recv_header(fd, &h); if (rv < 0) goto out;
+ result = (int)h.data; + + if (h.length == sizeof(struct sm_header)) + goto no_owner; + rv = recv_data(fd, owner_host, sizeof(struct sanlk_host), MSG_WAITALL); if (rv < 0) goto out; @@ -1217,8 +1217,8 @@ int sanlock_acquire2(int sock, int pid, uint32_t flags, } }
- rv = (int)cmd_result; - + no_owner: + rv = result; out: if (sock == -1) close(fd);
sanlock-devel@lists.fedorahosted.org