From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7497 invoked by alias); 20 Feb 2009 15:29:21 -0000 Received: (qmail 7491 invoked by alias); 20 Feb 2009 15:29:21 -0000 X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_43,SPF_HELO_PASS X-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_43,SPF_HELO_PASS X-Spam-Check-By: sourceware.org X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bastion.fedora.phx.redhat.com Subject: cluster: master - qdisk: Honor CMAN_TRY_SHUTDOWN To: cluster-cvs-relay@redhat.com X-Project: Cluster Project X-Git-Module: cluster.git X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: dc61e91070a63abb6395664e59f8ecd9dfd231f0 X-Git-Newrev: 3cc0a7367fd5048e5e1deb3d0bd776896c22d170 From: Lon Hohberger Message-Id: <20090220152852.A3D2D120153@lists.fedorahosted.org> Date: Fri, 20 Feb 2009 15:29:00 -0000 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 Mailing-List: contact cluster-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cluster-cvs-owner@sourceware.org X-SW-Source: 2009-q1/txt/msg00537.txt.bz2 Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=3cc0a7367fd5048e5e1deb3d0bd776896c22d170 Commit: 3cc0a7367fd5048e5e1deb3d0bd776896c22d170 Parent: dc61e91070a63abb6395664e59f8ecd9dfd231f0 Author: Lon Hohberger AuthorDate: Fri Feb 20 10:06:55 2009 -0500 Committer: Lon Hohberger CommitterDate: Fri Feb 20 10:28:35 2009 -0500 qdisk: Honor CMAN_TRY_SHUTDOWN Qdiskd was not correctly handling this event from CMAN. Ordinarily, this was not a problem. However, when a TRY_SHUTDOWN event was received during qdiskd initialization, qdiskd would ignore it. CMAN would then not properly exit. Signed-off-by: Lon Hohberger --- cman/qdisk/main.c | 29 ++++++++++++++++++++++++----- 1 files changed, 24 insertions(+), 5 deletions(-) diff --git a/cman/qdisk/main.c b/cman/qdisk/main.c index 6a64f0a..0478c3d 100644 --- a/cman/qdisk/main.c +++ b/cman/qdisk/main.c @@ -52,7 +52,7 @@ inline int get_time(struct timeval *tv, int use_uptime); inline void _diff_tv(struct timeval *dest, struct timeval *start, struct timeval *end); -static int _running = 1, _reconfig = 0; +static int _running = 1, _reconfig = 0, _cman_shutdown = 0; static int _debug = 0, _foreground = 0; /* */ @@ -62,6 +62,7 @@ static int _debug = 0, _foreground = 0; static void update_local_status(qd_ctx *ctx, node_info_t *ni, int max, int score, int score_req, int score_max); static int get_config_data(qd_ctx *ctx, struct h_data *h, int maxh, int *cfh); +static int cman_wait(cman_handle_t ch, struct timeval *_tv); static void @@ -467,6 +468,7 @@ static int quorum_init(qd_ctx *ctx, node_info_t *ni, int max, struct h_data *h, int maxh) { int x = 0, score, maxscore, score_req = 0; + struct timeval tv; logt_print(LOG_INFO, "Quorum Daemon Initializing\n"); @@ -517,7 +519,13 @@ quorum_init(qd_ctx *ctx, node_info_t *ni, int max, struct h_data *h, int maxh) score_req = (maxscore/2 + 1); update_local_status(ctx, ni, max, score, score_req, maxscore); - sleep(ctx->qc_interval); + tv.tv_sec = ctx->qc_interval; + tv.tv_usec = 0; + cman_wait(ctx->qc_cman_user, &tv); + } + + if (!_running) { + return 1; } get_my_score(&score, &maxscore); @@ -843,6 +851,7 @@ process_cman_event(cman_handle_t handle, void *private, int reason, int arg) break; case CMAN_REASON_TRY_SHUTDOWN: _running = 0; + _cman_shutdown = 1; break; case CMAN_REASON_CONFIG_UPDATE: get_config_data(ctx, NULL, 0, NULL); @@ -1712,10 +1721,17 @@ main(int argc, char **argv) } } - if (quorum_init(&ctx, ni, MAX_NODES_DISK, h, cfh) < 0) { + ret = quorum_init(&ctx, ni, MAX_NODES_DISK, h, cfh); + if (ret < 0) { logt_print(LOG_CRIT, "Initialization failed\n"); check_stop_cman(&ctx); goto out; + } else if (ret > 0) { + /* ret > 0 means we received a shutdown during initialization */ + /* Write our 'clean down' state to disk and get out of here */ + logt_print(LOG_INFO, "Shutdown request received during initialization\n"); + quorum_logout(&ctx); + goto out; } ret = 0; @@ -1744,10 +1760,13 @@ main(int argc, char **argv) cman_unregister_quorum_device(ctx.qc_cman_admin); quorum_logout(&ctx); - /* free cman handle to avoid leak in cman */ out: + /* free cman handle to avoid leak in cman */ cman_finish(ch_admin); - cman_finish(ch_user); + if (_cman_shutdown) { + cman_replyto_shutdown(ch_user, 1); + cman_finish(ch_user); + } qd_destroy(&ctx); logt_exit(); return ret;