cvs commit: apache-1.3/src/modules/proxy proxy_cache.c

1999-06-10 Thread manoj
manoj   99/06/09 22:18:10

  Modified:src/modules/proxy proxy_cache.c
  Log:
  Fix a seg fault when the proxy is enabled but CacheRoot isn't set.
  
  Revision  ChangesPath
  1.61  +3 -1  apache-1.3/src/modules/proxy/proxy_cache.c
  
  Index: proxy_cache.c
  ===
  RCS file: /home/cvs/apache-1.3/src/modules/proxy/proxy_cache.c,v
  retrieving revision 1.60
  retrieving revision 1.61
  diff -u -d -u -r1.60 -r1.61
  --- proxy_cache.c 1999/06/02 18:10:09 1.60
  +++ proxy_cache.c 1999/06/10 05:18:08 1.61
  @@ -279,7 +279,7 @@
   const struct cache_conf *conf = pconf-cache;
   
   const char *cachedir = conf-root;
  -char *filename = ap_palloc(r-pool, strlen(cachedir) + strlen( DOT_TIME 
) +1);
  +char *filename;
   struct stat buf;
   int timefd;
   time_t every = conf-gcinterval;
  @@ -287,6 +287,8 @@
   
   if (cachedir == NULL || every == -1)
   return 0;
  +
  +filename = ap_palloc(r-pool, strlen(cachedir) + strlen( DOT_TIME ) +1);
   
   garbage_now = time(NULL);
   /* Usually, the modification time of cachedir/.time can only increase.
  
  
  


cvs commit: apache-1.3/src/modules/proxy proxy_cache.c

1999-06-02 Thread dgaudet
dgaudet 99/06/02 11:10:11

  Modified:src/modules/proxy proxy_cache.c
  Log:
  missing ap_unblock_alarms
  
  Revision  ChangesPath
  1.60  +0 -1  apache-1.3/src/modules/proxy/proxy_cache.c
  
  Index: proxy_cache.c
  ===
  RCS file: /home/cvs/apache-1.3/src/modules/proxy/proxy_cache.c,v
  retrieving revision 1.59
  retrieving revision 1.60
  diff -u -r1.59 -r1.60
  --- proxy_cache.c 1999/04/22 14:27:51 1.59
  +++ proxy_cache.c 1999/06/02 18:10:09 1.60
  @@ -327,7 +327,6 @@
   else {
lastcheck = buf.st_mtime;   /* save the time */
   if (garbage_now  lastcheck + every) {
  -ap_unblock_alarms();
   return 0;
   }
   if (utime(filename, NULL) == -1)
  
  
  


cvs commit: apache-1.3/src/modules/proxy proxy_cache.c

1999-04-22 Thread rse
rse 99/04/22 07:27:52

  Modified:src/modules/proxy proxy_cache.c
  Log:
  Ouch! With the recent commits to proxy_cache.c horrible bugs were introduced:
  First the variable filename was a global static variable and at the same time
  a local variable (``declaration of `filename' shadows global declaration'').
  Second, the filename allocation at two locations used a ``strlen(cachedir)''
  before ``cachedir'' was actually initialized!
  
  Revision  ChangesPath
  1.59  +4 -2  apache-1.3/src/modules/proxy/proxy_cache.c
  
  Index: proxy_cache.c
  ===
  RCS file: /home/cvs/apache-1.3/src/modules/proxy/proxy_cache.c,v
  retrieving revision 1.58
  retrieving revision 1.59
  diff -u -r1.58 -r1.59
  --- proxy_cache.c 1999/04/19 12:30:46 1.58
  +++ proxy_cache.c 1999/04/22 14:27:51 1.59
  @@ -103,7 +103,6 @@
   static long block_size = 512;/* this must be a power of 2 */
   static long61_t curbytes, cachesize;
   static time_t garbage_now, garbage_expire;
  -static char *filename;
   static mutex *garbage_mutex = NULL;
   
   
  @@ -348,10 +347,11 @@
   const struct cache_conf *conf = pconf-cache;
   array_header *files;
   struct gc_ent *fent;
  +char *filename;
   int i;
  -char *filename = ap_palloc(r-pool, strlen(cachedir) + HASH_LEN + 2);
   
   cachedir = conf-root;
  +filename = ap_palloc(r-pool, strlen(cachedir) + HASH_LEN + 2);
   /* configured size is given in kB. Make it bytes, convert to long61_t: */
   cachesize.lower = cachesize.upper = 0;
   add_long61(cachesize, conf-space  10);
  @@ -416,8 +416,10 @@
   #endif
   struct gc_ent *fent;
   int nfiles = 0;
  +char *filename;
   
   ap_snprintf(cachedir, sizeof(cachedir), %s%s, cachebasedir, 
cachesubdir);
  +filename = ap_palloc(r-pool, strlen(cachedir) + HASH_LEN + 2);
   Explain1(GC Examining directory %s, cachedir);
   dir = opendir(cachedir);
   if (dir == NULL) {
  
  
  


cvs commit: apache-1.3/src/modules/proxy proxy_cache.c

1999-04-19 Thread martin
martin  99/04/19 05:30:47

  Modified:src/modules/proxy proxy_cache.c
  Log:
  Not every ANSI compliant compiler supports auto-arrays of dynamic size.
  Use defensive approach and allocate filename using ap_palloc().
  
  Revision  ChangesPath
  1.58  +2 -2  apache-1.3/src/modules/proxy/proxy_cache.c
  
  Index: proxy_cache.c
  ===
  RCS file: /export/home/cvs/apache-1.3/src/modules/proxy/proxy_cache.c,v
  retrieving revision 1.57
  retrieving revision 1.58
  diff -u -r1.57 -r1.58
  --- proxy_cache.c 1999/04/08 20:27:44 1.57
  +++ proxy_cache.c 1999/04/19 12:30:46 1.58
  @@ -280,7 +280,7 @@
   const struct cache_conf *conf = pconf-cache;
   
   const char *cachedir = conf-root;
  -char filename[ strlen(cachedir) + strlen( DOT_TIME ) +1];
  +char *filename = ap_palloc(r-pool, strlen(cachedir) + strlen( DOT_TIME 
) +1);
   struct stat buf;
   int timefd;
   time_t every = conf-gcinterval;
  @@ -349,7 +349,7 @@
   array_header *files;
   struct gc_ent *fent;
   int i;
  -char filename[ strlen(cachedir) + HASH_LEN + 2];
  +char *filename = ap_palloc(r-pool, strlen(cachedir) + HASH_LEN + 2);
   
   cachedir = conf-root;
   /* configured size is given in kB. Make it bytes, convert to long61_t: */
  
  
  


cvs commit: apache-1.3/src/modules/proxy proxy_cache.c

1999-04-08 Thread dirkx
dirkx   99/04/08 13:27:46

  Modified:src/modules/proxy proxy_cache.c
  Log:
  Modified cache garbage control to first check if it
  actually should run, based on the time of last run,
  and to try to get a lock; prior to actually forking
  and doing the real cleanup. This effectively avoids
  a fork after each and every request; and limites
  the spawning to just once every few hours.
  
  Revision  ChangesPath
  1.57  +77 -46apache-1.3/src/modules/proxy/proxy_cache.c
  
  Index: proxy_cache.c
  ===
  RCS file: /x3/home/cvs/apache-1.3/src/modules/proxy/proxy_cache.c,v
  retrieving revision 1.56
  retrieving revision 1.57
  diff -u -r1.56 -r1.57
  --- proxy_cache.c 1999/03/23 14:48:09 1.56
  +++ proxy_cache.c 1999/04/08 20:27:44 1.57
  @@ -102,7 +102,7 @@
   #define ROUNDUP2BLOCKS(_bytes) (((_bytes)+block_size-1)  ~(block_size-1))
   static long block_size = 512;/* this must be a power of 2 */
   static long61_t curbytes, cachesize;
  -static time_t every, garbage_now, garbage_expire;
  +static time_t garbage_now, garbage_expire;
   static char *filename;
   static mutex *garbage_mutex = NULL;
   
  @@ -119,6 +119,7 @@
   static int sub_garbage_coll(request_rec *r, array_header *files,
const char *cachedir, const char *cachesubdir);
   static void help_proxy_garbage_coll(request_rec *r);
  +static int should_proxy_garbage_coll(request_rec *r);
   #if !defined(WIN32)  !defined(MPE)  !defined(OS2)
   static void detached_proxy_garbage_coll(request_rec *r);
   #endif
  @@ -138,10 +139,11 @@
   (void) ap_release_mutex(garbage_mutex);
   
   ap_block_alarms();   /* avoid SIGALRM on big cache cleanup */
  +if (should_proxy_garbage_coll(r))
   #if !defined(WIN32)  !defined(MPE)  !defined(OS2)
  -detached_proxy_garbage_coll(r);
  +detached_proxy_garbage_coll(r);
   #else
  -help_proxy_garbage_coll(r);
  +help_proxy_garbage_coll(r);
   #endif
   ap_unblock_alarms();
   
  @@ -205,6 +207,10 @@
   int status;
   pid_t pgrp;
   
  +#if 0
  +ap_log_error(APLOG_MARK, APLOG_DEBUG, r-server,
  +  proxy: Guess what; we fork() again...);
  +#endif
   switch (pid = fork()) {
case -1:
ap_log_error(APLOG_MARK, APLOG_ERR, r-server,
  @@ -264,27 +270,25 @@
   }
   #endif /* ndef WIN32 */
   
  -static void help_proxy_garbage_coll(request_rec *r)
  +#define DOT_TIME /.time/* marker */
  +
  +static int should_proxy_garbage_coll(request_rec *r)
   {
  -const char *cachedir;
   void *sconf = r-server-module_config;
   proxy_server_conf *pconf =
   (proxy_server_conf *) ap_get_module_config(sconf, proxy_module);
   const struct cache_conf *conf = pconf-cache;
  -array_header *files;
  -struct stat buf;
  -struct gc_ent *fent;
  -int i, timefd;
  -static time_t lastcheck = BAD_DATE;  /* static (per-process) 
data!!! */
   
  -cachedir = conf-root;
  -/* configured size is given in kB. Make it bytes, convert to long61_t: */
  -cachesize.lower = cachesize.upper = 0;
  -add_long61(cachesize, conf-space  10);
  -every = conf-gcinterval;
  +const char *cachedir = conf-root;
  +char filename[ strlen(cachedir) + strlen( DOT_TIME ) +1];
  +struct stat buf;
  +int timefd;
  +time_t every = conf-gcinterval;
  +static time_t lastcheck = BAD_DATE; /* static (per-process) 
data!!! */
   
   if (cachedir == NULL || every == -1)
  - return;
  +return 0;
  +
   garbage_now = time(NULL);
   /* Usually, the modification time of cachedir/.time can only increase.
* Thus, even with several child processes having their own copy of
  @@ -292,41 +296,68 @@
* for GC yet.
*/
   if (garbage_now != -1  lastcheck != BAD_DATE  garbage_now  
lastcheck + every)
  - return;
  +return 0;
   
  -ap_block_alarms();   /* avoid SIGALRM on big cache cleanup */
  +strcpy(filename,cachedir);
  +strcat(filename,DOT_TIME);
   
  -filename = ap_palloc(r-pool, strlen(cachedir) + HASH_LEN + 2);
  -strcpy(filename, cachedir);
  -strcat(filename, /.time);
  -if (stat(filename, buf) == -1) {/* does not exist */
  - if (errno != ENOENT) {
  - ap_log_error(APLOG_MARK, APLOG_ERR, r-server,
  -  proxy: stat(%s), filename);
  - ap_unblock_alarms();
  - return;
  - }
  - if ((timefd = creat(filename, 0666)) == -1) {
  - if (errno != EEXIST)
  - ap_log_error(APLOG_MARK, APLOG_ERR, r-server,
  -  proxy: creat(%s), filename);
  - else
  - lastcheck = garbage_now;/* someone else got in there */
  - ap_unblock_alarms();
  - return;
  - }
  - close(timefd);
  +/* At this point we have 

cvs commit: apache-1.3/src/modules/proxy proxy_cache.c

1999-03-23 Thread martin
martin  99/03/23 06:48:10

  Modified:src/modules/proxy proxy_cache.c
  Log:
  Fix compiler warning for old SINIX-D
  
  Revision  ChangesPath
  1.56  +1 -1  apache-1.3/src/modules/proxy/proxy_cache.c
  
  Index: proxy_cache.c
  ===
  RCS file: /export/home/cvs/apache-1.3/src/modules/proxy/proxy_cache.c,v
  retrieving revision 1.55
  retrieving revision 1.56
  diff -u -r1.55 -r1.56
  --- proxy_cache.c 1999/02/07 20:48:31 1.55
  +++ proxy_cache.c 1999/03/23 14:48:09 1.56
  @@ -777,7 +777,7 @@
   int ap_proxy_cache_update(cache_req *c, table *resp_hdrs,
   const int is_HTTP1, int nocache)
   {
  -#ifdef ULTRIX_BRAIN_DEATH
  +#if defined(ULTRIX_BRAIN_DEATH) || defined(SINIX_D_RESOLVER_BUG)
 extern char *mktemp(char *template);
   #endif 
   request_rec *r = c-req;
  
  
  


cvs commit: apache-1.3/src/modules/proxy proxy_cache.c

1998-07-28 Thread dgaudet
dgaudet 98/07/28 09:59:11

  Modified:src  CHANGES
   src/modules/proxy proxy_cache.c
  Log:
  fix a segfault in the proxy on OS/2
  
  Submitted by: Brian Havard
  
  Revision  ChangesPath
  1.990 +2 -0  apache-1.3/src/CHANGES
  
  Index: CHANGES
  ===
  RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v
  retrieving revision 1.989
  retrieving revision 1.990
  diff -u -r1.989 -r1.990
  --- CHANGES   1998/07/27 14:58:17 1.989
  +++ CHANGES   1998/07/28 16:59:09 1.990
  @@ -1,5 +1,7 @@
   Changes with Apache 1.3.2
   
  +  *) Fix a segfault in the proxy on OS/2.  [Brian Havard]
  +
 *) Fix Win32 part of ap_spawn_child() by providing a reasonable child_info
structure instead of just NULL. This fixes at least the RewriteMap
programs under Win32. [Marco De Michele [EMAIL PROTECTED]] PR#2483
  
  
  
  1.47  +2 -1  apache-1.3/src/modules/proxy/proxy_cache.c
  
  Index: proxy_cache.c
  ===
  RCS file: /export/home/cvs/apache-1.3/src/modules/proxy/proxy_cache.c,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- proxy_cache.c 1998/07/09 19:45:56 1.46
  +++ proxy_cache.c 1998/07/28 16:59:11 1.47
  @@ -846,7 +846,8 @@
c-fp = NULL;
}
   /* delete the previously cached file */
  - unlink(c-filename);
  +if (c-filename)
  +unlink(c-filename);
return DECLINED;/* send data to client but not cache */
   }
   
  
  
  


cvs commit: apache-1.3/src/modules/proxy proxy_cache.c

1998-07-09 Thread rse
rse 98/07/09 02:52:22

  Modified:src/modules/proxy proxy_cache.c
  Log:
  Add one more level of parenthesis because the (long) cast has to
  apply to the complete expression or GCC still complains with:
  
  proxy_cache.c:334: warning: long int format, different type arg (arg 6)
  proxy_cache.c:365: warning: long int format, different type arg (arg 6)
  
  Revision  ChangesPath
  1.45  +2 -2  apache-1.3/src/modules/proxy/proxy_cache.c
  
  Index: proxy_cache.c
  ===
  RCS file: /export/home/cvs/apache-1.3/src/modules/proxy/proxy_cache.c,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- proxy_cache.c 1998/06/13 15:22:59 1.44
  +++ proxy_cache.c 1998/07/09 09:52:20 1.45
  @@ -331,7 +331,7 @@
   if (cmp_long61(curbytes, cachesize)  0L) {
ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, r-server,
 proxy GC: Cache is %ld%% full (nothing deleted),
  -  
(long)((curbytes.upper20)|(curbytes.lower10))*100/conf-space);
  +  
(long)(((curbytes.upper20)|(curbytes.lower10))*100/conf-space));
ap_unblock_alarms();
return;
   }
  @@ -362,7 +362,7 @@
   
   ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, r-server,
 proxy GC: Cache is %ld%% full (%d deleted),
  -  
(long)((curbytes.upper20)|(curbytes.lower10))*100/conf-space, i);
  +  
(long)(((curbytes.upper20)|(curbytes.lower10))*100/conf-space), i);
   ap_unblock_alarms();
   }
   
  
  
  


cvs commit: apache-1.3/src/modules/proxy proxy_cache.c

1998-06-09 Thread martin
martin  98/06/09 14:17:55

  Modified:src/modules/proxy proxy_cache.c
  Log:
  Add casts for systems where sizeof(off_t)  sizeof(long).
  Sorry, but I see no other portable way to do it :-(
  Submitted by: Ralf Engelschall [EMAIL PROTECTED]
  
  Revision  ChangesPath
  1.43  +3 -3  apache-1.3/src/modules/proxy/proxy_cache.c
  
  Index: proxy_cache.c
  ===
  RCS file: /export/home/cvs/apache-1.3/src/modules/proxy/proxy_cache.c,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -u -r1.42 -r1.43
  --- proxy_cache.c 1998/06/02 12:50:46 1.42
  +++ proxy_cache.c 1998/06/09 21:17:54 1.43
  @@ -331,7 +331,7 @@
   if (cmp_long61(curbytes, cachesize)  0L) {
ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, r-server,
 proxy GC: Cache is %ld%% full (nothing deleted),
  -  
((curbytes.upper20)|(curbytes.lower10))*100/conf-space);
  +  
(long)((curbytes.upper20)|(curbytes.lower10))*100/conf-space);
ap_unblock_alarms();
return;
   }
  @@ -362,7 +362,7 @@
   
   ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, r-server,
 proxy GC: Cache is %ld%% full (%d deleted),
  -  
((curbytes.upper20)|(curbytes.lower10))*100/conf-space, i);
  +  
(long)((curbytes.upper20)|(curbytes.lower10))*100/conf-space, i);
   ap_unblock_alarms();
   }
   
  @@ -594,7 +594,7 @@
q = ap_proxy_get_header(c-hdrs, Content-Length);
if (q == NULL) {
strp = ap_palloc(p, 15);
  - ap_snprintf(strp, 15, %lu, c-len);
  + ap_snprintf(strp, 15, %lu, (unsigned long)c-len);
ap_proxy_add_header(c-hdrs, Content-Length, strp, HDR_REP);
}
   }
  
  
  


cvs commit: apache-1.3/src/modules/proxy proxy_cache.c

1998-02-13 Thread martin
martin  98/02/13 01:57:28

  Modified:src/modules/proxy proxy_cache.c
  Log:
  Debug code referenced invalid structure tag
  
  Revision  ChangesPath
  1.34  +1 -1  apache-1.3/src/modules/proxy/proxy_cache.c
  
  Index: proxy_cache.c
  ===
  RCS file: /home/cvs/apache-1.3/src/modules/proxy/proxy_cache.c,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -u -r1.33 -r1.34
  --- proxy_cache.c 1998/01/24 20:43:43 1.33
  +++ proxy_cache.c 1998/02/13 09:57:27 1.34
  @@ -200,7 +200,7 @@
   for (i = 0; i  files-nelts; i++) {
fent = elts[i];
sprintf(filename, %s%s, cachedir, fent-file);
  - Explain3(GC Unlinking %s (expiry %ld, garbage_now %ld), filename, 
fent-garbage_expire, garbage_now);
  + Explain3(GC Unlinking %s (expiry %ld, garbage_now %ld), filename, 
fent-expire, garbage_now);
   #if TESTING
fprintf(stderr, Would unlink %s\n, filename);
   #else