]> granicus.if.org Git - apache/commitdiff
Improve ability to compile on C90 Compilers.
authorPaul Querna <pquerna@apache.org>
Wed, 29 Oct 2008 07:56:19 +0000 (07:56 +0000)
committerPaul Querna <pquerna@apache.org>
Wed, 29 Oct 2008 07:56:19 +0000 (07:56 +0000)
* Move all variable declartions to the top of their blocks.
* Remove traiing comma on enum
* Only use C90 style comments.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@708813 13f79535-47bb-0310-9956-ffa450edef68

server/mpm/simple/simple_api.c
server/mpm/simple/simple_children.c
server/mpm/simple/simple_event.c
server/mpm/simple/simple_io.c
server/mpm/simple/simple_run.c
server/mpm/simple/simple_types.h

index fdde726873aac13e9e1fe1e985c34c8620c8446d..3053ad2920b550f73cf3b85837331ebb5d657b35 100644 (file)
@@ -121,9 +121,11 @@ simple_open_logs(apr_pool_t *p,
                  apr_pool_t *ptemp,
                  server_rec *s)
 {
-  ap_server_conf = s;
+  int nsock;
 
-  int nsock = ap_setup_listeners(s);
+  ap_server_conf = s;
+  
+  nsock = ap_setup_listeners(s);
 
   if (nsock < 1) {
     ap_log_error(APLOG_MARK, APLOG_ALERT, 0,
@@ -139,12 +141,13 @@ static int
 simple_pre_config(apr_pool_t *pconf, apr_pool_t *plog,
                   apr_pool_t *ptemp)
 {
+  int run_debug;
   apr_status_t rv;
   simple_core_t* sc = simple_core_get();
 
   sc->restart_num++;
 
-  int run_debug = ap_exists_config_define("DEBUG");
+  run_debug = ap_exists_config_define("DEBUG");
 
   if (run_debug) {
     sc->run_foreground = 1;
@@ -262,12 +265,14 @@ set_proccount(cmd_parms *cmd, void *baton, const char *arg)
 static const char*
 set_threadcount(cmd_parms *cmd, void *baton, const char *arg)
 {
+  simple_core_t *sc = simple_core_get();
   const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
+
   if (err != NULL) {
     return err;
   }
 
-  simple_core_get()->procmgr.thread_count = atoi(arg);
+  sc->procmgr.thread_count = atoi(arg);
 
   return NULL;
 }
@@ -275,13 +280,14 @@ set_threadcount(cmd_parms *cmd, void *baton, const char *arg)
 static const char*
 set_user(cmd_parms *cmd, void *baton, const char *arg)
 {
+  simple_core_t *sc = simple_core_get();
   const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
   if (err != NULL) {
     return err;
   }
   
-  simple_core_get()->procmgr.user_name = arg;
-  simple_core_get()->procmgr.user_id = ap_uname2id(arg);
+  sc->procmgr.user_name = arg;
+  sc->procmgr.user_id = ap_uname2id(arg);
 
   return NULL;
 }
index 87c80fedf0e93c1ee5006bdba9470eb7f8454afb..4b7f60bfe846bcd7c90192d669cf049b800bad1f 100644 (file)
@@ -53,13 +53,14 @@ void
 simple_check_children_size(simple_core_t *sc,
                            void *baton)
 {
+  unsigned int count;
+  int wanted;
+  int i;
+  
   simple_register_timer(sc,
                         simple_check_children_size,
                         NULL,
                         SPAWN_CHILDREN_INTERVAL);
-  unsigned int count;
-  int wanted;
-  int i;
 
   if (sc->run_single_process && sc->restart_num == 2) {
     static int run = 0;
index db682e7776fca81661279acb9f1c008bcd073d62..908a864b71a8b202db979db56fa9704778a9eccc 100644 (file)
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-//#define APR_RING_DEBUG 1
+/* #define APR_RING_DEBUG 1 */
 
 #include "simple_types.h"
 #include "simple_event.h"
index cbc7fcca9c7042a611681aec37a673de8d715586..2eb55ab151e7b09a1610b68bcaa0bdeff2ca5810 100644 (file)
@@ -47,6 +47,9 @@ static apr_status_t
 simple_io_process(simple_conn_t *scon)
 {
   apr_status_t rv;
+  simple_core_t *sc;
+  conn_rec *c;
+  conn_state_t *cs;
 
   if (scon->c->clogging_input_filters && !scon->c->aborted) {
     /* Since we have an input filter which 'cloggs' the input stream,
@@ -59,9 +62,9 @@ simple_io_process(simple_conn_t *scon)
     }
   }
 
-  simple_core_t *sc = scon->sc;
-  conn_rec *c = scon->c;
-  conn_state_t *cs = c->cs;
+  sc = scon->sc;
+  c = scon->c;
+  cs = c->cs;
 
   while (!c->aborted) {
     if (cs->state == CONN_STATE_READ_REQUEST_LINE) {
@@ -175,12 +178,14 @@ static void *
 simple_io_setup_conn(apr_thread_t* thread, void *baton)
 {
   apr_status_t rv;
+  ap_sb_handle_t *sbh;
+  conn_state_t *cs;
+  long conn_id = 0;
+  simple_sb_t *sb;
   simple_conn_t *scon = (simple_conn_t *)baton;
 
   /* pqXXXXX: remove this. */
-  ap_sb_handle_t *sbh;
   ap_create_sb_handle(&sbh, scon->pool, 0, 0);
-  long conn_id = 0;
 
   scon->ba = apr_bucket_alloc_create(scon->pool);
 
@@ -188,8 +193,8 @@ simple_io_setup_conn(apr_thread_t* thread, void *baton)
                                conn_id, sbh, scon->ba);
 
   scon->c->cs = apr_pcalloc(scon->pool, sizeof(conn_state_t));
-  conn_state_t *cs = scon->c->cs;
-  simple_sb_t *sb = apr_pcalloc(scon->pool, sizeof(simple_sb_t));
+  cs = scon->c->cs;
+  sb = apr_pcalloc(scon->pool, sizeof(simple_sb_t));
 
   cs->pfd.p = scon->pool;
   cs->pfd.desc_type = APR_POLL_SOCKET;
@@ -225,12 +230,12 @@ apr_status_t
 simple_io_accept(simple_core_t *sc, simple_sb_t *sb)
 {
   apr_status_t rv;
-  ap_listen_rec *lr = (ap_listen_rec *)sb->baton;
   apr_pool_t *ptrans;
+  apr_socket_t *socket;
+  ap_listen_rec *lr = (ap_listen_rec *)sb->baton;
 
   /* pqXXXXXX: Consider doing pool recycling like the event/worker MPMs do. */
   apr_pool_create(&ptrans, NULL);
-  apr_socket_t *socket;
 
   apr_pool_tag(ptrans, "transaction");
 
index 224edb6b585a359745f3c18194258b2e97b69a90..80239b1c25b72e157aa0810da6206ebde5028207 100644 (file)
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-//#define APR_RING_DEBUG 1
+/* #define APR_RING_DEBUG 1 */
 
 #include "httpd.h"
 #include "http_log.h"
@@ -158,20 +158,26 @@ simple_run_loop(simple_core_t *sc)
   simple_timer_t *ep = NULL;
   
   while (sc->mpm_state == AP_MPMQ_RUNNING) {
-    apr_time_t now = apr_time_now();
+    apr_time_t tnow = apr_time_now();
+    simple_timer_t *head;
     apr_interval_time_t timeout = apr_time_from_msec(500);
-    
+    APR_RING_HEAD(simple_temp_timer_ring_t, simple_timer_t) tmp_ring;
+
     apr_thread_mutex_lock(sc->mtx);
-    simple_timer_t *head = APR_RING_FIRST(&sc->timer_ring);
+    head = APR_RING_FIRST(&sc->timer_ring);
     
     if (head != APR_RING_SENTINEL(&sc->timer_ring, simple_timer_t, link)) {
-      if (now < head->expires) {
-        timeout = (head->expires - now);
+      if (tnow < head->expires) {
+        timeout = (head->expires - tnow);
         if (timeout > apr_time_from_msec(500)) {
           /* pqXXXXX: I'm 95% sure that the Linux Powertop guys will slap me for this. */
           timeout = apr_time_from_msec(500);
         }
       }
+      else {
+        /* We have already expired timers in the queue. */
+        timeout = 0;
+      }
     }
     apr_thread_mutex_unlock(sc->mtx);
 
@@ -180,7 +186,7 @@ simple_run_loop(simple_core_t *sc)
                          simple_io_callback,
                          sc);
 
-    now = apr_time_now();
+    tnow = apr_time_now();
 
     if (rv) {
       if (!APR_STATUS_IS_EINTR(rv) && !APR_STATUS_IS_TIMEUP(rv)) {
@@ -190,7 +196,6 @@ simple_run_loop(simple_core_t *sc)
       }
     }
     
-    APR_RING_HEAD(simple_temp_timer_ring_t, simple_timer_t) tmp_ring;
     APR_RING_INIT(&tmp_ring, simple_timer_t, link);
 
     apr_thread_mutex_lock(sc->mtx);
@@ -204,7 +209,7 @@ simple_run_loop(simple_core_t *sc)
                                    simple_timer_t, link);
            ep = APR_RING_NEXT(ep, link))
       {
-        if (ep->expires < now) {
+        if (ep->expires < tnow) {
           simple_timer_t *next = APR_RING_PREV(ep, link);
           /* push this task */
           APR_RING_REMOVE(ep, link);
index d4454c7a07c3a4b1a3522102b783d4501edd1200..f27b77b1c7cc659311046bd7d0b70511421c1bd8 100644 (file)
@@ -53,7 +53,7 @@ typedef enum
   SIMPLE_PT_CORE_ACCEPT,
   SIMPLE_PT_CORE_IO,
   /* pqXXXXXX: User IO not defined yet. */
-  SIMPLE_PT_USER,
+  SIMPLE_PT_USER
 } simple_poll_type_e;
 
 struct simple_sb_t {