You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mod_python-commits@quetz.apache.org by gr...@apache.org on 2003/10/21 21:11:52 UTC

cvs commit: httpd-python/src/include mod_python.h

grisha      2003/10/21 12:11:51

  Modified:    src      mod_python.c
               src/include mod_python.h
  Log:
  As a interrim measure, introduce MAX_LOCKS constant. This will
  solve the semaphore/file lock problems for the time being so that
  we can think of a better solution.
  
  Revision  Changes    Path
  1.105     +21 -4     httpd-python/src/mod_python.c
  
  Index: mod_python.c
  ===================================================================
  RCS file: /home/cvs/httpd-python/src/mod_python.c,v
  retrieving revision 1.104
  retrieving revision 1.105
  diff -u -r1.104 -r1.105
  --- mod_python.c	15 Oct 2003 03:00:31 -0000	1.104
  +++ mod_python.c	21 Oct 2003 19:11:51 -0000	1.105
  @@ -344,7 +344,20 @@
       }
       max_clients = (((max_threads <= 0) ? 1 : max_threads) *
                      ((max_procs <= 0) ? 1 : max_procs));
  -    locks = max_clients; /* XXX this is completely out of the blue */
  +
  +    /* XXX On some systems the locking mechanism chosen uses valuable
  +       system resources, notably on RH 8 it will use sysv ipc for
  +       which Linux by default provides only 128 semaphores
  +       system-wide, and on many other systems flock is used, which
  +       results in a relatively large number of open files. So for now
  +       we get by with MAX_LOCKS constant for lack of a better
  +       solution.
  +
  +       The optimal number of necessary locks is not clear, perhaps a
  +       small number is more than sufficient - if someone took the
  +       time to run some research on this, that'd be most welcome!
  +    */
  +    locks = (max_clients > MAX_LOCKS) ? MAX_LOCKS : max_clients; 
   
       ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, s,
                    "mod_python: Creating %d session mutexes based "
  @@ -383,10 +396,14 @@
                   ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
                                "mod_python: Hint: On Linux, the problem may be the number of "
                                "available semaphores, check 'sysctl kernel.sem'");
  -                /* now free one lock so that if there is a module that wants a lock, it
  -                   will be ok */
  +                /* now free two locks so that if there is another
  +                   module or two that wants a lock, it will be ok */
                   apr_global_mutex_destroy(mutex[n-1]);
                   glb->nlocks = n-1;
  +                if (n > 2) {
  +                  apr_global_mutex_destroy(mutex[n-2]);
  +                  glb->nlocks = n-2;
  +                }
                   break;
                   
               }
  
  
  
  1.38      +4 -1      httpd-python/src/include/mod_python.h
  
  Index: mod_python.h
  ===================================================================
  RCS file: /home/cvs/httpd-python/src/include/mod_python.h,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- mod_python.h	10 Sep 2003 02:11:22 -0000	1.37
  +++ mod_python.h	21 Oct 2003 19:11:51 -0000	1.38
  @@ -141,6 +141,9 @@
   #define SILENT 0
   #define NOTSILENT 1
   
  +/* hopefully this will go away */
  +#define MAX_LOCKS 32
  +
   /* python 2.3 no longer defines LONG_LONG, it defines PY_LONG_LONG */
   #ifndef LONG_LONG
   #define LONG_LONG PY_LONG_LONG