/*
- * $Id: asn.cc,v 1.59 2000/03/06 16:23:28 wessels Exp $
+ * $Id: asn.cc,v 1.60 2000/05/07 16:18:19 adrian Exp $
*
* DEBUG: section 53 AS Number handling
* AUTHOR: Duane Wessels, Kostas Anagnostakis
struct _ASState {
StoreEntry *entry;
+ store_client *sc;
request_t *request;
int as_number;
off_t seen;
asState->request = requestLink(req);
if ((e = storeGetPublic(asres, METHOD_GET)) == NULL) {
e = storeCreateEntry(asres, asres, null_request_flags, METHOD_GET);
- storeClientListAdd(e, asState);
+ asState->sc = storeClientListAdd(e, asState);
fwdStart(-1, e, asState->request);
} else {
storeLockObject(e);
- storeClientListAdd(e, asState);
+ asState->sc = storeClientListAdd(e, asState);
}
asState->entry = e;
asState->seen = 0;
asState->offset = 0;
- storeClientCopy(e,
+ storeClientCopy(asState->sc,
+ e,
asState->seen,
asState->offset,
4096,
asState->seen, asState->offset);
if (e->store_status == STORE_PENDING) {
debug(53, 3) ("asHandleReply: store_status == STORE_PENDING: %s\n", storeUrl(e));
- storeClientCopy(e,
+ storeClientCopy(asState->sc,
+ e,
asState->seen,
asState->offset,
SM_PAGE_SIZE,
asState);
} else if (asState->seen < e->mem_obj->inmem_hi) {
debug(53, 3) ("asHandleReply: asState->seen < e->mem_obj->inmem_hi %s\n", storeUrl(e));
- storeClientCopy(e,
+ storeClientCopy(asState->sc,
+ e,
asState->seen,
asState->offset,
SM_PAGE_SIZE,
{
ASState *asState = data;
debug(53, 3) ("asnStateFree: %s\n", storeUrl(asState->entry));
- storeUnregister(asState->entry, asState);
+ storeUnregister(asState->sc, asState->entry, asState);
storeUnlockObject(asState->entry);
requestUnlink(asState->request);
cbdataFree(asState);
/*
- * $Id: client_side.cc,v 1.479 2000/05/02 22:32:37 hno Exp $
+ * $Id: client_side.cc,v 1.480 2000/05/07 16:18:19 adrian Exp $
*
* DEBUG: section 33 Client-side Routines
* AUTHOR: Duane Wessels
if (h->request == NULL)
h->request = requestLink(requestCreate(m, PROTO_NONE, null_string));
e = storeCreateEntry(h->uri, h->log_uri, flags, m);
- storeClientListAdd(e, h);
+ h->sc = storeClientListAdd(e, h);
#if DELAY_POOLS
- delaySetStoreClient(e, h, delayClient(h->request));
+ delaySetStoreClient(h->sc, delayClient(h->request));
#endif
- storeClientCopy(e, 0, 0, CLIENT_SOCK_SZ,
+ storeClientCopy(h->sc, e, 0, 0, CLIENT_SOCK_SZ,
memAllocate(MEM_CLIENT_SOCK_BUF), clientSendMoreData, h);
return e;
}
* it is not, then the beginning of the object data might get
* freed from memory before we need to access it.
*/
+#if STORE_CLIENT_LIST_SEARCH
assert(storeClientListSearch(http->old_entry->mem_obj, http));
+#endif
entry = storeCreateEntry(url,
http->log_uri,
http->request->flags,
http->request->method);
/* NOTE, don't call storeLockObject(), storeCreateEntry() does it */
- storeClientListAdd(entry, http);
+ http->sc = storeClientListAdd(entry, http);
#if DELAY_POOLS
/* delay_id is already set on original store client */
- delaySetStoreClient(entry, http, delayClient(http->request));
+ delaySetStoreClient(http->sc, delayClient(http->request));
#endif
http->request->lastmod = http->old_entry->lastmod;
debug(33, 5) ("clientProcessExpired: lastmod %d\n", (int) entry->lastmod);
/* Register with storage manager to receive updates when data comes in. */
if (EBIT_TEST(entry->flags, ENTRY_ABORTED))
debug(33, 0) ("clientProcessExpired: found ENTRY_ABORTED object\n");
- storeClientCopy(entry,
+ storeClientCopy(http->sc, entry,
http->out.offset,
http->out.offset,
CLIENT_SOCK_SZ,
/* We have an existing entry, but failed to validate it */
/* Its okay to send the old one anyway */
http->log_type = LOG_TCP_REFRESH_FAIL_HIT;
- storeUnregister(entry, http);
+ storeUnregister(http->sc, entry, http);
storeUnlockObject(entry);
entry = http->entry = http->old_entry;
} else if (STORE_PENDING == entry->store_status && 0 == status) {
debug(33, 3) ("clientHandleIMSReply: Reply is too large '%s', using old entry\n", url);
/* use old entry, this repeats the code abovez */
http->log_type = LOG_TCP_REFRESH_FAIL_HIT;
- storeUnregister(entry, http);
+ storeUnregister(http->sc, entry, http);
storeUnlockObject(entry);
entry = http->entry = http->old_entry;
/* continue */
} else {
- storeClientCopy(entry,
+ storeClientCopy(http->sc, entry,
http->out.offset + size,
http->out.offset,
CLIENT_SOCK_SZ,
* not the body they refer to. */
httpReplyUpdateOnNotModified(oldentry->mem_obj->reply, mem->reply);
storeTimestampsSet(oldentry);
- storeUnregister(entry, http);
+ storeUnregister(http->sc, entry, http);
storeUnlockObject(entry);
entry = http->entry = oldentry;
entry->timestamp = squid_curtime;
storeTimestampsSet(http->old_entry);
http->log_type = LOG_TCP_REFRESH_HIT;
}
- storeUnregister(http->old_entry, http);
+ storeUnregister(http->sc, http->old_entry, http);
storeUnlockObject(http->old_entry);
recopy = 0;
}
http->old_entry = NULL; /* done with old_entry */
assert(!EBIT_TEST(entry->flags, ENTRY_ABORTED));
if (recopy) {
- storeClientCopy(entry,
+ storeClientCopy(http->sc, entry,
http->out.offset,
http->out.offset,
CLIENT_SOCK_SZ,
*/
if ((e = http->entry)) {
http->entry = NULL;
- storeUnregister(e, http);
+ storeUnregister(http->sc, e, http);
storeUnlockObject(e);
}
#endif
stringClean(&http->range_iter.boundary);
if ((e = http->entry)) {
http->entry = NULL;
- storeUnregister(e, http);
+ storeUnregister(http->sc, e, http);
storeUnlockObject(e);
}
/* old_entry might still be set if we didn't yet get the reply
* code in clientHandleIMSReply() */
if ((e = http->old_entry)) {
http->old_entry = NULL;
- storeUnregister(e, http);
+ storeUnregister(http->sc, e, http);
storeUnlockObject(e);
}
requestUnlink(http->request);
http->log_type = LOG_TCP_SWAPFAIL_MISS;
if ((e = http->entry)) {
http->entry = NULL;
- storeUnregister(e, http);
+ storeUnregister(http->sc, e, http);
storeUnlockObject(e);
}
clientProcessMiss(http);
clientProcessMiss(http);
} else {
debug(33, 3) ("clientCacheHit: waiting for HTTP reply headers\n");
- storeClientCopy(e,
+ storeClientCopy(http->sc, e,
http->out.offset + size,
http->out.offset,
CLIENT_SOCK_SZ,
MemBuf mb = httpPacked304Reply(e->mem_obj->reply);
http->log_type = LOG_TCP_IMS_HIT;
memFree(buf, MEM_CLIENT_SOCK_BUF);
- storeUnregister(e, http);
+ storeUnregister(http->sc, e, http);
storeUnlockObject(e);
e = clientCreateStoreEntry(http, http->request->method, null_request_flags);
http->entry = e;
if (rep && clientReplyBodyTooLarge(rep->content_length)) {
ErrorState *err = errorCon(ERR_TOO_BIG, HTTP_FORBIDDEN);
err->request = requestLink(http->request);
- storeUnregister(http->entry, http);
+ storeUnregister(http->sc, http->entry, http);
storeUnlockObject(http->entry);
http->entry = clientCreateStoreEntry(http, http->request->method,
null_request_flags);
body_size, rep->hdr_sz);
} else if (size < CLIENT_SOCK_SZ && entry->store_status == STORE_PENDING) {
/* wait for more to arrive */
- storeClientCopy(entry,
+ storeClientCopy(http->sc, entry,
http->out.offset + size,
http->out.offset,
CLIENT_SOCK_SZ,
debug(33, 1) ("clientKeepaliveNextRequest: FD %d Sending next\n",
conn->fd);
assert(entry);
- if (0 == storeClientCopyPending(entry, http)) {
+ if (0 == storeClientCopyPending(http->sc, entry, http)) {
if (EBIT_TEST(entry->flags, ENTRY_ABORTED))
debug(33, 0) ("clientKeepaliveNextRequest: ENTRY_ABORTED\n");
- storeClientCopy(entry,
+ storeClientCopy(http->sc, entry,
http->out.offset,
http->out.offset,
CLIENT_SOCK_SZ,
* storage manager. */
if (EBIT_TEST(entry->flags, ENTRY_ABORTED))
debug(33, 0) ("clientWriteComplete 2: ENTRY_ABORTED\n");
- storeClientCopy(entry,
+ storeClientCopy(http->sc, entry,
http->out.offset,
http->out.offset,
CLIENT_SOCK_SZ,
err->request = requestLink(r);
err->src_addr = http->conn->peer.sin_addr;
if (http->entry) {
- storeUnregister(http->entry, http);
+ storeUnregister(http->sc, http->entry, http);
storeUnlockObject(http->entry);
}
http->entry = clientCreateStoreEntry(http, r->method, null_request_flags);
storeLockObject(http->entry);
storeCreateMemObject(http->entry, http->uri, http->log_uri);
http->entry->mem_obj->method = r->method;
- storeClientListAdd(http->entry, http);
+ http->sc = storeClientListAdd(http->entry, http);
#if DELAY_POOLS
- delaySetStoreClient(http->entry, http, delayClient(r));
+ delaySetStoreClient(http->sc, delayClient(r));
#endif
- storeClientCopy(http->entry,
+ storeClientCopy(http->sc, http->entry,
http->out.offset,
http->out.offset,
CLIENT_SOCK_SZ,
if (http->entry) {
if (EBIT_TEST(http->entry->flags, ENTRY_SPECIAL))
debug(33, 0) ("clientProcessMiss: miss on a special object (%s).\n", url);
- storeUnregister(http->entry, http);
+ storeUnregister(http->sc, http->entry, http);
storeUnlockObject(http->entry);
http->entry = NULL;
}
/*
- * $Id: delay_pools.cc,v 1.14 2000/05/02 18:55:11 hno Exp $
+ * $Id: delay_pools.cc,v 1.15 2000/05/07 16:18:19 adrian Exp $
*
* DEBUG: section 77 Delay Pools
* AUTHOR: David Luyer <luyer@ucs.uwa.edu.au>
int i = 0;
int found = 0;
store_client *sc;
- for (sc = mem->clients; sc; sc = sc->next) {
+ dlink_node *node;
+ for (node = mem->clients.head; node; node = node->next) {
+ sc = (store_client *)node->data;
if (sc->callback_data == NULL) /* open slot */
continue;
if (sc->type != STORE_MEM_CLIENT)
int j;
int jmax = -1;
store_client *sc;
+ dlink_node *node;
delay_id d = 0;
- for (sc = mem->clients; sc; sc = sc->next) {
+ for (node = mem->clients.head; node; node = node->next) {
+ sc = (store_client *)node->data;
if (sc->callback_data == NULL) /* open slot */
continue;
if (sc->type != STORE_MEM_CLIENT)
}
void
-delaySetStoreClient(StoreEntry * e, void *data, delay_id delay_id)
+delaySetStoreClient(store_client *sc, delay_id delay_id)
{
- store_client *sc = storeClientListSearch(e->mem_obj, data);
assert(sc != NULL);
sc->delay_id = delay_id;
delayRegisterDelayIdPtr(&sc->delay_id);
/*
- * $Id: net_db.cc,v 1.143 2000/05/02 20:41:23 hno Exp $
+ * $Id: net_db.cc,v 1.144 2000/05/07 16:18:19 adrian Exp $
*
* DEBUG: section 38 Network Measurement Database
* AUTHOR: Duane Wessels
typedef struct {
peer *p;
StoreEntry *e;
+ store_client *sc;
request_t *r;
off_t seen;
off_t used;
netdbExchangeDone(ex);
} else if (ex->e->store_status == STORE_PENDING) {
debug(38, 3) ("netdbExchangeHandleReply: STORE_PENDING\n");
- storeClientCopy(ex->e, ex->seen, ex->used, ex->buf_sz,
+ storeClientCopy(ex->sc, ex->e, ex->seen, ex->used, ex->buf_sz,
ex->buf, netdbExchangeHandleReply, ex);
} else if (ex->seen < ex->e->mem_obj->inmem_hi) {
debug(38, 3) ("netdbExchangeHandleReply: ex->e->mem_obj->inmem_hi\n");
- storeClientCopy(ex->e, ex->seen, ex->used, ex->buf_sz,
+ storeClientCopy(ex->sc, ex->e, ex->seen, ex->used, ex->buf_sz,
ex->buf, netdbExchangeHandleReply, ex);
} else {
debug(38, 3) ("netdbExchangeHandleReply: Done\n");
debug(38, 3) ("netdbExchangeDone: %s\n", storeUrl(ex->e));
memFree(ex->buf, MEM_4K_BUF);
requestUnlink(ex->r);
- storeUnregister(ex->e, ex);
+ storeUnregister(ex->sc, ex->e, ex);
storeUnlockObject(ex->e);
cbdataUnlock(ex->p);
cbdataFree(ex);
ex->buf_sz = 4096;;
ex->buf = memAllocate(MEM_4K_BUF);
assert(NULL != ex->e);
- storeClientListAdd(ex->e, ex);
- storeClientCopy(ex->e, ex->seen, ex->used, ex->buf_sz,
+ ex->sc = storeClientListAdd(ex->e, ex);
+ storeClientCopy(ex->sc, ex->e, ex->seen, ex->used, ex->buf_sz,
ex->buf, netdbExchangeHandleReply, ex);
ex->r->flags.loopdetect = 1; /* cheat! -- force direct */
if (p->login)
/*
- * $Id: peer_digest.cc,v 1.73 2000/03/06 16:23:33 wessels Exp $
+ * $Id: peer_digest.cc,v 1.74 2000/05/07 16:18:19 adrian Exp $
*
* DEBUG: section 72 Peer Digest Routines
* AUTHOR: Alex Rousskov
debug(72, 5) ("peerDigestRequest: found old entry\n");
storeLockObject(old_e);
storeCreateMemObject(old_e, url, url);
- storeClientListAdd(old_e, fetch);
+ fetch->old_sc = storeClientListAdd(old_e, fetch);
}
e = fetch->entry = storeCreateEntry(url, url, req->flags, req->method);
assert(EBIT_TEST(e->flags, KEY_PRIVATE));
- storeClientListAdd(e, fetch);
+ fetch->sc = storeClientListAdd(e, fetch);
/* set lastmod to trigger IMS request if possible */
if (old_e)
e->lastmod = old_e->lastmod;
fwdStart(-1, e, req);
cbdataLock(fetch);
cbdataLock(fetch->pd);
- storeClientCopy(e, 0, 0, 4096, memAllocate(MEM_4K_BUF),
+ storeClientCopy(fetch->sc, e, 0, 0, 4096, memAllocate(MEM_4K_BUF),
peerDigestFetchReply, fetch);
}
httpReplyUpdateOnNotModified(fetch->old_entry->mem_obj->reply, reply);
storeTimestampsSet(fetch->old_entry);
/* get rid of 304 reply */
- storeUnregister(fetch->entry, fetch);
+ storeUnregister(fetch->sc, fetch->entry, fetch);
storeUnlockObject(fetch->entry);
fetch->entry = fetch->old_entry;
fetch->old_entry = NULL;
/* get rid of old entry if any */
if (fetch->old_entry) {
debug(72, 3) ("peerDigestFetchReply: got new digest, releasing old one\n");
- storeUnregister(fetch->old_entry, fetch);
+ storeUnregister(fetch->old_sc, fetch->old_entry, fetch);
storeReleaseRequest(fetch->old_entry);
storeUnlockObject(fetch->old_entry);
fetch->old_entry = NULL;
if (status == HTTP_NOT_MODIFIED && fetch->pd->cd)
peerDigestFetchStop(fetch, buf, "Not modified");
else
- storeClientCopy(fetch->entry, /* have to swap in */
+ storeClientCopy(fetch->sc, fetch->entry, /* have to swap in */
0, 0, SM_PAGE_SIZE, buf, peerDigestSwapInHeaders, fetch);
} else {
/* need more data, do we have space? */
if (size >= SM_PAGE_SIZE)
peerDigestFetchAbort(fetch, buf, "reply header too big");
else
- storeClientCopy(fetch->entry, size, 0, SM_PAGE_SIZE, buf,
+ storeClientCopy(fetch->sc, fetch->entry, size, 0, SM_PAGE_SIZE, buf,
peerDigestFetchReply, fetch);
}
}
return;
}
fetch->offset += hdr_size;
- storeClientCopy(fetch->entry, size, fetch->offset,
+ storeClientCopy(fetch->sc, fetch->entry, size, fetch->offset,
SM_PAGE_SIZE, buf,
peerDigestSwapInCBlock, fetch);
} else {
if (size >= SM_PAGE_SIZE)
peerDigestFetchAbort(fetch, buf, "stored header too big");
else
- storeClientCopy(fetch->entry, size, 0, SM_PAGE_SIZE, buf,
+ storeClientCopy(fetch->sc, fetch->entry, size, 0, SM_PAGE_SIZE, buf,
peerDigestSwapInHeaders, fetch);
}
}
memFree(buf, MEM_4K_BUF);
buf = NULL;
assert(pd->cd->mask);
- storeClientCopy(fetch->entry,
+ storeClientCopy(fetch->sc, fetch->entry,
seen,
fetch->offset,
pd->cd->mask_size,
if (size >= SM_PAGE_SIZE)
peerDigestFetchAbort(fetch, buf, "digest cblock too big");
else
- storeClientCopy(fetch->entry, size, 0, SM_PAGE_SIZE, buf,
+ storeClientCopy(fetch->sc, fetch->entry, size, 0, SM_PAGE_SIZE, buf,
peerDigestSwapInCBlock, fetch);
}
}
} else {
const size_t buf_sz = pd->cd->mask_size - fetch->mask_offset;
assert(buf_sz > 0);
- storeClientCopy(fetch->entry,
+ storeClientCopy(fetch->sc, fetch->entry,
fetch->offset,
fetch->offset,
buf_sz,
if (fetch->old_entry) {
debug(72, 2) ("peerDigestFetchFinish: deleting old entry\n");
- storeUnregister(fetch->old_entry, fetch);
+ storeUnregister(fetch->sc, fetch->old_entry, fetch);
storeReleaseRequest(fetch->old_entry);
storeUnlockObject(fetch->old_entry);
fetch->old_entry = NULL;
Counter.cd.msgs_recv += fetch->recv.msg;
/* unlock everything */
- storeUnregister(fetch->entry, fetch);
+ storeUnregister(fetch->sc, fetch->entry, fetch);
storeUnlockObject(fetch->entry);
requestUnlink(fetch->request);
fetch->entry = NULL;
/*
- * $Id: protos.h,v 1.363 2000/05/03 17:15:42 adrian Exp $
+ * $Id: protos.h,v 1.364 2000/05/07 16:18:19 adrian Exp $
*
*
* SQUID Internet Object Cache http://squid.nlanr.net/Squid/
extern void storeLockObject(StoreEntry *);
extern void storeRelease(StoreEntry *);
extern int storeUnlockObject(StoreEntry *);
-extern int storeUnregister(StoreEntry *, void *);
-extern void storeClientCopy(StoreEntry * e,
- off_t seen_offset,
- off_t copy_offset,
- size_t size,
- char *buf,
- STCB * callback,
- void *data);
extern int storePendingNClients(const StoreEntry *);
extern EVH storeMaintainSwapSpace;
extern void storeExpireNow(StoreEntry *);
extern void storeNegativeCache(StoreEntry *);
extern void storeFreeMemory(void);
extern int expiresMoreThan(time_t, time_t);
-extern int storeClientCopyPending(StoreEntry *, void *);
extern void InvokeHandlers(StoreEntry *);
extern int storeEntryValidToSend(StoreEntry *);
extern void storeTimestampsSet(StoreEntry *);
/*
* store_client.c
*/
+#if STORE_CLIENT_LIST_DEBUG
extern store_client *storeClientListSearch(const MemObject * mem, void *data);
-extern void storeClientListAdd(StoreEntry * e, void *data);
-extern void storeClientCopy(StoreEntry *, off_t, off_t, size_t, char *, STCB *, void *);
-extern int storeClientCopyPending(StoreEntry * e, void *data);
-extern int storeUnregister(StoreEntry * e, void *data);
+#endif
+extern store_client *storeClientListAdd(StoreEntry * e, void *data);
+extern void storeClientCopy(store_client *, StoreEntry *, off_t, off_t, size_t, char *, STCB *, void *);
+extern int storeClientCopyPending(store_client *, StoreEntry * e, void *data);
+extern int storeUnregister(store_client *sc, StoreEntry * e, void *data);
extern off_t storeLowestMemReaderOffset(const StoreEntry * entry);
extern void InvokeHandlers(StoreEntry * e);
extern int storePendingNClients(const StoreEntry * e);
extern void delayBytesIn(delay_id, int qty);
extern int delayMostBytesWanted(const MemObject * mem, int max);
extern delay_id delayMostBytesAllowed(const MemObject * mem);
-extern void delaySetStoreClient(StoreEntry * e, void *data, delay_id delay_id);
+extern void delaySetStoreClient(store_client *sc, delay_id delay_id);
extern void delayRegisterDelayIdPtr(delay_id * loc);
extern void delayUnregisterDelayIdPtr(delay_id * loc);
#endif
/*
- * $Id: stat.cc,v 1.325 2000/05/03 17:15:42 adrian Exp $
+ * $Id: stat.cc,v 1.326 2000/05/07 16:18:19 adrian Exp $
*
* DEBUG: section 18 Cache Manager Statistics
* AUTHOR: Harvest Derived
MemObject *mem = e->mem_obj;
int i;
struct _store_client *sc;
+ dlink_node *node;
storeAppendPrintf(s, "KEY %s\n", storeKeyText(e->key));
if (mem)
storeAppendPrintf(s, "\t%s %s\n",
if (mem->swapout.sio)
storeAppendPrintf(s, "\tswapout: %d bytes written\n",
(int) storeOffset(mem->swapout.sio));
- for (i = 0, sc = &mem->clients[i]; sc != NULL; sc = sc->next, i++) {
+ for (i = 0, node = mem->clients.head; node; node = node->next, i++) {
+ sc = (store_client *)node->data;
if (sc->callback_data == NULL)
continue;
storeAppendPrintf(s, "\tClient #%d, %p\n", i, sc->callback_data);
/*
- * $Id: store.cc,v 1.520 2000/05/03 17:15:42 adrian Exp $
+ * $Id: store.cc,v 1.521 2000/05/07 16:18:20 adrian Exp $
*
* DEBUG: section 20 Storage Manager
* AUTHOR: Harvest Derived
* There is no way to abort FD-less clients, so they might
* still have mem->clients set if mem->fd == -1
*/
- assert(mem->fd == -1 || mem->clients == NULL);
+ assert(mem->fd == -1 || mem->clients.head == NULL);
httpReplyDestroy(mem->reply);
requestUnlink(mem->request);
mem->request = NULL;
/*
- * $Id: store_client.cc,v 1.87 2000/05/03 17:15:43 adrian Exp $
+ * $Id: store_client.cc,v 1.88 2000/05/07 16:18:20 adrian Exp $
*
* DEBUG: section 20 Storage Manager Client-Side Interface
* AUTHOR: Duane Wessels
storeClientWaiting(const StoreEntry * e)
{
MemObject *mem = e->mem_obj;
+ dlink_node *node;
store_client *sc;
- for (sc = mem->clients; sc; sc = sc->next) {
+ for (node = mem->clients.head; node; node = node->next) {
+ sc = (store_client *)node->data;
if (sc->callback_data != NULL)
return 1;
}
return 0;
}
+#if STORE_CLIENT_LIST_DEBUG
store_client *
storeClientListSearch(const MemObject * mem, void *data)
{
- store_client *sc;
- for (sc = mem->clients; sc; sc = sc->next) {
+ dlink_node *node;
+ store_client *sc = NULL;
+ for (node = mem->clients.head; node; node = node->next) {
+ sc = (store_client *)node->data;
if (sc->callback_data == data)
- break;
+ return sc;
}
- return sc;
+ return NULL;
}
+#endif
static store_client_t
storeClientType(StoreEntry * e)
}
/* add client with fd to client list */
-void
+store_client *
storeClientListAdd(StoreEntry * e, void *data)
{
MemObject *mem = e->mem_obj;
- store_client **T;
store_client *sc;
assert(mem);
+#if STORE_CLIENT_LIST_DEBUG
if (storeClientListSearch(mem, data) != NULL)
- return;
+ assert(1==0); /* XXX die! */
+#endif
e->refcount++;
mem->nclients++;
sc = memAllocate(MEM_STORE_CLIENT);
/* assert we'll be able to get the data we want */
/* maybe we should open swapin_fd here */
assert(e->swap_filen > -1 || storeSwapOutAble(e));
- for (T = &mem->clients; *T; T = &(*T)->next);
- *T = sc;
+ dlinkAdd(sc, &sc->node, &mem->clients);
#if DELAY_POOLS
sc->delay_id = 0;
#endif
+ return sc;
}
static void
/* copy bytes requested by the client */
void
-storeClientCopy(StoreEntry * e,
+storeClientCopy(store_client *sc,
+ StoreEntry * e,
off_t seen_offset,
off_t copy_offset,
size_t size,
STCB * callback,
void *data)
{
- store_client *sc;
assert(!EBIT_TEST(e->flags, ENTRY_ABORTED));
debug(20, 3) ("storeClientCopy: %s, seen %d, want %d, size %d, cb %p, cbdata %p\n",
storeKeyText(e->key),
(int) size,
callback,
data);
- sc = storeClientListSearch(e->mem_obj, data);
assert(sc != NULL);
+#if STORE_CLIENT_LIST_DEBUG
+ assert(sc == storeClientListSearch(e->mem_obj, data));
+#endif
assert(sc->callback == NULL);
+ assert(sc->entry == e);
sc->copy_offset = copy_offset;
sc->seen_offset = seen_offset;
sc->callback = callback;
}
int
-storeClientCopyPending(StoreEntry * e, void *data)
+storeClientCopyPending(store_client *sc, StoreEntry * e, void *data)
{
- /* return 1 if there is a callback registered for this client */
- store_client *sc = storeClientListSearch(e->mem_obj, data);
+#if STORE_CLIENT_LIST_DEBUG
+ assert(sc == storeClientListSearch(e->mem_obj, data));
+#endif
+ assert(sc->entry == e);
if (sc == NULL)
return 0;
if (sc->callback == NULL)
return 1;
}
+/*
+ * This routine hasn't been optimised to take advantage of the
+ * passed sc. Yet.
+ */
int
-storeUnregister(StoreEntry * e, void *data)
+storeUnregister(store_client *sc, StoreEntry * e, void *data)
{
MemObject *mem = e->mem_obj;
- store_client *sc;
- store_client **S;
+#if STORE_CLIENT_LIST_DEBUG
+ assert(sc == storeClientListSearch(e->mem_obj, data));
+#endif
if (mem == NULL)
- return 0;
+ return 0;
debug(20, 3) ("storeUnregister: called for '%s'\n", storeKeyText(e->key));
- for (S = &mem->clients; (sc = *S) != NULL; S = &(*S)->next) {
- if (sc->callback_data == data)
- break;
- }
if (sc == NULL)
- return 0;
- if (sc == mem->clients) {
- /*
- * If we are unregistering the _first_ client for this
- * entry, then we have to reset the client FD to -1.
- */
- mem->fd = -1;
+ return 0;
+ if (mem->clients.head == NULL)
+ return 0;
+ if (sc == (store_client *)mem->clients.head->data) {
+ /*
+ * If we are unregistering the _first_ client for this
+ * entry, then we have to reset the client FD to -1.
+ */
+ mem->fd = -1;
}
- *S = sc->next;
+ dlinkDelete(&sc->node, &mem->clients);
mem->nclients--;
if (e->store_status == STORE_OK && e->swap_status != SWAPOUT_DONE)
- storeSwapOut(e);
+ storeSwapOut(e);
if (sc->swapin_sio) {
- storeClose(sc->swapin_sio);
- cbdataUnlock(sc->swapin_sio);
- sc->swapin_sio = NULL;
+ storeClose(sc->swapin_sio);
+ cbdataUnlock(sc->swapin_sio);
+ sc->swapin_sio = NULL;
}
if (NULL != sc->callback) {
- /* callback with ssize = -1 to indicate unexpected termination */
- debug(20, 3) ("storeUnregister: store_client for %s has a callback\n",
- mem->url);
- storeClientCallback(sc, -1);
+ /* callback with ssize = -1 to indicate unexpected termination */
+ debug(20, 3) ("storeUnregister: store_client for %s has a callback\n",
+ mem->url);
+ storeClientCallback(sc, -1);
}
#if DELAY_POOLS
delayUnregisterDelayIdPtr(&sc->delay_id);
#endif
- cbdataUnlock(sc->callback_data); /* we're done with it now */
+ cbdataUnlock(sc->callback_data); /* we're done with it now */
/*assert(!sc->flags.disk_io_pending); */
cbdataFree(sc);
assert(e->lock_count > 0);
if (mem->nclients == 0)
- CheckQuickAbort(e);
+ CheckQuickAbort(e);
return 1;
}
const MemObject *mem = entry->mem_obj;
off_t lowest = mem->inmem_hi + 1;
store_client *sc;
- store_client *nx = NULL;
- for (sc = mem->clients; sc; sc = nx) {
- nx = sc->next;
+ dlink_node *nx = NULL;
+ dlink_node *node;
+
+ for (node = mem->clients.head; node; node = nx) {
+ sc = (store_client *)node->data;
+ nx = node->next;
if (sc->callback_data == NULL) /* open slot */
continue;
if (sc->type != STORE_MEM_CLIENT)
int i = 0;
MemObject *mem = e->mem_obj;
store_client *sc;
- store_client *nx = NULL;
- assert(mem->clients != NULL || mem->nclients == 0);
+ dlink_node *nx = NULL;
+ dlink_node *node;
+
debug(20, 3) ("InvokeHandlers: %s\n", storeKeyText(e->key));
/* walk the entire list looking for valid callbacks */
- for (sc = mem->clients; sc; sc = nx) {
- nx = sc->next;
+ for (node = mem->clients.head; node; node = nx) {
+ sc = (store_client *)node->data;
+ nx = node->next;
debug(20, 3) ("InvokeHandlers: checking client #%d\n", i++);
if (sc->callback_data == NULL)
continue;
/*
- * $Id: store_swapout.cc,v 1.65 2000/05/03 17:15:44 adrian Exp $
+ * $Id: store_swapout.cc,v 1.66 2000/05/07 16:18:20 adrian Exp $
*
* DEBUG: section 20 Storage Manager Swapout Functions
* AUTHOR: Duane Wessels
int
storeSwapOutAble(const StoreEntry * e)
{
- store_client *sc;
+ dlink_node *node;
if (e->mem_obj->swapout.sio != NULL)
return 1;
if (e->mem_obj->inmem_lo > 0)
* If there are DISK clients, we must write to disk
* even if its not cachable
*/
- for (sc = e->mem_obj->clients; sc; sc = sc->next)
- if (sc->type == STORE_DISK_CLIENT)
- return 1;
+ for (node = e->mem_obj->clients.head; node; node = node->next) {
+ if (((store_client *)node->data)->type == STORE_DISK_CLIENT)
+ return 1;
+ }
if (store_dirs_rebuilding)
if (!EBIT_TEST(e->flags, ENTRY_SPECIAL))
return 0;
/*
- * $Id: structs.h,v 1.329 2000/05/03 17:15:44 adrian Exp $
+ * $Id: structs.h,v 1.330 2000/05/07 16:18:20 adrian Exp $
*
*
* SQUID Internet Object Cache http://squid.nlanr.net/Squid/
struct _clientHttpRequest {
ConnStateData *conn;
request_t *request; /* Parsed URL ... */
+ store_client *sc; /* The store_client we're using */
char *uri;
char *log_uri;
struct {
PeerDigest *pd;
StoreEntry *entry;
StoreEntry *old_entry;
+ store_client *sc;
+ store_client *old_sc;
request_t *request;
int offset;
int mask_offset;
unsigned int store_copying:1;
unsigned int copy_event_pending:1;
} flags;
- store_client *next;
#if DELAY_POOLS
delay_id delay_id;
#endif
+ dlink_node node;
};
mem_hdr data_hdr;
off_t inmem_hi;
off_t inmem_lo;
- store_client *clients;
+ dlink_list clients;
int nclients;
struct {
off_t queue_offset; /* relative to in-mem data */
/*
*
- * $Id: urn.cc,v 1.58 2000/03/06 16:23:36 wessels Exp $
+ * $Id: urn.cc,v 1.59 2000/05/07 16:18:20 adrian Exp $
*
* DEBUG: section 52 URN Parsing
* AUTHOR: Kostas Anagnostakis
typedef struct {
StoreEntry *entry;
+ store_client *sc;
StoreEntry *urlres_e;
request_t *request;
request_t *urlres_r;
httpHeaderPutStr(&urlres_r->header, HDR_ACCEPT, "text/plain");
if ((urlres_e = storeGetPublic(urlres, METHOD_GET)) == NULL) {
urlres_e = storeCreateEntry(urlres, urlres, null_request_flags, METHOD_GET);
- storeClientListAdd(urlres_e, urnState);
+ urnState->sc = storeClientListAdd(urlres_e, urnState);
fwdStart(-1, urlres_e, urlres_r);
} else {
storeLockObject(urlres_e);
- storeClientListAdd(urlres_e, urnState);
+ urnState->sc = storeClientListAdd(urlres_e, urnState);
}
urnState->urlres_e = urlres_e;
urnState->urlres_r = requestLink(urlres_r);
- storeClientCopy(urlres_e,
+ storeClientCopy(urnState->sc, urlres_e,
0,
0,
4096,
return;
}
if (urlres_e->store_status == STORE_PENDING && size < SM_PAGE_SIZE) {
- storeClientCopy(urlres_e,
+ storeClientCopy(urnState->sc, urlres_e,
size,
0,
SM_PAGE_SIZE,
}
safe_free(urls);
/* mb was absorbed in httpBodySet call, so we must not clean it */
- storeUnregister(urlres_e, urnState);
+ storeUnregister(urnState->sc, urlres_e, urnState);
storeUnlockObject(urlres_e);
storeUnlockObject(urnState->entry);
requestUnlink(urnState->request);