From b9fb9b206e8eed69475bfdeec774731a056cf946 Mon Sep 17 00:00:00 2001 From: Patrick Caulfield Date: Fri, 7 Jan 2005 14:22:49 +0000 Subject: [PATCH] Fix off-by-one error in cluster_locking that could case read hangs. --- WHATS_NEW | 1 + daemons/clvmd/clvmd.c | 1 + lib/locking/cluster_locking.c | 5 ++--- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index 144e39060..3b029f24f 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -5,6 +5,7 @@ Version 2.00.33 - gulm clvmd now doesn't ignore the first node in cluster.conf Improve clvmd failure message if it's already running. Allow user to kill clvmd during initialisation. + Fix off-by-one error in cluster_locking that could cause read hangs. Version 2.00.32 - 22nd December 2004 ==================================== diff --git a/daemons/clvmd/clvmd.c b/daemons/clvmd/clvmd.c index 6346fdf29..9a86f6f11 100644 --- a/daemons/clvmd/clvmd.c +++ b/daemons/clvmd/clvmd.c @@ -1313,6 +1313,7 @@ static void *pre_and_post_thread(void *arg) DEBUGLOG("Got post command condition...\n"); + status = 0; do_post_command(client); write(pipe_fd, &status, sizeof(int)); diff --git a/lib/locking/cluster_locking.c b/lib/locking/cluster_locking.c index d9cab2d7e..4faa73f06 100644 --- a/lib/locking/cluster_locking.c +++ b/lib/locking/cluster_locking.c @@ -139,8 +139,7 @@ static int _send_request(char *inbuf, int inlen, char **retbuf) /* Read the returned values */ off = 1; /* we've already read the first byte */ - - while (off < outheader->arglen && len > 0) { + while (off <= outheader->arglen && len > 0) { len = read(_clvmd_sock, outheader->args + off, buflen - off - offsetof(struct clvm_header, args)); if (len > 0) @@ -150,7 +149,7 @@ static int _send_request(char *inbuf, int inlen, char **retbuf) /* Was it an error ? */ if (outheader->status < 0) { errno = -outheader->status; - log_error("cluster send request failed: %s", strerror(errno)); + log_error("cluster request failed: %s", strerror(errno)); return 0; } -- 2.43.5