Hi,
this patch allows storing large files in cache.
It applies to the squid3-largeobj branch. It must applied after the
previous patch I sent applied.
This patch also changes the format of cache stores so existing caches
must re-created. I don't know if it is valid. Maybe we can add some
code to keep the compatibility with existing caches like squid2.6 does.
I will try to do it if needed.
This patch must also allows large coss files but it is not tested
To enable storing large files in cache squid must configured with
"--with-large-files" option.
Regards,
Christos
Tsantilas Christos wrote:
> A more completed patch for large objects support
>
> It contains all previous changes plus:
> - HttpReply::bodySize must return 64 bit integer.
> - Some changes inside ClientHttpRequest::mRangeCLen method to use 64bit
> integers.
> - Some changes inside HttpStateData::persistentConnStatus to use 64bit
> integers
> - Remove or change some castings in file store_Client.cc
>
> This patch apply to the squid3-largeobj branch.
> I test it and worked for me.
> I also test range headers, ftp and ICAP client. Looks good.
> I did not test large objects uploads.
>
> Regards,
> Christos
>
diff -r -u -x 'Makefile*' -x '*.Po' -x '*.o' -x '*~' -x '*.la' ../../my-squid3-largeobj/src/cache_cf.cc ./cache_cf.cc
--- ../../my-squid3-largeobj/src/cache_cf.cc 2007-05-02 19:08:48.0 +0300
+++ ./cache_cf.cc 2007-05-11 22:11:00.0 +0300
@@ -144,6 +144,7 @@
#endif
#endif /* USE_SSL */
static void parse_b_size_t(size_t * var);
+static void parse_b_int64_t(int64_t * var);
/*
* LegacyParser is a parser for legacy code that uses the global
@@ -163,7 +164,7 @@
update_maxobjsize(void)
{
int i;
-ssize_t ms = -1;
+int64_t ms = -1;
for (i = 0; i < Config.cacheSwap.n_configured; i++) {
assert (Config.cacheSwap.swapDirs[i].getRaw());
@@ -172,7 +173,6 @@
max_objsize > ms)
ms = dynamic_cast(Config.cacheSwap.swapDirs[i].getRaw())->max_objsize;
}
-
store_maxobjsize = ms;
}
@@ -701,12 +701,51 @@
}
static void
+parseBytesLine64(int64_t * bptr, const char *units)
+{
+char *token;
+double d;
+int64_t m;
+int64_t u;
+
+if ((u = parseBytesUnits(units)) == 0)
+self_destruct();
+
+if ((token = strtok(NULL, w_space)) == NULL)
+self_destruct();
+
+if (strcmp(token, "none") == 0 || strcmp(token, "-1") == 0) {
+*bptr = static_cast(-1);
+return;
+}
+
+d = xatof(token);
+
+m = u; /* default to 'units' if none specified */
+
+if (0.0 == d)
+(void) 0;
+else if ((token = strtok(NULL, w_space)) == NULL)
+debugs(3, 0, "WARNING: No units on '" <<
+ config_input_line << "', assuming " <<
+ d << " " << units );
+else if ((m = parseBytesUnits(token)) == 0)
+self_destruct();
+
+*bptr = static_cast(m * d / u);
+
+if (static_cast(*bptr) * 2 != m * d / u * 2)
+self_destruct();
+}
+
+
+static void
parseBytesLine(size_t * bptr, const char *units)
{
char *token;
double d;
-size_t m;
-size_t u;
+int m;
+int u;
if ((u = parseBytesUnits(units)) == 0)
self_destruct();
@@ -1029,7 +1068,7 @@
l = cbdataAlloc(acl_size_t);
-parse_b_size_t(&l->size);
+parse_b_int64_t(&l->size);
aclParseAclList(LegacyParser, &l->aclList);
@@ -2287,6 +2326,12 @@
}
static void
+dump_b_int64_t(StoreEntry * entry, const char *name, int64_t var)
+{
+storeAppendPrintf(entry, "%s %"PRId64" %s\n", name, var, B_BYTES_STR);
+}
+
+static void
parse_size_t(size_t * var)
{
int i;
@@ -2301,6 +2346,12 @@
}
static void
+parse_b_int64_t(int64_t * var)
+{
+parseBytesLine64(var, B_BYTES_STR);
+}
+
+static void
parse_kb_size_t(size_t * var)
{
parseBytesLine(var, B_KBYTES_STR);
@@ -2312,6 +2363,12 @@
*var = 0;
}
+static void
+free_b_int64_t(int64_t * var)
+{
+*var = 0;
+}
+
#define free_b_size_t free_size_t
#define free_kb_size_t free_size_t
#define free_mb_size_t free_size_t
diff -r -u -x 'Makefile*' -x '*.Po' -x '*.o' -x '*~' -x '*.la' ../../my-squid3-largeobj/src/cf.data ./cf.data
--- ../../my-squid3-largeobj/src/cf.data 2007-05-09 20:13:51.0 +0300
+++ ./cf.data 2007-05-13 11:03:30.0 +0300
@@ -936,7 +936,7 @@
NAME: maximum_object_size
COMMENT: (bytes)
-TYPE: b_size_t
+TYPE: b_int64_t
DEFAULT: 4096 KB
LOC: Config.Store.maxObjectSize
DOC_START
@@ -954,7 +954,7 @@
NAME: minimum_object_size
COMMENT: (bytes)
-TYPE: b_size_t
+TYPE: b_int64_t
DEFAULT: 0 KB
LOC: Config.Store.minObjectSize
DOC_START
diff -r -u -x 'Makefile*' -x '*.Po' -x '*.o' -x '*~' -x '*.la' ../../my-squid3-largeobj/src/cf.data.pre ./cf.data.pre
--- ../../my-squid3-largeobj/src/cf.data.pre 2007-04-17 02:06:16.0 +0300
+++ ./cf.data.pre 2007-05-11 22:22:19.0 +0300
@@ -936,7 +936,7 @@
NAME: maximum_object_size
COMMENT: (bytes)