public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
* master - dlm/fence/gfs: fix daemon spinning 100% due to memory corruption
@ 2008-09-25 4:52 Fabio M. Di Nitto
0 siblings, 0 replies; only message in thread
From: Fabio M. Di Nitto @ 2008-09-25 4:52 UTC (permalink / raw)
To: cluster-cvs-relay
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;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-09-25 4:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-25 4:52 master - dlm/fence/gfs: fix daemon spinning 100% due to memory corruption Fabio M. Di Nitto
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).