From: Fabio M. Di Nitto <fdinitto@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH] rgmanager: Fix segfault caused by unref race [RHEL6]
Date: Thu, 08 Sep 2011 08:42:25 +0200 [thread overview]
Message-ID: <4E6863D1.4060107@redhat.com> (raw)
In-Reply-To: <1315423361-31947-1-git-send-email-lhh@redhat.com>
ACK
On 9/7/2011 9:22 PM, Lon Hohberger wrote:
> Since we only ever open/close the connection in one
> place, there is no need to call ref/unref in the
> separate thread, since we wait for that thread to exit
> before calling DBus *close() and *unref() functions.
>
> It is possible for notification(s) to be sent during
> shutdown after shutting down the DBus connection.
> Since notifications are best-effort and having the
> DBus thread shut down is a normal condition, we should
> not log errors when this condition occurs.
>
> The rgm_dbus_notify() function was not locking around
> checks to the private db variable, which was incorrect.
>
> Resolves: rhbz#697446
>
> Signed-off-by: Lon Hohberger <lhh@redhat.com>
> Tested-by: Lon Hohberger <lhh@redhat.com>
> ---
> rgmanager/src/daemons/update-dbus.c | 16 +++++++++++-----
> 1 files changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/rgmanager/src/daemons/update-dbus.c b/rgmanager/src/daemons/update-dbus.c
> index bff1644..b45113c 100644
> --- a/rgmanager/src/daemons/update-dbus.c
> +++ b/rgmanager/src/daemons/update-dbus.c
> @@ -127,13 +127,11 @@ static void *
> _dbus_auto_flush(void *arg)
> {
> /* DBus connection functions are thread safe */
> - dbus_connection_ref(db);
> while (dbus_connection_read_write(db, 500)) {
> if (!th)
> break;
> }
>
> - dbus_connection_unref(db);
> th = 0;
> return NULL;
> }
> @@ -147,7 +145,7 @@ _rgm_dbus_notify(const char *svcname,
> const char *svclast)
> {
> DBusMessage *msg = NULL;
> - int ret = -1;
> + int ret = 0;
>
> pthread_mutex_lock(&mu);
>
> @@ -155,6 +153,9 @@ _rgm_dbus_notify(const char *svcname,
> goto out_unlock;
> }
>
> + /* Notifications are enabled */
> + ret = -1;
> +
> /* Check to ensure the connection is still valid. If it
> * isn't, clean up and shut down the dbus connection.
> *
> @@ -215,12 +216,17 @@ rgm_dbus_update(char *key, uint64_t view, void *data, uint32_t size)
>
> if (!rgm_dbus_notify)
> goto out_free;
> - if (!db)
> - goto out_free;
> if (view == 1)
> goto out_free;
> if (size != (sizeof(*st)))
> goto out_free;
> +
> + pthread_mutex_lock(&mu);
> + if (!db) {
> + pthread_mutex_unlock(&mu);
> + goto out_free;
> + }
> + pthread_mutex_unlock(&mu);
>
> st = (rg_state_t *)data;
> swab_rg_state_t(st);
prev parent reply other threads:[~2011-09-08 6:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-07 19:22 [Cluster-devel] [PATCH] rgmanager: Fix segfault caused by unref race [RHEL6] Lon Hohberger
2011-09-08 6:42 ` Fabio M. Di Nitto [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E6863D1.4060107@redhat.com \
--to=fdinitto@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.