From ef70cebf29faffb3c4e36524e80b4b4a12494454 Mon Sep 17 00:00:00 2001 From: Paul Querna Date: Mon, 1 Dec 2008 03:10:49 +0000 Subject: [PATCH] Move variable declartions to the top of functions for c89'ness. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@721956 13f79535-47bb-0310-9956-ffa450edef68 --- modules/cluster/mod_heartbeat.c | 16 +++++++++------- modules/cluster/mod_heartmonitor.c | 6 ++++-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/modules/cluster/mod_heartbeat.c b/modules/cluster/mod_heartbeat.c index 0d612c7add..77f08be824 100644 --- a/modules/cluster/mod_heartbeat.c +++ b/modules/cluster/mod_heartbeat.c @@ -49,6 +49,9 @@ static const char *msg_format = "v=%u&ready=%u&busy=%u"; static int hb_monitor(hb_ctx_t *ctx, apr_pool_t *p) { + apr_size_t len; + apr_socket_t *sock = NULL; + char buf[256]; int i, j; apr_uint32_t ready = 0; apr_uint32_t busy = 0; @@ -74,11 +77,8 @@ static int hb_monitor(hb_ctx_t *ctx, apr_pool_t *p) } } - char buf[256]; - apr_size_t len = - apr_snprintf(buf, sizeof(buf), msg_format, MSG_VERSION, ready, busy); + len = apr_snprintf(buf, sizeof(buf), msg_format, MSG_VERSION, ready, busy); - apr_socket_t *sock = NULL; do { apr_status_t rv; rv = apr_socket_create(&sock, ctx->mcast_addr->family, @@ -136,6 +136,8 @@ static void *hb_worker(apr_thread_t *thd, void *data) while (ctx->keep_running) { int mpm_state = 0; + apr_pool_t *tpool; + rv = ap_mpm_query(AP_MPMQ_MPM_STATE, &mpm_state); if (rv != APR_SUCCESS) { @@ -147,7 +149,6 @@ static void *hb_worker(apr_thread_t *thd, void *data) break; } - apr_pool_t *tpool; apr_pool_create(&tpool, pool); apr_pool_tag(tpool, "heartbeat_worker_temp"); hb_monitor(ctx, tpool); @@ -276,6 +277,8 @@ static const char *cmd_hb_address(cmd_parms *cmd, void *dconf, const char *addr) { apr_status_t rv; + const char *tmpdir = NULL; + char *path; char *host_str; char *scope_id; apr_port_t port = 0; @@ -312,13 +315,12 @@ static const char *cmd_hb_address(cmd_parms *cmd, return "HeartbeatAddress: apr_sockaddr_info_get failed."; } - const char *tmpdir = NULL; rv = apr_temp_dir_get(&tmpdir, p); if (rv) { return "HeartbeatAddress: unable to find temp directory."; } - char *path = apr_pstrcat(p, tmpdir, "/hb-tmp.XXXXXX", NULL); + path = apr_pstrcat(p, tmpdir, "/hb-tmp.XXXXXX", NULL); rv = apr_file_mktemp(&ctx->lockf, path, 0, p); diff --git a/modules/cluster/mod_heartmonitor.c b/modules/cluster/mod_heartmonitor.c index bf514c6952..9d642b6c2f 100644 --- a/modules/cluster/mod_heartmonitor.c +++ b/modules/cluster/mod_heartmonitor.c @@ -279,6 +279,7 @@ static apr_status_t hm_recv(hm_ctx_t *ctx, apr_pool_t *p) static void *hm_worker(apr_thread_t *thd, void *data) { + apr_time_t last; hm_ctx_t *ctx = (hm_ctx_t *) data; apr_status_t rv; @@ -307,15 +308,16 @@ static void *hm_worker(apr_thread_t *thd, void *data) } - apr_time_t last = apr_time_now(); + last = apr_time_now(); while (ctx->keep_running) { int n; apr_pool_t *p; apr_pollfd_t pfd; apr_interval_time_t timeout; + apr_time_t now; apr_pool_create(&p, ctx->p); - apr_time_t now = apr_time_now(); + now = apr_time_now(); if (apr_time_sec((now - last)) > 5) { hm_update_stats(ctx, p); -- 2.40.0