Patch for squid short expiration time

From: Eduard Veleba <eduard.veleba@dont-contact.us>
Date: Fri, 28 Jul 2006 10:55:51 +0200

Dear Squid developers,

in our company Seznam.cz we use your application Squid for a long time,
for example at our service http://wiki.mapy.cz,
and we are very satisfied with it. There was recently a demand to cache
pages that has set expiration time shorter than
1 minute, that your system doesn´t allow. So we modified the code a
little bit. This modification is an easy patch and we
would very appreciate if you use it in Squid for other users. The patch
is sent as an attachment and it's patch for Debian
source squid 2.5.9-10sarge2.

Thank you in advance.
Eduard Veleba
Seznam.cz, a.s.

#! /bin/sh /usr/share/dpatch/dpatch-run
## 46-ntlm-scheme-assert.dpatch by Luigi Gangitano <luigi@debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: No description.

@DPATCH@
diff -urNad squid.2.5.9.orig/src/cache_cf.c squid-2.5.9/src/cache_cf.c
--- squid.2.5.9.orig/src/cache_cf.c 2006-07-27 15:17:25.000000000 +0200
+++ squid-2.5.9/src/cache_cf.c 2006-07-27 15:20:13.236439528 +0200
@@ -223,6 +223,27 @@
     return i;
 }
 
+int
+GetTimeInteger(void)
+{
+ char *token = strtok(NULL, w_space);
+ char *end;
+ int i;
+ double d;
+ int mul = 60;
+ if (token == NULL)
+ self_destruct();
+ if (token[strlen(token) - 1] == 's') {
+ mul = 1;
+ token[strlen(token) - 1] = 0;
+ }
+ i = strtol(token, &end, 0);
+ d = strtod(token, NULL);
+ if (d > INT_MAX || end == token)
+ self_destruct();
+ return i * mul;
+}
+
 static squid_off_t
 GetOffT(void)
 {
@@ -1978,12 +1999,10 @@
     if (token == NULL)
         self_destruct();
     pattern = xstrdup(token);
- i = GetInteger(); /* token: min */
- min = (time_t) (i * 60); /* convert minutes to seconds */
- i = GetInteger(); /* token: pct */
+ min = (time_t) GetTimeInteger(); /* token: min */
+ i = GetInteger(); /* token: pct */
     pct = (double) i / 100.0;
- i = GetInteger(); /* token: max */
- max = (time_t) (i * 60); /* convert minutes to seconds */
+ max = (time_t) GetTimeInteger(); /* token: max */
     /* Options */
     while ((token = strtok(NULL, w_space)) != NULL) {
 #if HTTP_VIOLATIONS
diff -urNad squid.2.5.9.orig/src/cf.data.pre squid-2.5.9/src/cf.data.pre
--- squid.2.5.9.orig/src/cf.data.pre 2006-07-27 15:17:24.000000000 +0200
+++ squid-2.5.9/src/cf.data.pre 2006-07-27 15:27:48.871315912 +0200
@@ -1615,6 +1615,12 @@
  -----------------------------------------------------------------------------
 COMMENT_END
 
+NAME: expires_too_soon
+TYPE: int
+DEFAULT: 60
+LOC: Config.expiresTooSoon
+DOC_NONE
+
 NAME: wais_relay_host
 TYPE: string
 DEFAULT: none
diff -urNad squid.2.5.9.orig/src/refresh.c squid-2.5.9/src/refresh.c
--- squid.2.5.9.orig/src/refresh.c 2002-07-18 11:22:17.000000000 +0200
+++ squid-2.5.9/src/refresh.c 2006-07-27 15:31:45.515685944 +0200
@@ -331,7 +331,7 @@
      * 60 seconds delta, to avoid objects which expire almost
      * immediately, and which can't be refreshed.
      */
- int reason = refreshCheck(entry, NULL, 60);
+ int reason = refreshCheck(entry, NULL, Config.expiresTooSoon);
     refreshCounts[rcStore].total++;
     refreshCounts[rcStore].status[reason]++;
     if (reason < 200)
diff -urNad squid.2.5.9.orig/src/structs.h squid-2.5.9/src/structs.h
--- squid.2.5.9.orig/src/structs.h 2006-07-27 15:17:25.000000000 +0200
+++ squid-2.5.9/src/structs.h 2006-07-27 15:32:15.148181120 +0200
@@ -390,6 +390,7 @@
         int lowWaterMark;
     } Swap;
     squid_off_t memMaxSize;
+ int expiresTooSoon;
     struct {
         char *relayHost;
         u_short relayPort;

Received on Fri Jul 28 2006 - 14:16:27 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Aug 01 2006 - 12:00:02 MDT