This is the mail archive of the
cluster-cvs@sourceware.org
mailing list for the cluster.
master - dlm/fence/gfs: fix daemon spinning 100% due to memorycorruption
- From: "Fabio M. Di Nitto" <fabbione at fedoraproject dot org>
- To: cluster-cvs-relay at redhat dot com
- Date: Thu, 25 Sep 2008 04:26:00 +0000 (UTC)
- Subject: master - dlm/fence/gfs: fix daemon spinning 100% due to memorycorruption
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=31f216b4b0a1b5ebda5fc992363b6be6a4c9ab22
Commit: 31f216b4b0a1b5ebda5fc992363b6be6a4c9ab22
Parent: 51610f70d7bc79c3e35a7f9b6eded687db47d89e
Author: Fabio M. Di Nitto <fdinitto@redhat.com>
AuthorDate: Thu Sep 25 06:18:15 2008 +0200
Committer: Fabio M. Di Nitto <fdinitto@redhat.com>
CommitterDate: Thu Sep 25 06:18:15 2008 +0200
dlm/fence/gfs: fix daemon spinning 100% due to memory corruption
This is more a workaround than a real fix.
When building with -O0, arg list to pthread_create is somehow corrupted
(I suspect a gcc bug here as the problem doesn't show with any other -O
levels), and data passed down to process_query are invalid.
Stop passing arguments via pthread_create.
Add simple sanity check and fallback in process_queries on accept() call
that was the main cause of the spin.
Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
---
fence/fenced/main.c | 21 +++++++++++----------
group/dlm_controld/main.c | 21 +++++++++++----------
group/gfs_controld/main.c | 21 +++++++++++----------
3 files changed, 33 insertions(+), 30 deletions(-)
diff --git a/fence/fenced/main.c b/fence/fenced/main.c
index 74835c7..31115a2 100644
--- a/fence/fenced/main.c
+++ b/fence/fenced/main.c
@@ -551,11 +551,18 @@ void query_unlock(void)
static void *process_queries(void *arg)
{
struct fenced_header h;
- int s = *((int *)arg);
- int f, rv;
+ int f, rv, s;
+
+ rv = setup_listener(FENCED_QUERY_SOCK_PATH);
+ if (rv < 0)
+ exit (-1);
+
+ s = rv;
for (;;) {
f = accept(s, NULL, NULL);
+ if (f < 0)
+ exit (-1);
rv = do_read(f, &h, sizeof(h));
if (rv < 0) {
@@ -597,19 +604,13 @@ static void *process_queries(void *arg)
static int setup_queries(void)
{
- int rv, s;
-
- rv = setup_listener(FENCED_QUERY_SOCK_PATH);
- if (rv < 0)
- return rv;
- s = rv;
+ int rv;
pthread_mutex_init(&query_mutex, NULL);
- rv = pthread_create(&query_thread, NULL, process_queries, &s);
+ rv = pthread_create(&query_thread, NULL, process_queries, NULL);
if (rv < 0) {
log_error("can't create query thread");
- close(s);
return rv;
}
return 0;
diff --git a/group/dlm_controld/main.c b/group/dlm_controld/main.c
index a4c38b9..57feb0e 100644
--- a/group/dlm_controld/main.c
+++ b/group/dlm_controld/main.c
@@ -771,11 +771,18 @@ void query_unlock(void)
static void *process_queries(void *arg)
{
struct dlmc_header h;
- int s = *((int *)arg);
- int f, rv;
+ int s, f, rv;
+
+ rv = setup_listener(DLMC_QUERY_SOCK_PATH);
+ if (rv < 0)
+ exit (-1);
+
+ s = rv;
for (;;) {
f = accept(s, NULL, NULL);
+ if (f < 0)
+ exit (-1);
rv = do_read(f, &h, sizeof(h));
if (rv < 0) {
@@ -823,19 +830,13 @@ static void *process_queries(void *arg)
static int setup_queries(void)
{
- int rv, s;
-
- rv = setup_listener(DLMC_QUERY_SOCK_PATH);
- if (rv < 0)
- return rv;
- s = rv;
+ int rv;
pthread_mutex_init(&query_mutex, NULL);
- rv = pthread_create(&query_thread, NULL, process_queries, &s);
+ rv = pthread_create(&query_thread, NULL, process_queries, NULL);
if (rv < 0) {
log_error("can't create query thread");
- close(s);
return rv;
}
return 0;
diff --git a/group/gfs_controld/main.c b/group/gfs_controld/main.c
index 4d34657..94d370d 100644
--- a/group/gfs_controld/main.c
+++ b/group/gfs_controld/main.c
@@ -992,11 +992,18 @@ void query_unlock(void)
static void *process_queries(void *arg)
{
struct gfsc_header h;
- int s = *((int *)arg);
- int f, rv;
+ int f, rv, s;
+
+ rv = setup_listener(GFSC_QUERY_SOCK_PATH);
+ if (rv < 0)
+ exit (-1);
+
+ s = rv;
for (;;) {
f = accept(s, NULL, NULL);
+ if (f < 0)
+ exit (-1);
rv = do_read(f, &h, sizeof(h));
if (rv < 0) {
@@ -1044,19 +1051,13 @@ static void *process_queries(void *arg)
static int setup_queries(void)
{
- int rv, s;
-
- rv = setup_listener(GFSC_QUERY_SOCK_PATH);
- if (rv < 0)
- return rv;
- s = rv;
+ int rv;
pthread_mutex_init(&query_mutex, NULL);
- rv = pthread_create(&query_thread, NULL, process_queries, &s);
+ rv = pthread_create(&query_thread, NULL, process_queries, NULL);
if (rv < 0) {
log_error("can't create query thread");
- close(s);
return rv;
}
return 0;