httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject svn commit: r830188 - in /httpd/mod_fcgid/trunk/modules/fcgid: fcgid_bridge.c fcgid_pm_main.c fcgid_proctbl.h fcgid_proctbl_unix.c fcgid_proctbl_win.c
Date Tue, 27 Oct 2009 13:56:17 GMT
Author: trawick
Date: Tue Oct 27 13:56:17 2009
New Revision: 830188

URL: http://svn.apache.org/viewvc?rev=830188&view=rev
Log:
separate [un]locking of the process table by the PM and 
the request handling threads for better logging
(and potentially context-appropriate error handling in
the future)


Modified:
    httpd/mod_fcgid/trunk/modules/fcgid/fcgid_bridge.c
    httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm_main.c
    httpd/mod_fcgid/trunk/modules/fcgid/fcgid_proctbl.h
    httpd/mod_fcgid/trunk/modules/fcgid/fcgid_proctbl_unix.c
    httpd/mod_fcgid/trunk/modules/fcgid/fcgid_proctbl_win.c

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=830188&r1=830187&r2=830188&view=diff
==============================================================================
--- httpd/mod_fcgid/trunk/modules/fcgid/fcgid_bridge.c (original)
+++ httpd/mod_fcgid/trunk/modules/fcgid/fcgid_bridge.c Tue Oct 27 13:56:17 2009
@@ -33,7 +33,7 @@
 #define FCGID_APPLY_TRY_COUNT 2
 #define FCGID_REQUEST_COUNT 32
 
-static fcgid_procnode *apply_free_procnode(server_rec * s,
+static fcgid_procnode *apply_free_procnode(request_rec *r,
                                            fcgid_command * command)
 {
     /* Scan idle list, find a node match inode, deviceid and groupid
@@ -51,7 +51,7 @@
     previous_node = proctable_get_idle_list();
     busy_list_header = proctable_get_busy_list();
 
-    safe_lock(s);
+    proctable_lock(r);
     current_node = &proc_table[previous_node->next_index];
     while (current_node != proc_table) {
         next_node = &proc_table[current_node->next_index];
@@ -68,21 +68,21 @@
             current_node->next_index = busy_list_header->next_index;
             busy_list_header->next_index = current_node - proc_table;
 
-            safe_unlock(s);
+            proctable_unlock(r);
             return current_node;
         } else
             previous_node = current_node;
 
         current_node = next_node;
     }
-    safe_unlock(s);
+    proctable_unlock(r);
 
     /* Found nothing */
     return NULL;
 }
 
 static void
-return_procnode(server_rec * s,
+return_procnode(request_rec *r,
                 fcgid_procnode * procnode, int communicate_error)
 {
     fcgid_procnode *previous_node, *current_node, *next_node;
@@ -91,7 +91,7 @@
     fcgid_procnode *idle_list_header = proctable_get_idle_list();
     fcgid_procnode *busy_list_header = proctable_get_busy_list();
 
-    safe_lock(s);
+    proctable_lock(r);
 
     /* Unlink the node from busy list first */
     previous_node = busy_list_header;
@@ -118,18 +118,18 @@
         idle_list_header->next_index = procnode - proc_table;
     }
 
-    safe_unlock(s);
+    proctable_unlock(r);
 }
 
 static int
-count_busy_processes(server_rec * s, fcgid_command * command)
+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();
 
-    safe_lock(s);
+    proctable_lock(r);
 
     previous_node = busy_list_header;
     current_node = &proc_table[previous_node->next_index];
@@ -146,7 +146,7 @@
         current_node = next_node;
     }
 
-    safe_unlock(s);
+    proctable_unlock(r);
 
     return result;
 }
@@ -193,16 +193,16 @@
                           sconf->busy_timeout, dt);
         } else if (ctx->has_error) {
             ctx->procnode->diewhy = FCGID_DIE_COMM_ERROR;
-            return_procnode(s, ctx->procnode,
+            return_procnode(r, ctx->procnode,
                             1 /* communication error */ );
         } else if (ctx->procnode->cmdopts.max_requests_per_process
                    && ++ctx->procnode->requests_handled >=
                    ctx->procnode->cmdopts.max_requests_per_process) {
             ctx->procnode->diewhy = FCGID_DIE_LIFETIME_EXPIRED;
-            return_procnode(s, ctx->procnode,
+            return_procnode(r, ctx->procnode,
                             1 /* handled all requests */ );
         } else
-            return_procnode(s, ctx->procnode,
+            return_procnode(r, ctx->procnode,
                             0 /* communication ok */ );
 
         ctx->procnode = NULL;
@@ -328,7 +328,7 @@
 
             /* Apply a process slot */
             bucket_ctx->procnode =
-                apply_free_procnode(r->server, &fcgi_request);
+                apply_free_procnode(r, &fcgi_request);
             if (bucket_ctx->procnode)
                 break;
 
@@ -336,11 +336,11 @@
                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->server, &fcgi_request)) {
+                || count_busy_processes(r, &fcgi_request)) {
                 apr_sleep(apr_time_from_sec(1));
 
                 bucket_ctx->procnode =
-                    apply_free_procnode(r->server, &fcgi_request);
+                    apply_free_procnode(r, &fcgi_request);
                 if (bucket_ctx->procnode)
                     break;
             }
@@ -355,7 +355,7 @@
                                  &bucket_ctx->ipc) != APR_SUCCESS) {
                 proc_close_ipc(&bucket_ctx->ipc);
                 bucket_ctx->procnode->diewhy = FCGID_DIE_CONNECT_ERROR;
-                return_procnode(r->server, bucket_ctx->procnode,
+                return_procnode(r, bucket_ctx->procnode,
                                 1 /* has error */ );
                 bucket_ctx->procnode = NULL;
             } else

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=830188&r1=830187&r2=830188&view=diff
==============================================================================
--- httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm_main.c (original)
+++ httpd/mod_fcgid/trunk/modules/fcgid/fcgid_pm_main.c Tue Oct 27 13:56:17 2009
@@ -34,10 +34,10 @@
                   fcgid_procnode * header,
                   fcgid_procnode * node, fcgid_procnode * table_array)
 {
-    safe_lock(main_server);
+    proctable_pm_lock(main_server);
     node->next_index = header->next_index;
     header->next_index = node - table_array;
-    safe_unlock(main_server);
+    proctable_pm_unlock(main_server);
 }
 
 static apr_time_t lastidlescan = 0;
@@ -69,7 +69,7 @@
     previous_node = proctable_get_idle_list();
     error_list_header = proctable_get_error_list();
 
-    safe_lock(main_server);
+    proctable_pm_lock(main_server);
     current_node = &proc_table[previous_node->next_index];
     while (current_node != proc_table) {
         next_node = &proc_table[current_node->next_index];
@@ -101,7 +101,7 @@
 
         current_node = next_node;
     }
-    safe_unlock(main_server);
+    proctable_pm_unlock(main_server);
 }
 
 static apr_time_t lastbusyscan = 0;
@@ -131,7 +131,7 @@
     previous_node = proctable_get_busy_list();
     error_list_header = proctable_get_error_list();
 
-    safe_lock(main_server);
+    proctable_pm_lock(main_server);
     current_node = &proc_table[previous_node->next_index];
     while (current_node != proc_table) {
         next_node = &proc_table[current_node->next_index];
@@ -154,7 +154,7 @@
 
         current_node = next_node;
     }
-    safe_unlock(main_server);
+    proctable_pm_unlock(main_server);
 }
 
 static apr_time_t lastzombiescan = 0;
@@ -194,7 +194,7 @@
     error_list_header = proctable_get_error_list();
     check_list_header = &temp_header;
 
-    safe_lock(main_server);
+    proctable_pm_lock(main_server);
     current_node = &proc_table[previous_node->next_index];
     while (current_node != proc_table) {
         next_node = &proc_table[current_node->next_index];
@@ -214,7 +214,7 @@
 
         current_node = next_node;
     }
-    safe_unlock(main_server);
+    proctable_pm_unlock(main_server);
 
     /* 
        Now check every node in check list
@@ -249,7 +249,7 @@
        Now link the check list back to the tail of idle list 
      */
     if (check_list_header->next_index) {
-        safe_lock(main_server);
+        proctable_pm_lock(main_server);
         previous_node = proctable_get_idle_list();
         current_node = &proc_table[previous_node->next_index];
 
@@ -261,7 +261,7 @@
 
         /* Link check list to the tail of idle list */
         previous_node->next_index = check_list_header->next_index;
-        safe_unlock(main_server);
+        proctable_pm_unlock(main_server);
     }
 }
 
@@ -291,10 +291,10 @@
 
     /* Try wait dead processes, restore to free list */
     /* Note: I can't keep the lock during the scan */
-    safe_lock(main_server);
+    proctable_pm_lock(main_server);
     temp_error_header.next_index = error_list_header->next_index;
     error_list_header->next_index = 0;
-    safe_unlock(main_server);
+    proctable_pm_unlock(main_server);
 
     previous_node = &temp_error_header;
     current_node = &proc_table[previous_node->next_index];
@@ -338,7 +338,7 @@
     }
 
     /* Link the temp error list back */
-    safe_lock(main_server);
+    proctable_pm_lock(main_server);
     /* Find the tail of error list */
     previous_node = error_list_header;
     current_node = &proc_table[previous_node->next_index];
@@ -347,7 +347,7 @@
         current_node = &proc_table[current_node->next_index];
     }
     previous_node->next_index = temp_error_header.next_index;
-    safe_unlock(main_server);
+    proctable_pm_unlock(main_server);
 }
 
 static void kill_all_subprocess(server_rec * main_server)
@@ -474,9 +474,9 @@
     proctable_array = proctable_get_table_array();
 
     /* Apply a slot from free list */
-    safe_lock(main_server);
+    proctable_pm_lock(main_server);
     if (free_list_header->next_index == 0) {
-        safe_unlock(main_server);
+        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;
@@ -484,7 +484,7 @@
     procnode = &proctable_array[free_list_header->next_index];
     free_list_header->next_index = procnode->next_index;
     procnode->next_index = 0;
-    safe_unlock(main_server);
+    proctable_pm_unlock(main_server);
 
     /* Prepare to spawn */
     procnode->deviceid = command->deviceid;

Modified: httpd/mod_fcgid/trunk/modules/fcgid/fcgid_proctbl.h
URL: http://svn.apache.org/viewvc/httpd/mod_fcgid/trunk/modules/fcgid/fcgid_proctbl.h?rev=830188&r1=830187&r2=830188&view=diff
==============================================================================
--- httpd/mod_fcgid/trunk/modules/fcgid/fcgid_proctbl.h (original)
+++ httpd/mod_fcgid/trunk/modules/fcgid/fcgid_proctbl.h Tue Oct 27 13:56:17 2009
@@ -85,8 +85,10 @@
 size_t proctable_get_table_size(void);
 fcgid_global_share *proctable_get_globalshare(void);
 
-void safe_lock(server_rec * s);
-void safe_unlock(server_rec * s);
+void proctable_pm_lock(server_rec *s);
+void proctable_pm_unlock(server_rec *s);
+void proctable_lock(request_rec *r);
+void proctable_unlock(request_rec *r);
 
 /* Just for debug */
 void proctable_print_debug_info(server_rec * main_server);

Modified: httpd/mod_fcgid/trunk/modules/fcgid/fcgid_proctbl_unix.c
URL: http://svn.apache.org/viewvc/httpd/mod_fcgid/trunk/modules/fcgid/fcgid_proctbl_unix.c?rev=830188&r1=830187&r2=830188&view=diff
==============================================================================
--- httpd/mod_fcgid/trunk/modules/fcgid/fcgid_proctbl_unix.c (original)
+++ httpd/mod_fcgid/trunk/modules/fcgid/fcgid_proctbl_unix.c Tue Oct 27 13:56:17 2009
@@ -245,7 +245,35 @@
     return g_table_size;
 }
 
-void safe_lock(server_rec * s)
+void proctable_lock(request_rec *r)
+{
+    /* Lock error is a fatal error */
+    apr_status_t rv;
+
+    if ((rv = proctable_lock_internal()) != APR_SUCCESS) {
+        ap_log_rerror(APLOG_MARK, APLOG_EMERG, rv, r,
+                      "mod_fcgid: can't lock process table in pid %"
+                      APR_PID_T_FMT,
+                      getpid());
+        exit(1);
+    }
+}
+
+void proctable_unlock(request_rec *r)
+{
+    /* Lock error is a fatal error */
+    apr_status_t rv;
+
+    if ((rv = proctable_unlock_internal()) != APR_SUCCESS) {
+        ap_log_rerror(APLOG_MARK, APLOG_EMERG, rv, r,
+                      "mod_fcgid: can't unlock process table in pid %"
+                      APR_PID_T_FMT, 
+                      getpid());
+        exit(1);
+    }
+}
+
+void proctable_pm_lock(server_rec *s)
 {
     apr_status_t rv;
 
@@ -260,20 +288,22 @@
     /* Lock error is a fatal error */
     if ((rv = proctable_lock_internal()) != APR_SUCCESS) {
         ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
-                     "mod_fcgid: can't get lock in pid %" APR_PID_T_FMT,
+                     "mod_fcgid: can't lock process table in PM, pid %"
+                     APR_PID_T_FMT,
                      getpid());
         exit(1);
     }
 }
 
-void safe_unlock(server_rec * s)
+void proctable_pm_unlock(server_rec *s)
 {
     /* Lock error is a fatal error */
     apr_status_t rv;
 
     if ((rv = proctable_unlock_internal()) != APR_SUCCESS) {
         ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
-                     "mod_fcgid: can't unlock in pid %" APR_PID_T_FMT, 
+                     "mod_fcgid: can't unlock process table in PM, pid %"
+                     APR_PID_T_FMT,
                      getpid());
         exit(1);
     }

Modified: httpd/mod_fcgid/trunk/modules/fcgid/fcgid_proctbl_win.c
URL: http://svn.apache.org/viewvc/httpd/mod_fcgid/trunk/modules/fcgid/fcgid_proctbl_win.c?rev=830188&r1=830187&r2=830188&view=diff
==============================================================================
--- httpd/mod_fcgid/trunk/modules/fcgid/fcgid_proctbl_win.c (original)
+++ httpd/mod_fcgid/trunk/modules/fcgid/fcgid_proctbl_win.c Tue Oct 27 13:56:17 2009
@@ -121,26 +121,50 @@
     return g_table_size;
 }
 
-void safe_lock(server_rec * s)
+void proctable_lock(request_rec *r)
+{
+    /* Lock error is a fatal error */
+    apr_status_t rv;
+
+    if ((rv = proctable_lock_internal()) != APR_SUCCESS) {
+        ap_log_rerror(APLOG_MARK, APLOG_EMERG, rv, r,
+                      "mod_fcgid: can't lock process table");
+        exit(1);
+    }
+}
+
+void proctable_unlock(request_rec *r)
+{
+    /* Lock error is a fatal error */
+    apr_status_t rv;
+
+    if ((rv = proctable_unlock_internal()) != APR_SUCCESS) {
+        ap_log_rerror(APLOG_MARK, APLOG_EMERG, rv, r,
+                      "mod_fcgid: can't unlock process table");
+        exit(1);
+    }
+}
+
+void proctable_pm_lock(server_rec * s)
 {
     /* Lock error is a fatal error */
     apr_status_t rv;
 
     if ((rv = proctable_lock_internal()) != APR_SUCCESS) {
         ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
-                     "mod_fcgid: can't get lock");
+                     "mod_fcgid: can't lock process table in PM");
         exit(1);
     }
 }
 
-void safe_unlock(server_rec * s)
+void proctable_pm_unlock(server_rec * s)
 {
     /* Lock error is a fatal error */
     apr_status_t rv;
 
     if ((rv = proctable_unlock_internal()) != APR_SUCCESS) {
         ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
-                     "mod_fcgid: can't unlock");
+                     "mod_fcgid: can't unlock process table in PM");
         exit(1);
     }
 }



Mime
View raw message