httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dgau...@hyperreal.org
Subject cvs commit: apache-1.3/src/modules/standard mod_rewrite.c mod_rewrite.h
Date Tue, 03 Aug 1999 09:27:44 GMT
dgaudet     99/08/03 02:27:42

  Modified:    src      CHANGES
               src/modules/standard mod_rewrite.c mod_rewrite.h
  Log:
  > This patch includes fix for rewritelock in vhost problem and makes program
  > map writes atomic if writev is available.
  >
  >         -Dima
  
  PR:		3874
  Submitted by:	Dmitry Khrustalev <dima@bog.msu.su>
  
  Revision  Changes    Path
  1.1409    +4 -1      apache-1.3/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/CHANGES,v
  retrieving revision 1.1408
  retrieving revision 1.1409
  diff -u -r1.1408 -r1.1409
  --- CHANGES	1999/08/02 10:48:11	1.1408
  +++ CHANGES	1999/08/03 09:27:25	1.1409
  @@ -1,6 +1,9 @@
   Changes with Apache 1.3.8
   
  -  *  Support for compaq/tandem/com.
  +  *) RewriteLock/RewriteMap didn't work properly with virtual hosts.
  +     [Dmitry Khrustalev <dima@bog.msu.su>] PR#3874
  +
  +  *) Support for compaq/tandem/com.
        [Ottati, Michael" <michael.ottati@compaq.com>, dirkx]
   
     *) Added SHA1 password encryption support to easy migration from 
  
  
  
  1.144     +35 -49    apache-1.3/src/modules/standard/mod_rewrite.c
  
  Index: mod_rewrite.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/modules/standard/mod_rewrite.c,v
  retrieving revision 1.143
  retrieving revision 1.144
  diff -u -r1.143 -r1.144
  --- mod_rewrite.c	1999/07/29 17:54:06	1.143
  +++ mod_rewrite.c	1999/08/03 09:27:33	1.144
  @@ -91,6 +91,10 @@
   
   #include "mod_rewrite.h"
   
  +#ifndef NO_WRITEV
  +#include <sys/types.h>
  +#include <sys/uio.h>
  +#endif
   
   /*
   ** +-------------------------------------------------------+
  @@ -208,6 +212,8 @@
       /* whether proxy module is available or not */
   static int proxy_available;
   
  +static char *lockname;
  +static int lockfd = -1;
   
   /*
   ** +-------------------------------------------------------+
  @@ -234,8 +240,6 @@
       a->rewritelogfile  = NULL;
       a->rewritelogfp    = -1;
       a->rewriteloglevel = 0;
  -    a->rewritelockfile = NULL;
  -    a->rewritelockfp   = -1;
       a->rewritemaps     = ap_make_array(p, 2, sizeof(rewritemap_entry));
       a->rewriteconds    = ap_make_array(p, 2, sizeof(rewritecond_entry));
       a->rewriterules    = ap_make_array(p, 2, sizeof(rewriterule_entry));
  @@ -270,12 +274,6 @@
           a->rewritelogfp    = overrides->rewritelogfp != -1 
                                ? overrides->rewritelogfp 
                                : base->rewritelogfp;
  -        a->rewritelockfile = overrides->rewritelockfile != NULL
  -                             ? overrides->rewritelockfile
  -                             : base->rewritelockfile;
  -        a->rewritelockfp   = overrides->rewritelockfp != -1
  -                             ? overrides->rewritelockfp
  -                             : base->rewritelockfp;
           a->rewritemaps     = ap_append_arrays(p, overrides->rewritemaps,
                                                 base->rewritemaps);
           a->rewriteconds    = ap_append_arrays(p, overrides->rewriteconds,
  @@ -291,8 +289,6 @@
           a->rewriteloglevel = overrides->rewriteloglevel;
           a->rewritelogfile  = overrides->rewritelogfile;
           a->rewritelogfp    = overrides->rewritelogfp;
  -        a->rewritelockfile = overrides->rewritelockfile;
  -        a->rewritelockfp   = overrides->rewritelockfp;
           a->rewritemaps     = overrides->rewritemaps;
           a->rewriteconds    = overrides->rewriteconds;
           a->rewriterules    = overrides->rewriterules;
  @@ -528,15 +524,12 @@
   
   static const char *cmd_rewritelock(cmd_parms *cmd, void *dconf, char *a1)
   {
  -    rewrite_server_conf *sconf;
       const char *error;
   
       if ((error = ap_check_cmd_context(cmd, GLOBAL_ONLY)) != NULL)
           return error;
  -    sconf = (rewrite_server_conf *)
  -            ap_get_module_config(cmd->server->module_config, &rewrite_module);
   
  -    sconf->rewritelockfile = a1;
  +    lockname = a1;
   
       return NULL;
   }
  @@ -2920,6 +2913,9 @@
       char buf[LONG_STRING_LEN];
       char c;
       int i;
  +#ifndef NO_WRITEV
  +    struct iovec iov[2];
  +#endif
   
       /* when `RewriteEngine off' was used in the per-server
        * context then the rewritemap-programs were not spawned.
  @@ -2934,8 +2930,16 @@
       rewritelock_alloc(r);
   
       /* write out the request key */
  +#ifdef NO_WRITEV
       write(fpin, key, strlen(key));
       write(fpin, "\n", 1);
  +#else
  +    iov[0].iov_base = key;
  +    iov[0].iov_len = strlen(key);
  +    iov[1].iov_base = "\n";
  +    iov[1].iov_len = 1;
  +    writev(fpin, iov, 2);
  +#endif
   
       /* read in the response value */
       i = 0;
  @@ -3254,28 +3258,26 @@
       conf = ap_get_module_config(s->module_config, &rewrite_module);
   
       /* only operate if a lockfile is used */
  -    if (conf->rewritelockfile == NULL
  -        || *(conf->rewritelockfile) == '\0') {
  +    if (lockname == NULL || *(lockname) == '\0') {
           return;
       }
   
       /* fixup the path, especially for rewritelock_remove() */
  -    conf->rewritelockfile = ap_server_root_relative(p, conf->rewritelockfile);
  +    lockname = ap_server_root_relative(p, lockname);
   
       /* create the lockfile */
  -    unlink(conf->rewritelockfile);
  -    if ((conf->rewritelockfp = ap_popenf(p, conf->rewritelockfile,
  -                                         O_WRONLY|O_CREAT,
  +    unlink(lockname);
  +    if ((lockfd = ap_popenf(p, lockname, O_WRONLY|O_CREAT,
                                            REWRITELOCK_MODE)) < 0) {
           ap_log_error(APLOG_MARK, APLOG_ERR, s,
                        "mod_rewrite: Parent could not create RewriteLock "
  -                     "file %s", conf->rewritelockfile);
  +                     "file %s", lockname);
           exit(1);
       }
   #if !defined(OS2) && !defined(WIN32)
       /* make sure the childs have access to this file */
       if (geteuid() == 0 /* is superuser */)
  -        chown(conf->rewritelockfile, ap_user_id, -1 /* no gid change */);
  +        chown(lockname, ap_user_id, -1 /* no gid change */);
   #endif
   
       return;
  @@ -3288,18 +3290,16 @@
       conf = ap_get_module_config(s->module_config, &rewrite_module);
   
       /* only operate if a lockfile is used */
  -    if (conf->rewritelockfile == NULL
  -        || *(conf->rewritelockfile) == '\0') {
  +    if (lockname == NULL || *(lockname) == '\0') {
           return;
       }
   
       /* open the lockfile (once per child) to get a unique fd */
  -    if ((conf->rewritelockfp = ap_popenf(p, conf->rewritelockfile,
  -                                         O_WRONLY,
  +    if ((lockfd = ap_popenf(p, lockname, O_WRONLY,
                                            REWRITELOCK_MODE)) < 0) {
           ap_log_error(APLOG_MARK, APLOG_ERR, s,
                        "mod_rewrite: Child could not open RewriteLock "
  -                     "file %s", conf->rewritelockfile);
  +                     "file %s", lockname);
           exit(1);
       }
       return;
  @@ -3307,43 +3307,29 @@
   
   static void rewritelock_remove(void *data)
   {
  -    server_rec *s;
  -    rewrite_server_conf *conf;
  -
  -    /* the data is really the server_rec */
  -    s = (server_rec *)data;
  -    conf = ap_get_module_config(s->module_config, &rewrite_module);
  -
       /* only operate if a lockfile is used */
  -    if (conf->rewritelockfile == NULL
  -        || *(conf->rewritelockfile) == '\0') {
  +    if (lockname == NULL || *(lockname) == '\0') {
           return;
       }
   
       /* remove the lockfile */
  -    unlink(conf->rewritelockfile);
  +    unlink(lockname);
  +    lockname = NULL;
  +    lockfd = -1;
   }
   
   static void rewritelock_alloc(request_rec *r)
   {
  -    rewrite_server_conf *conf;
  -
  -    conf = ap_get_module_config(r->server->module_config, &rewrite_module);
  -
  -    if (conf->rewritelockfp != -1) {
  -        fd_lock(r, conf->rewritelockfp);
  +    if (lockfd != -1) {
  +        fd_lock(r, lockfd);
       }
       return;
   }
   
   static void rewritelock_free(request_rec *r)
   {
  -    rewrite_server_conf *conf;
  -
  -    conf = ap_get_module_config(r->server->module_config, &rewrite_module);
  -
  -    if (conf->rewritelockfp != -1) {
  -        fd_unlock(r, conf->rewritelockfp);
  +    if (lockfd != -1) {
  +        fd_unlock(r, lockfd);
       }
       return;
   }
  
  
  
  1.65      +0 -2      apache-1.3/src/modules/standard/mod_rewrite.h
  
  Index: mod_rewrite.h
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/modules/standard/mod_rewrite.h,v
  retrieving revision 1.64
  retrieving revision 1.65
  diff -u -r1.64 -r1.65
  --- mod_rewrite.h	1999/08/02 10:45:35	1.64
  +++ mod_rewrite.h	1999/08/03 09:27:35	1.65
  @@ -302,8 +302,6 @@
       char         *rewritelogfile;  /* the RewriteLog filename */
       int           rewritelogfp;    /* the RewriteLog open filepointer */
       int           rewriteloglevel; /* the RewriteLog level of verbosity */
  -    char         *rewritelockfile; /* the RewriteLock filename */
  -    int           rewritelockfp;   /* the RewriteLock open filepointer */
       array_header *rewritemaps;     /* the RewriteMap entries */
       array_header *rewriteconds;    /* the RewriteCond entries (temporary) */
       array_header *rewriterules;    /* the RewriteRule entries */
  
  
  

Mime
View raw message