]> granicus.if.org Git - apache/commitdiff
Move variable declartions to the top of functions for c89'ness.
authorPaul Querna <pquerna@apache.org>
Mon, 1 Dec 2008 03:10:49 +0000 (03:10 +0000)
committerPaul Querna <pquerna@apache.org>
Mon, 1 Dec 2008 03:10:49 +0000 (03:10 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@721956 13f79535-47bb-0310-9956-ffa450edef68

modules/cluster/mod_heartbeat.c
modules/cluster/mod_heartmonitor.c

index 0d612c7adde7d8e667c37064423d2eff549c7468..77f08be824e17fc75f1f5184b00aa5dea4c48ea6 100644 (file)
@@ -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);
 
index bf514c6952e00ed85d94bdc4b1dce754d5187fca..9d642b6c2fbc35a127b11e5e8ad058462681fb82 100644 (file)
@@ -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);