You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by tr...@apache.org on 2010/11/21 16:45:04 UTC

svn commit: r1037483 - in /httpd/mod_fcgid/trunk: CHANGES-FCGID modules/fcgid/fcgid_spawn_ctl.c

Author: trawick
Date: Sun Nov 21 15:45:03 2010
New Revision: 1037483

URL: http://svn.apache.org/viewvc?rev=1037483&view=rev
Log:
account for first process in class in the spawn score, possibly
slowing down process creation, depending on the configuration

previously, the score was not incremented by FcgidSpawnScore when
creating the first process

refactor the code so that the same logic is used to adjust the
score and process count whether this is the first process in the
class or the Nth

Modified:
    httpd/mod_fcgid/trunk/CHANGES-FCGID
    httpd/mod_fcgid/trunk/modules/fcgid/fcgid_spawn_ctl.c

Modified: httpd/mod_fcgid/trunk/CHANGES-FCGID
URL: http://svn.apache.org/viewvc/httpd/mod_fcgid/trunk/CHANGES-FCGID?rev=1037483&r1=1037482&r2=1037483&view=diff
==============================================================================
--- httpd/mod_fcgid/trunk/CHANGES-FCGID [utf8] (original)
+++ httpd/mod_fcgid/trunk/CHANGES-FCGID [utf8] Sun Nov 21 15:45:03 2010
@@ -1,7 +1,7 @@
                                                          -*- coding: utf-8 -*-
 Changes with mod_fcgid 2.3.7
 
-
+  *) Account for first process in class in the spawn score.  [Jeff Trawick]
 
 Changes with mod_fcgid 2.3.6
 

Modified: httpd/mod_fcgid/trunk/modules/fcgid/fcgid_spawn_ctl.c
URL: http://svn.apache.org/viewvc/httpd/mod_fcgid/trunk/modules/fcgid/fcgid_spawn_ctl.c?rev=1037483&r1=1037482&r2=1037483&view=diff
==============================================================================
--- httpd/mod_fcgid/trunk/modules/fcgid/fcgid_spawn_ctl.c (original)
+++ httpd/mod_fcgid/trunk/modules/fcgid/fcgid_spawn_ctl.c Sun Nov 21 15:45:03 2010
@@ -49,6 +49,7 @@ register_life_death(server_rec * main_se
     struct fcgid_stat_node *previous_node, *current_node;
     fcgid_server_conf *sconf = ap_get_module_config(main_server->module_config,
                                                     &fcgid_module);
+    apr_time_t now = apr_time_now();
 
     if (!g_stat_pool || !procnode)
         abort();
@@ -67,31 +68,13 @@ register_life_death(server_rec * main_se
         previous_node = current_node;
     }
 
-    if (current_node) {
-        /* Found the node */
-        apr_time_t now = apr_time_now();
-
-        /* Increase the score first */
-        if (life_or_death == REGISTER_LIFE) {
-            current_node->score += sconf->spawn_score;
-            current_node->process_counter++;
-        } else {
-            current_node->score += sconf->termination_score;
-            current_node->process_counter--;
+    if (!current_node) {         /* I can't find it, create one */
+        if (life_or_death == REGISTER_DEATH) {
+            ap_log_error(APLOG_MARK, APLOG_CRIT, 0, main_server,
+                         "stat node not found for exiting process %s",
+                         procnode->cmdline);
+            return;
         }
-
-        /* Decrease the score base on elapsed time */
-        current_node->score -= 
-          sconf->time_score * 
-          (int)(apr_time_sec(now) - apr_time_sec(current_node->last_stat_time));
-
-        /* Make score reasonable */
-        if (current_node->score < 0)
-            current_node->score = 0;
-
-        current_node->last_stat_time = now;
-    } else {
-        /* I can't find it, create one */
         current_node = apr_pcalloc(g_stat_pool, sizeof(*current_node));
         current_node->deviceid = procnode->deviceid;
         current_node->inode = procnode->inode;
@@ -99,9 +82,9 @@ register_life_death(server_rec * main_se
         current_node->vhost_id = procnode->vhost_id;
         current_node->uid = procnode->uid;
         current_node->gid = procnode->gid;
-        current_node->last_stat_time = apr_time_now();
+        current_node->last_stat_time = now;
         current_node->score = 0;
-        current_node->process_counter = 1;
+        current_node->process_counter = 0;
         current_node->max_class_process_count =
             procnode->cmdopts.max_class_process_count;
         current_node->min_class_process_count =
@@ -114,6 +97,26 @@ register_life_death(server_rec * main_se
         else
             previous_node->next = current_node;
     }
+
+    /* Increase the score first */
+    if (life_or_death == REGISTER_LIFE) {
+        current_node->score += sconf->spawn_score;
+        current_node->process_counter++;
+    } else {
+        current_node->score += sconf->termination_score;
+        current_node->process_counter--;
+    }
+
+    /* Decrease the score based on elapsed time */
+    current_node->score -= 
+        sconf->time_score * 
+        (int)(apr_time_sec(now) - apr_time_sec(current_node->last_stat_time));
+
+    /* Make score reasonable */
+    if (current_node->score < 0)
+        current_node->score = 0;
+
+    current_node->last_stat_time = now;
 }
 
 void spawn_control_init(server_rec * main_server, apr_pool_t * configpool)