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 2013/10/04 03:48:20 UTC

svn commit: r1529061 - in /httpd/mod_fcgid/trunk: CHANGES-FCGID modules/fcgid/fcgid_bridge.c modules/fcgid/fcgid_pm.h modules/fcgid/fcgid_pm_main.c modules/fcgid/fcgid_pm_unix.c modules/fcgid/fcgid_pm_win.c

Author: trawick
Date: Fri Oct  4 01:48:20 2013
New Revision: 1529061

URL: http://svn.apache.org/r1529061
Log:
Revert r1377398 (bug fix for PR 53693), which results
in more processes being used.  This needs more careful
analysis and modification before release.

Also revert r1397778 (PR 54000) and r1527358, which addressed issues
with r1377398.

Modified:
    httpd/mod_fcgid/trunk/CHANGES-FCGID
    httpd/mod_fcgid/trunk/modules/fcgid/fcgid_bridge.c
    httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm.h
    httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm_main.c
    httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm_unix.c
    httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm_win.c

Modified: httpd/mod_fcgid/trunk/CHANGES-FCGID
URL: http://svn.apache.org/viewvc/httpd/mod_fcgid/trunk/CHANGES-FCGID?rev=1529061&r1=1529060&r2=1529061&view=diff
==============================================================================
--- httpd/mod_fcgid/trunk/CHANGES-FCGID [utf8] (original)
+++ httpd/mod_fcgid/trunk/CHANGES-FCGID [utf8] Fri Oct  4 01:48:20 2013
@@ -1,6 +1,7 @@
                                                          -*- coding: utf-8 -*-
 Changes with mod_fcgid 2.3.9
 
+  *) Revert fix for PR 53693 (added in 2.3.8 but undocumented).
 
 Changes with mod_fcgid 2.3.8
 

Modified: httpd/mod_fcgid/trunk/modules/fcgid/fcgid_bridge.c
URL: http://svn.apache.org/viewvc/httpd/mod_fcgid/trunk/modules/fcgid/fcgid_bridge.c?rev=1529061&r1=1529060&r2=1529061&view=diff
==============================================================================
--- httpd/mod_fcgid/trunk/modules/fcgid/fcgid_bridge.c (original)
+++ httpd/mod_fcgid/trunk/modules/fcgid/fcgid_bridge.c Fri Oct  4 01:48:20 2013
@@ -124,6 +124,35 @@ return_procnode(request_rec *r,
     proctable_unlock(r);
 }
 
+static int count_busy_processes(request_rec *r, fcgid_command *command)
+{
+    int result = 0;
+    fcgid_procnode *previous_node, *current_node, *next_node;
+    fcgid_procnode *proc_table = proctable_get_table_array();
+    fcgid_procnode *busy_list_header = proctable_get_busy_list();
+
+    proctable_lock(r);
+
+    previous_node = busy_list_header;
+    current_node = &proc_table[previous_node->next_index];
+    while (current_node != proc_table) {
+        if (current_node->inode == command->inode
+            && current_node->deviceid == command->deviceid
+            && !strcmp(current_node->cmdline, command->cmdline)
+            && current_node->vhost_id == command->vhost_id
+            && current_node->uid == command->uid
+            && current_node->gid == command->gid) {
+            result++;
+        }
+        next_node = &proc_table[current_node->next_index];
+        current_node = next_node;
+    }
+
+    proctable_unlock(r);
+
+    return result;
+}
+
 apr_status_t bucket_ctx_cleanup(void *thectx)
 {
     /* Cleanup jobs:
@@ -416,19 +445,19 @@ handle_request(request_rec * r, int role
             if (bucket_ctx->procnode)
                 break;
 
-            /* Send a spawn request if I can't get a process slot */
-            /* procmgr_send_spawn_cmd() return APR_SUCCESS if a process is created */
-            if( procmgr_send_spawn_cmd(&fcgi_request, r)==APR_SUCCESS ) {
-                bucket_ctx->procnode = apply_free_procnode(r, &fcgi_request);
-                if (bucket_ctx->procnode)
-                    break;
-            }
-            else {
+            /* Avoid sleeping the very first time through if there are no
+               busy processes; the problem is just that we haven't spawned
+               anything yet, so waiting is pointless */
+            if (i > 0 || j > 0 || count_busy_processes(r, &fcgi_request)) {
                 apr_sleep(apr_time_from_sec(1));
+
                 bucket_ctx->procnode = apply_free_procnode(r, &fcgi_request);
                 if (bucket_ctx->procnode)
                     break;
             }
+
+            /* Send a spawn request if I can't get a process slot */
+            procmgr_send_spawn_cmd(&fcgi_request, r);
         }
 
         /* Connect to the fastcgi server */

Modified: httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm.h
URL: http://svn.apache.org/viewvc/httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm.h?rev=1529061&r1=1529060&r2=1529061&view=diff
==============================================================================
--- httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm.h (original)
+++ httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm.h Fri Oct  4 01:48:20 2013
@@ -45,10 +45,7 @@ apr_status_t procmgr_send_spawn_cmd(fcgi
                                     request_rec * r);
 apr_status_t procmgr_fetch_cmd(fcgid_command * command,
                               server_rec * main_server);
-
-#define PROCMGR_PROC_CREATED 0
-#define PROCMGR_PROC_NOT_CREATED 1
-apr_status_t procmgr_finish_notify(server_rec * main_server, char proc_created);
+apr_status_t procmgr_finish_notify(server_rec * main_server);
 
 apr_status_t procmgr_child_init(server_rec * main_server,
                                 apr_pool_t * pchild);

Modified: httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm_main.c
URL: http://svn.apache.org/viewvc/httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm_main.c?rev=1529061&r1=1529060&r2=1529061&view=diff
==============================================================================
--- httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm_main.c (original)
+++ httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm_main.c Fri Oct  4 01:48:20 2013
@@ -527,7 +527,7 @@ static void default_proc_env(apr_table_t
 
 /* End of common to util_script.c */
 
-static apr_status_t
+static void
 fastcgi_spawn(fcgid_command * command, server_rec * main_server,
               apr_pool_t * configpool)
 {
@@ -547,7 +547,7 @@ fastcgi_spawn(fcgid_command * command, s
         proctable_pm_unlock(main_server);
         ap_log_error(APLOG_MARK, APLOG_WARNING, 0, main_server,
                      "mod_fcgid: too much processes, please increase FCGID_MAX_APPLICATION");
-        return APR_CHILD_NOTDONE;
+        return;
     }
     procnode = &proctable_array[free_list_header->next_index];
     free_list_header->next_index = procnode->next_index;
@@ -589,7 +589,7 @@ fastcgi_spawn(fcgid_command * command, s
 
         ap_log_error(APLOG_MARK, APLOG_WARNING, rv, main_server,
                      "mod_fcgid: can't create pool for process");
-        return APR_CHILD_NOTDONE;
+        return;
     }
     /* Set up longer, system defaults before falling into parsing fixed-limit
      * request-by-request variables, so if any are overriden, they preempt
@@ -614,7 +614,7 @@ fastcgi_spawn(fcgid_command * command, s
         apr_pool_destroy(procnode->proc_pool);
         link_node_to_list(main_server, free_list_header,
                           procnode, proctable_array);
-        return APR_CHILD_NOTDONE;
+        return;
     }
     else {
         /* The job done */
@@ -628,7 +628,6 @@ fastcgi_spawn(fcgid_command * command, s
                      procnode->proc_id.pid);
         register_spawn(main_server, procnode);
     }
-    return APR_SUCCESS;
 }
 
 apr_status_t pm_main(server_rec * main_server, apr_pool_t * configpool)
@@ -636,17 +635,15 @@ apr_status_t pm_main(server_rec * main_s
     fcgid_command command;
 
     while (1) {
-        char proc_created = PROCMGR_PROC_NOT_CREATED;
         if (procmgr_must_exit())
             break;
 
         /* Wait for command */
         if (procmgr_fetch_cmd(&command, main_server) == APR_SUCCESS) {
             if (is_spawn_allowed(main_server, &command))
-                if( fastcgi_spawn(&command, main_server, configpool)==APR_SUCCESS )
-                    proc_created = PROCMGR_PROC_CREATED;
+                fastcgi_spawn(&command, main_server, configpool);
 
-            procmgr_finish_notify(main_server, proc_created);
+            procmgr_finish_notify(main_server);
         }
 
         /* Move matched node to error list */

Modified: httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm_unix.c
URL: http://svn.apache.org/viewvc/httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm_unix.c?rev=1529061&r1=1529060&r2=1529061&view=diff
==============================================================================
--- httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm_unix.c (original)
+++ httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm_unix.c Fri Oct  4 01:48:20 2013
@@ -461,10 +461,9 @@ void procmgr_init_spawn_cmd(fcgid_comman
 apr_status_t procmgr_send_spawn_cmd(fcgid_command * command,
                                     request_rec * r)
 {
-    apr_status_t rv,result;
+    apr_status_t rv;
     char notifybyte;
     apr_size_t nbytes = sizeof(*command);
-    result = APR_SUCCESS;
 
     /* Get the global mutex before posting the request */
     if ((rv = apr_global_mutex_lock(g_pipelock)) != APR_SUCCESS) {
@@ -479,7 +478,6 @@ apr_status_t procmgr_send_spawn_cmd(fcgi
         /* Just print some error log and fall through */
         ap_log_rerror(APLOG_MARK, APLOG_WARNING, rv, r,
                       "mod_fcgid: can't write spawn command");
-        result = rv;
     } else {
         /* Wait the finish notify while send the request successfully */
         nbytes = sizeof(notifybyte);
@@ -488,9 +486,7 @@ apr_status_t procmgr_send_spawn_cmd(fcgi
                            &nbytes)) != APR_SUCCESS) {
             ap_log_rerror(APLOG_MARK, APLOG_WARNING, rv, r,
                           "mod_fcgid: can't get notify from process manager");
-            result = rv;
-        } else if( notifybyte!=PROCMGR_PROC_CREATED )
-            result = APR_CHILD_NOTDONE;
+        }
     }
 
     /* Release the lock */
@@ -500,16 +496,17 @@ apr_status_t procmgr_send_spawn_cmd(fcgi
         exit(0);
     }
 
-    return result;
+    return APR_SUCCESS;
 }
 
-apr_status_t procmgr_finish_notify(server_rec * main_server, char proc_created)
+apr_status_t procmgr_finish_notify(server_rec * main_server)
 {
     apr_status_t rv;
-    apr_size_t nbytes = sizeof(proc_created);
+    char notifybyte = 'p';
+    apr_size_t nbytes = sizeof(notifybyte);
 
     if ((rv =
-         apr_file_write(g_pm_write_pipe, &proc_created,
+         apr_file_write(g_pm_write_pipe, &notifybyte,
                         &nbytes)) != APR_SUCCESS) {
         ap_log_error(APLOG_MARK, APLOG_WARNING, rv, main_server,
                      "mod_fcgid: can't send notify from process manager");

Modified: httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm_win.c
URL: http://svn.apache.org/viewvc/httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm_win.c?rev=1529061&r1=1529060&r2=1529061&view=diff
==============================================================================
--- httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm_win.c (original)
+++ httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm_win.c Fri Oct  4 01:48:20 2013
@@ -160,7 +160,6 @@ void procmgr_init_spawn_cmd(fcgid_comman
 apr_status_t procmgr_send_spawn_cmd(fcgid_command * command,
                                     request_rec * r)
 {
-     char *notifybyte = NULL;
     if (g_thread && g_msgqueue && !g_must_exit
         && g_reqlock && g_notifyqueue) {
         apr_status_t rv;
@@ -191,6 +190,8 @@ apr_status_t procmgr_send_spawn_cmd(fcgi
             return rv;
         } else {
             /* Wait the respond from process manager */
+            char *notifybyte = NULL;
+
             if ((rv =
                  apr_queue_pop(g_notifyqueue,
                                (void **)&notifybyte)) != APR_SUCCESS) {
@@ -210,22 +211,13 @@ apr_status_t procmgr_send_spawn_cmd(fcgi
         }
     }
 
-    if( notifybyte && *notifybyte==PROCMGR_PROC_CREATED )
-        return APR_SUCCESS;
-    else
-        return APR_CHILD_NOTDONE;
+    return APR_SUCCESS;
 }
 
-static char g_proc_created = PROCMGR_PROC_CREATED;
-static char g_proc_not_created = PROCMGR_PROC_NOT_CREATED;
-apr_status_t procmgr_finish_notify(server_rec * main_server, char proc_created)
+apr_status_t procmgr_finish_notify(server_rec * main_server)
 {
     apr_status_t rv;
     char *notify = NULL;
-    if( proc_created==PROCMGR_PROC_CREATED )
-        notify = &g_proc_created;
-    else
-        notify = &g_proc_not_created;
 
     if ((rv = apr_queue_push(g_notifyqueue, notify)) != APR_SUCCESS) {
         ap_log_error(APLOG_MARK, APLOG_EMERG, rv, main_server,