]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/store_swapmeta.cc
2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
9 /* DEBUG: section 20 Storage Manager Swapfile Metadata */
13 #include "MemObject.h"
15 #include "StoreMeta.h"
16 #include "StoreMetaUnpacker.h"
23 storeSwapTLVFree(tlv
* n
)
27 while ((t
= n
) != NULL
) {
35 * Build a TLV list for a StoreEntry
38 storeSwapMetaBuild(StoreEntry
* e
)
40 tlv
*TLV
= NULL
; /* we'll return this */
44 assert(e
->mem_obj
!= NULL
);
45 const int64_t objsize
= e
->mem_obj
->expectedReplySize();
46 assert(e
->swap_status
== SWAPOUT_WRITING
);
48 // e->mem_obj->request may be nil in this context
49 if (e
->mem_obj
->request
)
50 url
= e
->mem_obj
->request
->storeId();
54 debugs(20, 3, "storeSwapMetaBuild URL: " << url
);
56 tlv
*t
= StoreMeta::Factory (STORE_META_KEY
,SQUID_MD5_DIGEST_LENGTH
, e
->key
);
59 storeSwapTLVFree(TLV
);
63 T
= StoreMeta::Add(T
, t
);
64 t
= StoreMeta::Factory(STORE_META_STD_LFS
,STORE_HDR_METASIZE
,&e
->timestamp
);
67 storeSwapTLVFree(TLV
);
71 T
= StoreMeta::Add(T
, t
);
72 t
= StoreMeta::Factory(STORE_META_URL
, strlen(url
) + 1, url
);
75 storeSwapTLVFree(TLV
);
80 T
= StoreMeta::Add(T
, t
);
81 t
= StoreMeta::Factory(STORE_META_OBJSIZE
, sizeof(objsize
), &objsize
);
84 storeSwapTLVFree(TLV
);
89 T
= StoreMeta::Add(T
, t
);
90 vary
= e
->mem_obj
->vary_headers
;
93 t
=StoreMeta::Factory(STORE_META_VARY_HEADERS
, strlen(vary
) + 1, vary
);
96 storeSwapTLVFree(TLV
);
100 StoreMeta::Add (T
, t
);
107 storeSwapMetaPack(tlv
* tlv_list
, int *length
)
113 assert(length
!= NULL
);
114 ++buflen
; /* STORE_META_OK */
115 buflen
+= sizeof(int); /* size of header to follow */
117 for (t
= tlv_list
; t
; t
= t
->next
)
118 buflen
+= sizeof(char) + sizeof(int) + t
->length
;
120 buf
= (char *)xmalloc(buflen
);
122 buf
[j
] = (char) STORE_META_OK
;
125 memcpy(&buf
[j
], &buflen
, sizeof(int));
129 for (t
= tlv_list
; t
; t
= t
->next
) {
130 buf
[j
] = t
->getType();
132 memcpy(&buf
[j
], &t
->length
, sizeof(int));
134 memcpy(&buf
[j
], t
->value
, t
->length
);
138 assert((int) j
== buflen
);