--------------------- PatchSet 2400 Date: 2001/05/29 10:04:54 Author: hno Branch: etag Tag: (none) Log: Adding routines for parsing the vary marker object data Members: src/store.c:1.12.14.6->1.12.14.7 Index: squid/src/store.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/store.c,v retrieving revision 1.12.14.6 retrieving revision 1.12.14.7 diff -u -r1.12.14.6 -r1.12.14.7 --- squid/src/store.c 28 May 2001 21:04:47 -0000 1.12.14.6 +++ squid/src/store.c 29 May 2001 10:04:54 -0000 1.12.14.7 @@ -1,6 +1,6 @@ /* - * $Id: store.c,v 1.12.14.6 2001/05/28 21:04:47 hno Exp $ + * $Id: store.c,v 1.12.14.7 2001/05/29 10:04:54 hno Exp $ * * DEBUG: section 20 Storage Manager * AUTHOR: Harvest Derived @@ -614,6 +614,90 @@ } } +typedef struct { + cache_key *key; + char *etag; + int netags; + char **etags; +} VaryData; +MemPool *VaryData_pool = NULL; +void storeLocateVaryRelease(VaryData *data); +typedef void STLVCB(VaryData *vary, void *cbdata); +void storeLocateVary(StoreEntry * e, int offset, char *vary_data, STLVCB *callback, void *cbdata); + +void storeLocateVaryRelease(VaryData *data) +{ + int i; + safe_free(data->key); + data->etag = NULL; /* points to an entry in etags */ + for (i=0 ; i < data->netags; i++) { + safe_free(data->etags[i]); + } + memPoolFree(VaryData_pool, data); +} + +typedef struct { + VaryData *data; + STLVCB *callback; + void *callback_data; + StoreEntry *e; + store_client *sc; + char *buf; + char *vary_data; +} LocateVaryState; +CBDATA_TYPE(LocateVaryState); + +static void +storeLocateVaryCallback(LocateVaryState *state) +{ + if (cbdataValid(state->callback_data)) { + VaryData *data = state->data; + if (data->key || data->netags) { + state->callback(data, state->callback_data); + state->data = NULL; /* now owned by the caller */ + } else { + state->callback(NULL, state->callback_data); + } + } + cbdataUnlock(state->callback_data); + if (state->data) { + storeLocateVaryRelease(state->data); + state->data = NULL; + } + safe_free(state->vary_data); + cbdataFree(state); +} + +static void +storeLocateVaryRead(void *data, char *buf, ssize_t size) +{ + LocateVaryState *state = data; + if (size <= 0) { + storeLocateVaryCallback(state); + return; + } +} + +void +storeLocateVary(StoreEntry * e, int offset, char *vary_data, STLVCB *callback, void *cbdata) +{ + LocateVaryState *state; + CBDATA_INIT_TYPE(LocateVaryState); + if (!VaryData_pool) + VaryData_pool = memPoolCreate("VaryData", sizeof(VaryData)); + state = cbdataAlloc(LocateVaryState); + state->vary_data = xstrdup(vary_data); + state->data = memPoolAlloc(VaryData_pool); + state->e = e; + storeLockObject(state->e); + state->callback_data = cbdata; + cbdataLock(cbdata); + state->callback = callback; + state->buf = memAllocate(MEM_4K_BUF); + state->sc = storeClientListAdd(state->e, state); + storeClientCopy(state->sc, state->e, offset, offset, 4096, state->buf, storeLocateVaryRead, state); +} + void storeSetPublicKey(StoreEntry * e) {