--------------------- PatchSet 2722 Date: 2001/08/07 13:18:33 Author: adri Branch: newhttp Tag: (none) Log: * update stmem to use a dlink_list * squid-indent on each of the committed files (since we'll have to do it anyway) Members: src/HttpReply.c:1.1.1.3.8.4.4.3->1.1.1.3.8.4.4.3.2.1 src/protos.h:1.1.1.3.8.11.2.20.2.9->1.1.1.3.8.11.2.20.2.10 src/stmem.c:1.1.1.2.12.3.4.1->1.1.1.2.12.3.4.1.2.1 src/store.c:1.1.1.3.8.7.4.6->1.1.1.3.8.7.4.6.2.1 src/store_swapout.c:1.1.1.3.4.1.4.8.4.2->1.1.1.3.4.1.4.8.4.2.2.1 src/structs.h:1.1.1.3.4.1.4.12.2.26.2.7->1.1.1.3.4.1.4.12.2.26.2.8 Index: squid/src/HttpReply.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/HttpReply.c,v retrieving revision 1.1.1.3.8.4.4.3 retrieving revision 1.1.1.3.8.4.4.3.2.1 diff -u -r1.1.1.3.8.4.4.3 -r1.1.1.3.8.4.4.3.2.1 --- squid/src/HttpReply.c 27 Apr 2001 14:38:37 -0000 1.1.1.3.8.4.4.3 +++ squid/src/HttpReply.c 7 Aug 2001 13:18:33 -0000 1.1.1.3.8.4.4.3.2.1 @@ -1,6 +1,6 @@ /* - * $Id: HttpReply.c,v 1.1.1.3.8.4.4.3 2001/04/27 14:38:37 rbcollins Exp $ + * $Id: HttpReply.c,v 1.1.1.3.8.4.4.3.2.1 2001/08/07 13:18:33 adri Exp $ * * DEBUG: section 58 HTTP Reply (Response) * AUTHOR: Alex Rousskov @@ -190,6 +190,7 @@ * this is realllly bad. Bring on metadata headers and no silly checks. * of course, if vprintf returned size, we could just count the traffic in Packer */ HttpReply *tempreply, *tempreply2; + mem_node *n; Packer p; assert(rep && e); @@ -197,10 +198,12 @@ httpReplyPackInto(rep, &p); packerClean(&p); /* cross fingers and hope the header length is in the first chunk */ - tempreply=httpReplyCreate(); - httpReplyParse(tempreply, e->mem_obj->data_hdr.head->data,e->mem_obj->data_hdr.head->len); - tempreply2=(HttpReply *)rep; - tempreply2->hdr_sz=tempreply->hdr_sz; + tempreply = httpReplyCreate(); + n = e->mem_obj->data_hdr.list.head->data; + + httpReplyParse(tempreply, n->data, n->len); + tempreply2 = (HttpReply *) rep; + tempreply2->hdr_sz = tempreply->hdr_sz; httpReplyDestroy(tempreply); } Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,v retrieving revision 1.1.1.3.8.11.2.20.2.9 retrieving revision 1.1.1.3.8.11.2.20.2.10 diff -u -r1.1.1.3.8.11.2.20.2.9 -r1.1.1.3.8.11.2.20.2.10 --- squid/src/protos.h 13 May 2001 14:34:42 -0000 1.1.1.3.8.11.2.20.2.9 +++ squid/src/protos.h 7 Aug 2001 13:18:34 -0000 1.1.1.3.8.11.2.20.2.10 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.1.1.3.8.11.2.20.2.9 2001/05/13 14:34:42 rbcollins Exp $ + * $Id: protos.h,v 1.1.1.3.8.11.2.20.2.10 2001/08/07 13:18:34 adri Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -397,7 +397,7 @@ extern void httpHeaderAddContRange(HttpHeader *, HttpHdrRangeSpec, ssize_t); extern void strListAdd(String * str, const char *item, char del); extern int strListIsMember(const String * str, const char *item, char del); -extern int strListIsMember_q (const String * list, const char *m, char del); +extern int strListIsMember_q(const String * list, const char *m, char del); extern int strListIsSubstr(const String * list, const char *s, char del); extern int strListGetItem(const String * str, char del, const char **item, int *ilen, const char **pos); extern const char *getStringPrefix(const char *str, const char *end); @@ -699,7 +699,7 @@ extern void cachemgrInit(void); extern void peerSelect(request_t *, StoreEntry *, PSC *, void *data); -extern void newpeerSelect(clientHttpRequest *,PSC *, void *data); +extern void newpeerSelect(clientHttpRequest *, PSC *, void *data); extern void peerSelectInit(void); /* peer_digest.c */ @@ -863,6 +863,7 @@ extern ssize_t stmemCopy(const mem_hdr *, off_t, char *, size_t); extern void stmemFree(mem_hdr *); extern void stmemFreeData(mem_hdr *); +extern int stmemRead(int, mem_hdr *); /* ----------------------------------------------------------------- */ @@ -1307,31 +1308,31 @@ /* internal_modules.sh */ extern int mod_internal_install(const char *, modNode *); /* modules.c */ -extern void mod_register(const char * namestr, MOD_INSTALL *, MOD_UNINSTALL *, modNode *); +extern void mod_register(const char *namestr, MOD_INSTALL *, MOD_UNINSTALL *, modNode *); /* * transfer_encoding.c */ -extern void new_xlat (dlink_list *, int beg_or_end, - DATAFILTER *, DATAFILTER_HDR *, REMOVEFILTER *, - void *data); -extern int perform_te (TE_list *xlat, const char *ibuf, int ibufl, - char **obuf, int *obufl); +extern void new_xlat(dlink_list *, int beg_or_end, + DATAFILTER *, DATAFILTER_HDR *, REMOVEFILTER *, + void *data); +extern int perform_te(TE_list * xlat, const char *ibuf, int ibufl, + char **obuf, int *obufl); /* alters hdr as it build the list */ extern void te_build_decode_xlate_list(HttpHeader * hdr, dlink_list *); -extern void te_build_encode_xlate_list(const HttpHeader *ohdr, HttpHeader *hdr, dlink_list *, http_version_t http_ver, request_flags *flags); +extern void te_build_encode_xlate_list(const HttpHeader * ohdr, HttpHeader * hdr, dlink_list *, http_version_t http_ver, request_flags * flags); /* filters.c */ extern FILTER_module *filterByName(const char *namestr); extern FILTER_instance *filterInstanceByName(const char *namestr, FILTER_instance **); extern void filterRegisterModule(const char *, ADDFILTERINSTANCE *, REMFILTERINSTANCE *); extern void filterDeregisterModule(const char *); -extern void filterBuildChain(filterAccess *, dlink_list *, clientHttpRequest * , HttpReply *, request_t *); +extern void filterBuildChain(filterAccess *, dlink_list *, clientHttpRequest *, HttpReply *, request_t *); extern void filterCleanChain(dlink_list *); extern void filterChainAdd(dlink_list *, DATAFILTER *, DATAFILTER_HDR *, - REMOVEFILTER *, void *); + REMOVEFILTER *, void *); extern void filterChainAddTail(dlink_list *, DATAFILTER *, DATAFILTER_HDR *, - REMOVEFILTER *, void *); + REMOVEFILTER *, void *); extern void filterParserRegister(void); extern DATAFILTER_HDR identity_header; extern DATAFILTER identity_body; Index: squid/src/stmem.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/stmem.c,v retrieving revision 1.1.1.2.12.3.4.1 retrieving revision 1.1.1.2.12.3.4.1.2.1 diff -u -r1.1.1.2.12.3.4.1 -r1.1.1.2.12.3.4.1.2.1 --- squid/src/stmem.c 5 Feb 2001 13:37:33 -0000 1.1.1.2.12.3.4.1 +++ squid/src/stmem.c 7 Aug 2001 13:18:34 -0000 1.1.1.2.12.3.4.1.2.1 @@ -1,6 +1,6 @@ /* - * $Id: stmem.c,v 1.1.1.2.12.3.4.1 2001/02/05 13:37:33 rbcollins Exp $ + * $Id: stmem.c,v 1.1.1.2.12.3.4.1.2.1 2001/08/07 13:18:34 adri Exp $ * * DEBUG: section 19 Store Memory Primitives * AUTHOR: Harvest Derived @@ -38,17 +38,21 @@ void stmemFree(mem_hdr * mem) { + dlink_node *n; mem_node *p; - while ((p = mem->head)) { - mem->head = p->next; + + n = mem->list.head; + while (n) { + p = n->data; + n = n->next; memFree(p->data, MEM_STMEM_BUF); store_mem_size -= SM_PAGE_SIZE; + dlinkDelete(n, &mem->list); if (p) { memFree(p, MEM_MEM_NODE); p = NULL; } } - mem->head = mem->tail = NULL; mem->origin_offset = 0; } @@ -57,16 +61,22 @@ { int current_offset = mem->origin_offset; mem_node *lastp; - mem_node *p = mem->head; + mem_node *p; + + assert(mem->list.head != NULL); + /* If the first assert() passes this one should, but hey.. -- adrian */ + assert(mem->list.tail != NULL); + p = mem->list.head->data; while (p && ((current_offset + p->len) <= target_offset)) { - if (p == mem->tail) { + if (p == mem->list.tail->data) { /* keep the last one to avoid change to other part of code */ - mem->head = mem->tail; + /* mem->head = mem->tail; */ mem->origin_offset = current_offset; return current_offset; } else { lastp = p; - p = p->next; + p = p->node.next->data; + dlinkDelete(&lastp->node, &mem->list); current_offset += lastp->len; memFree(lastp->data, MEM_STMEM_BUF); store_mem_size -= SM_PAGE_SIZE; @@ -76,7 +86,7 @@ } } } - mem->head = p; + /* mem->head = p; */ mem->origin_offset = current_offset; if (current_offset < target_offset) { /* there are still some data left. */ @@ -91,37 +101,32 @@ stmemAppend(mem_hdr * mem, const char *data, int len) { mem_node *p; + mem_node *t; int avail_len; int len_to_copy; + debug(19, 6) ("memAppend: len %d\n", len); /* Does the last block still contain empty space? * If so, fill out the block before dropping into the * allocation loop */ - if (mem->head && mem->tail && (mem->tail->len < SM_PAGE_SIZE)) { - avail_len = SM_PAGE_SIZE - (mem->tail->len); + if (mem->list.head && mem->list.tail && (((mem_node *) (mem->list.tail->data))->len < SM_PAGE_SIZE)) { + t = mem->list.tail->data; + avail_len = SM_PAGE_SIZE - (t->len); len_to_copy = XMIN(avail_len, len); - xmemcpy((mem->tail->data + mem->tail->len), data, len_to_copy); + xmemcpy((t->data + t->len), data, len_to_copy); /* Adjust the ptr and len according to what was deposited in the page */ data += len_to_copy; len -= len_to_copy; - mem->tail->len += len_to_copy; + t->len += len_to_copy; } while (len > 0) { len_to_copy = XMIN(len, SM_PAGE_SIZE); p = memAllocate(MEM_MEM_NODE); - p->next = NULL; p->len = len_to_copy; p->data = memAllocate(MEM_STMEM_BUF); store_mem_size += SM_PAGE_SIZE; xmemcpy(p->data, data, len_to_copy); - if (!mem->head) { - /* The chain is empty */ - mem->head = mem->tail = p; - } else { - /* Append it to existing chain */ - mem->tail->next = p; - mem->tail = p; - } + dlinkAddTail(p, &p->node, &mem->list); len -= len_to_copy; data += len_to_copy; } @@ -130,7 +135,7 @@ ssize_t stmemCopy(const mem_hdr * mem, off_t offset, char *buf, size_t size) { - mem_node *p = mem->head; + mem_node *p = mem->list.head->data; off_t t_off = mem->origin_offset; size_t bytes_to_go = size; char *ptr_to_buf = NULL; @@ -143,12 +148,12 @@ /* Seek our way into store */ while ((t_off + p->len) < offset) { t_off += p->len; - if (!p->next) { + if (!p->node.next) { debug(19, 1) ("memCopy: p->next == NULL\n"); return 0; } - assert(p->next); - p = p->next; + assert(p->node.next); + p = p->node.next->data; } /* Start copying begining with this block until * we're satiated */ @@ -157,7 +162,7 @@ xmemcpy(buf, p->data + bytes_into_this_packet, bytes_from_this_packet); bytes_to_go -= bytes_from_this_packet; ptr_to_buf = buf + bytes_from_this_packet; - p = p->next; + p = p->node.next->data; while (p && bytes_to_go > 0) { if (bytes_to_go > p->len) { xmemcpy(ptr_to_buf, p->data, p->len); @@ -167,7 +172,24 @@ xmemcpy(ptr_to_buf, p->data, bytes_to_go); bytes_to_go -= bytes_to_go; } - p = p->next; + p = p->node.next->data; } return size - bytes_to_go; } + +/* + * stmemRead - read some data into a storemem list + * + * We attempt to read some data into the existing buffer. + * If the buffer is filled or we need a new buffer, create it. + * Later on someone should look at optimising this (ie if a buffer is filled, + * try filling a second buffer) but for now this will do. + * + * Return values: same as read() + */ + +int +stmemRead(int fd, mem_hdr * mem) +{ + +} Index: squid/src/store.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/store.c,v retrieving revision 1.1.1.3.8.7.4.6 retrieving revision 1.1.1.3.8.7.4.6.2.1 diff -u -r1.1.1.3.8.7.4.6 -r1.1.1.3.8.7.4.6.2.1 --- squid/src/store.c 27 Apr 2001 14:39:05 -0000 1.1.1.3.8.7.4.6 +++ squid/src/store.c 7 Aug 2001 13:18:34 -0000 1.1.1.3.8.7.4.6.2.1 @@ -1,6 +1,6 @@ /* - * $Id: store.c,v 1.1.1.3.8.7.4.6 2001/04/27 14:39:05 rbcollins Exp $ + * $Id: store.c,v 1.1.1.3.8.7.4.6.2.1 2001/08/07 13:18:34 adri Exp $ * * DEBUG: section 20 Storage Manager * AUTHOR: Harvest Derived @@ -511,7 +511,7 @@ void storeAppendOld(StoreEntry * e, const char *buf, int len) { - storeAppend(e,buf,len,0); + storeAppend(e, buf, len, 0); } /* Append incoming data from a primary server to an entry. */ @@ -522,7 +522,7 @@ MemObject *mem = e->mem_obj; assert(mem != NULL); assert(len >= 0); - debug(20,1)("storeAppend, entry %p, len %d, flags %d\n",e,len,flags); + debug(20, 1) ("storeAppend, entry %p, len %d, flags %d\n", e, len, flags); assert(e->store_status == STORE_PENDING); if (flags & FILTER_ABORT) { /* the filter chain is aborting the request. Discard any attached data. and @@ -1051,7 +1051,7 @@ MemObject *mem = e->mem_obj; if (mem == NULL) return 0; - if (mem->data_hdr.head == NULL) + if (mem->data_hdr.list.head == NULL) return 0; return mem->inmem_lo == 0; } @@ -1150,9 +1150,9 @@ storeMemObjectDump(MemObject * mem) { debug(20, 1) ("MemObject->data.head: %p\n", - mem->data_hdr.head); + mem->data_hdr.list.head ? mem->data_hdr.list.head->data : NULL); debug(20, 1) ("MemObject->data.tail: %p\n", - mem->data_hdr.tail); + mem->data_hdr.list.tail ? mem->data_hdr.list.tail->data : NULL); debug(20, 1) ("MemObject->data.origin_offset: %d\n", mem->data_hdr.origin_offset); debug(20, 1) ("MemObject->start_ping: %d.%06d\n", Index: squid/src/store_swapout.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/store_swapout.c,v retrieving revision 1.1.1.3.4.1.4.8.4.2 retrieving revision 1.1.1.3.4.1.4.8.4.2.2.1 diff -u -r1.1.1.3.4.1.4.8.4.2 -r1.1.1.3.4.1.4.8.4.2.2.1 --- squid/src/store_swapout.c 31 Mar 2001 11:28:55 -0000 1.1.1.3.4.1.4.8.4.2 +++ squid/src/store_swapout.c 7 Aug 2001 13:18:34 -0000 1.1.1.3.4.1.4.8.4.2.2.1 @@ -1,6 +1,6 @@ /* - * $Id: store_swapout.c,v 1.1.1.3.4.1.4.8.4.2 2001/03/31 11:28:55 rbcollins Exp $ + * $Id: store_swapout.c,v 1.1.1.3.4.1.4.8.4.2.2.1 2001/08/07 13:18:34 adri Exp $ * * DEBUG: section 20 Storage Manager Swapout Functions * AUTHOR: Duane Wessels @@ -215,10 +215,16 @@ if (mem->swapout.memnode == NULL) { /* We need to swap out the first page */ - mem->swapout.memnode = mem->data_hdr.head; + assert(mem->data_hdr.list.head); + mem->swapout.memnode = mem->data_hdr.list.head->data; } else { /* We need to swap out the next page */ - mem->swapout.memnode = mem->swapout.memnode->next; + dlink_node *d; + d = mem->swapout.memnode->node.next; + if (d != NULL) + mem->swapout.memnode = d->data; + else + mem->swapout.memnode = NULL; } /* * Get the length of this buffer. We are assuming(!) that the buffer Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/structs.h,v retrieving revision 1.1.1.3.4.1.4.12.2.26.2.7 retrieving revision 1.1.1.3.4.1.4.12.2.26.2.8 diff -u -r1.1.1.3.4.1.4.12.2.26.2.7 -r1.1.1.3.4.1.4.12.2.26.2.8 --- squid/src/structs.h 13 May 2001 13:07:09 -0000 1.1.1.3.4.1.4.12.2.26.2.7 +++ squid/src/structs.h 7 Aug 2001 13:18:34 -0000 1.1.1.3.4.1.4.12.2.26.2.8 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.1.1.3.4.1.4.12.2.26.2.7 2001/05/13 13:07:09 rbcollins Exp $ + * $Id: structs.h,v 1.1.1.3.4.1.4.12.2.26.2.8 2001/08/07 13:18:34 adri Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -192,7 +192,7 @@ char rfc931[USER_IDENT_SZ]; auth_user_request_t *auth_user_request; acl_lookup_state lastcheckstate; - acl * lastcheckowner; + acl *lastcheckowner; #if SQUID_SNMP char *snmp_community; #endif @@ -236,7 +236,7 @@ dlink_node node; char *namestr; mod_t type; - MOD_INSTALL *install; + MOD_INSTALL *install; MOD_UNINSTALL *uninstall; }; @@ -251,7 +251,7 @@ ADDFILTER *Add; FILTERMKSTATE *MakeState; #if 0 - FILTERPARSE *Parse; + FILTERPARSE *Parse; #endif parserNameNode *ConfigParent; void *data; @@ -266,14 +266,14 @@ struct _FILTER_list { dlink_node node; - DATAFILTER * filter; - DATAFILTER_HDR * filter_hdr; + DATAFILTER *filter; + DATAFILTER_HDR *filter_hdr; REMOVEFILTER *Remove; void *data; }; struct _filterAccess { - filterAccess * next; + filterAccess *next; FILTER_instance *instance; acl_access *apply; }; @@ -571,7 +571,7 @@ struct _authSchemes { authScheme *schemes; int n_allocated; - int n_configured; + int n_configured; } authSchemes; struct { size_t list_width; @@ -753,7 +753,7 @@ DEFER *defer_check; /* check if we should defer read */ void *defer_data; CommWriteStateData *rwstate; /* State data for comm_write */ - CommReadStateData rstate; /* State data for comm_read */ + CommReadStateData rstate; /* State data for comm_read */ READ_HANDLER *read_method; WRITE_HANDLER *write_method; #if USE_SSL @@ -896,13 +896,11 @@ }; -typedef struct _TE_list -{ - int (*func)(char *ibuf, int ibufl, char **obuf, int *obufl, void **data); - void *data; - struct _TE_list *next; -} -TE_list; +typedef struct _TE_list { + int (*func) (char *ibuf, int ibufl, char **obuf, int *obufl, void **data); + void *data; + struct _TE_list *next; +} TE_list; struct _HttpReply { @@ -1050,9 +1048,9 @@ /* reply data filtering list */ dlink_list repfilters; FILTERREAD *clientread; - void * clientreaddata; + void *clientreaddata; FILTERREAD *serverread; - void * serverreaddata; + void *serverreaddata; /* Membuf for aggregating data to be written to the client */ MemBuf mb; @@ -1381,12 +1379,11 @@ struct _mem_node { char *data; int len; - mem_node *next; + dlink_node node; }; struct _mem_hdr { - mem_node *head; - mem_node *tail; + dlink_list list; int origin_offset; }; @@ -1615,7 +1612,7 @@ char *canonical; int link_count; /* free when zero */ request_flags flags; - ssize_t content_length; /* -1 means post no size known, 0 means no body/zero length body, >0 means known content_length */ + ssize_t content_length; /* -1 means post no size known, 0 means no body/zero length body, >0 means known content_length */ HttpHdrCc *cache_control; HttpHdrRange *range; http_version_t http_ver; @@ -1927,8 +1924,8 @@ /* filter data */ HttpReply *rep; clientHttpRequest *http; - dlink_list * filter_list; - FILTER_list * filters; + dlink_list *filter_list; + FILTER_list *filters; unsigned int filterflags; int client_fd; StoreEntry *entry;