--------------------- PatchSet 2892 Date: 2001/08/28 23:42:58 Author: adri Branch: newhttp Tag: (none) Log: * add a comment at the top of refstring.c outlining some basics covering how this code is meant to work * pad out some more of the refstring code Note I've slightly changed direction here- since we're either referencing some offset into a shared buffer or a private buffer, why not just write all the manipulation routines to start at 'pos' in the refstring, and simply change pos to point to the offset in the shared string, or offset 0 into the private buffer? That'll save having to write logic to determine which string type we're using. Niiiifty. Now I just have to write it. And then when it all works, rewrite it to not be so damned slow. Members: src/refstring.c:1.1.2.2->1.1.2.3 src/structs.h:1.1.1.3.4.1.4.12.2.26.2.13->1.1.1.3.4.1.4.12.2.26.2.14 Index: squid/src/refstring.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/refstring.c,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -r1.1.2.2 -r1.1.2.3 --- squid/src/refstring.c 28 Aug 2001 23:08:30 -0000 1.1.2.2 +++ squid/src/refstring.c 28 Aug 2001 23:42:58 -0000 1.1.2.3 @@ -3,9 +3,20 @@ * * Adrian Chadd * - * $Id: refstring.c,v 1.1.2.2 2001/08/28 23:08:30 adri Exp $ + * $Id: refstring.c,v 1.1.2.3 2001/08/28 23:42:58 adri Exp $ */ + +/* + * a refstring is a string that references an stmem_ref . + * The stmem_ref can be a shared buffer, or private one that can be + * modified. + * + * the key to this is that the refstring_t.pos points to the string + * and offset where we start. In the case of a private buffer it points + * to position 0. This means all the manipulation routines can just + * work with the stuff inside the pos and all will work out fine. + */ #include "squid.h" @@ -26,12 +37,15 @@ rs->type = RS_BLANK; rs->len = NULL; + /* blank out the pos */ + bzero(&rs->pos, sizeof(stmem_ref_pos_t)); + /* If we have a read-only string position */ if (pos != NULL) { /* Set this string up to be a read-only string */ rs->type = RS_SHARED; rs->ro_string = st; - rs->ro_pos = *pos; + rs->pos = *pos; stmemRefRef(st); } @@ -65,6 +79,9 @@ /* Upgrade the string type to a rw string */ rs->type = RS_LOCAL; + + /* Point pos to the beginning of this string */ + stmem_ref_pos_set(&rs->pos, &rs->rw_string, 0); } @@ -98,13 +115,21 @@ * refstring_destroy - destroy a string */ void -refstring_destroy(refstring_t *st) +refstring_destroy(refstring_t *rs) { /* Assert the thing exists */ + assert(rs->type != RS_NONE); /* If we have a read-only string, unlock it */ - /* If we have a read-write string, free it */ + if (rs->ro_string) + stmemRefUnref(rs->ro_string); + + /* If we have a read-write string, unlock it */ + if (rs->type == RS_LOCAL) + stmemRefUnref(&rs->rw_string); + /* Mark string as dead */ + rs->type = RS_NONE; } 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.13 retrieving revision 1.1.1.3.4.1.4.12.2.26.2.14 diff -u -r1.1.1.3.4.1.4.12.2.26.2.13 -r1.1.1.3.4.1.4.12.2.26.2.14 --- squid/src/structs.h 28 Aug 2001 23:08:30 -0000 1.1.1.3.4.1.4.12.2.26.2.13 +++ squid/src/structs.h 28 Aug 2001 23:42:58 -0000 1.1.1.3.4.1.4.12.2.26.2.14 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.1.1.3.4.1.4.12.2.26.2.13 2001/08/28 23:08:30 adri Exp $ + * $Id: structs.h,v 1.1.1.3.4.1.4.12.2.26.2.14 2001/08/28 23:42:58 adri Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -2162,7 +2162,7 @@ */ struct _refstring { stmem_ref_t *ro_string; /* Pointer to a read-only string */ - stmem_ref_pos_t ro_pos; /* Where in which string we're in */ + stmem_ref_pos_t pos; /* Where in which string we're in */ stmem_ref_t rw_string; /* Local string, if we're using it */ refstring_type_t type; /* String type */ int len; /* String length */