--------------------- PatchSet 10186 Date: 2007/12/02 02:01:33 Author: adri Branch: s27_adri Tag: (none) Log: Begin shuffling code which may want to be: * used in other binaries! * tested separately from the rest of the codebase. The first thing to shuffle out is the dlink stuff (not complete yet!) and the debugging core (again, not complete!) The debug code still lives in src/ and will do until I've written a couple of "registration" routines so other "things" can register to receive debugging messages. The context code relies on the debugging code to print out messages - the debugging code currently relies on the context code to potentially print out context. Its an unfortunate cyclic dependency but not one thats important to fix at the present time. Members: Makefile.am:1.20->1.20.36.1 configure.in:1.184.2.1->1.184.2.1.4.1 libcore/Makefile.am:1.1->1.1.2.1 libcore/ctx.c:1.1->1.1.2.1 libcore/ctx.h:1.1->1.1.2.1 libcore/debug.c:1.1->1.1.2.1 libcore/debug.h:1.1->1.1.2.1 libcore/tools.c:1.1->1.1.2.1 libcore/tools.h:1.1->1.1.2.1 src/Makefile.am:1.54.2.1->1.54.2.1.4.1 src/debug.c:1.19->1.19.8.1 src/defines.h:1.43->1.43.8.1 src/globals.h:1.31->1.31.8.1 src/protos.h:1.146.2.4->1.146.2.4.4.1 src/squid.h:1.36->1.36.24.1 src/structs.h:1.158.2.5->1.158.2.5.4.1 src/tools.c:1.62.2.3->1.62.2.3.4.1 src/typedefs.h:1.43.2.3->1.43.2.3.4.1 Index: squid/Makefile.am =================================================================== RCS file: /cvsroot/squid-sf//squid/Makefile.am,v retrieving revision 1.20 retrieving revision 1.20.36.1 diff -u -r1.20 -r1.20.36.1 --- squid/Makefile.am 2 Jun 2006 21:50:59 -0000 1.20 +++ squid/Makefile.am 2 Dec 2007 02:01:33 -0000 1.20.36.1 @@ -4,8 +4,8 @@ # AUTOMAKE_OPTIONS = dist-bzip2 subdir-objects 1.5 -DIST_SUBDIRS = lib snmplib scripts src icons errors contrib doc helpers tools -SUBDIRS = lib @makesnmplib@ scripts src icons errors doc helpers tools +DIST_SUBDIRS = lib libcore snmplib scripts src icons errors contrib doc helpers tools +SUBDIRS = lib libcore @makesnmplib@ scripts src icons errors doc helpers tools DISTCLEANFILES = include/stamp-h include/stamp-h[0-9]* DEFAULT_PINGER = $(libexecdir)/`echo pinger | sed '$(transform);s/$$/$(EXEEXT)/'` Index: squid/configure.in =================================================================== RCS file: /cvsroot/squid-sf//squid/configure.in,v retrieving revision 1.184.2.1 retrieving revision 1.184.2.1.4.1 diff -u -r1.184.2.1 -r1.184.2.1.4.1 --- squid/configure.in 27 Nov 2007 08:12:17 -0000 1.184.2.1 +++ squid/configure.in 2 Dec 2007 02:01:33 -0000 1.184.2.1.4.1 @@ -1,7 +1,7 @@ dnl dnl Configuration input file for Squid dnl -dnl $Id: configure.in,v 1.184.2.1 2007/11/27 08:12:17 adri Exp $ +dnl $Id: configure.in,v 1.184.2.1.4.1 2007/12/02 02:01:33 adri Exp $ dnl dnl dnl @@ -10,7 +10,7 @@ AM_CONFIG_HEADER(include/autoconf.h) AC_CONFIG_AUX_DIR(cfgaux) AM_INIT_AUTOMAKE -AC_REVISION($Revision: 1.184.2.1 $)dnl +AC_REVISION($Revision: 1.184.2.1.4.1 $)dnl AC_PREFIX_DEFAULT(/usr/local/squid) AM_MAINTAINER_MODE @@ -3173,6 +3173,7 @@ AC_OUTPUT([\ Makefile \ + libcore/Makefile \ lib/Makefile \ scripts/Makefile \ scripts/RunCache \ --- /dev/null Mon Dec 3 01:19:29 2007 +++ squid/libcore/Makefile.am Mon Dec 3 01:19:29 2007 @@ -0,0 +1,17 @@ +## Process this file with automake to produce Makefile.in +# +# $Id: Makefile.am,v 1.1.2.1 2007/12/02 02:01:33 adri Exp $ +# + +libcore_a_SOURCES = \ + tools.c \ + debug.c \ + ctx.c + +libcore_a_LIBADD = \ + tools.o \ + debug.o \ + ctx.o + +noinst_LIBRARIES = \ + libcore.a --- /dev/null Mon Dec 3 01:19:29 2007 +++ squid/libcore/ctx.c Mon Dec 3 01:19:29 2007 @@ -0,0 +1,165 @@ + + +#include "tools.h" +#include "ctx.h" +#include "debug.h" +#include "assert.h" + +int Ctx_Lock = 0; + +/* + * Context-based Debugging + * + * Rationale + * --------- + * + * When you have a long nested processing sequence, it is often impossible + * for low level routines to know in what larger context they operate. If a + * routine coredumps, one can restore the context using debugger trace. + * However, in many case you do not want to coredump, but just want to report + * a potential problem. A report maybe useless out of problem context. + * + * To solve this potential problem, use the following approach: + * + * int + * top_level_foo(const char *url) + * { + * // define current context + * // note: we stack but do not dup ctx descriptions! + * Ctx ctx = ctx_enter(url); + * ... + * // go down; middle_level_bar will eventually call bottom_level_boo + * middle_level_bar(method, protocol); + * ... + * // exit, clean after yourself + * ctx_exit(ctx); + * } + * + * void + * bottom_level_boo(int status, void *data) + * { + * // detect exceptional condition, and simply report it, the context + * // information will be available somewhere close in the log file + * if (status == STRANGE_STATUS) + * debug(13, 6) ("DOS attack detected, data: %p\n", data); + * ... + * } + * + * Current implementation is extremely simple but still very handy. It has a + * negligible overhead (descriptions are not duplicated). + * + * When the _first_ debug message for a given context is printed, it is + * prepended with the current context description. Context is printed with + * the same debugging level as the original message. + * + * Note that we do not print context every type you do ctx_enter(). This + * approach would produce too many useless messages. For the same reason, a + * context description is printed at most _once_ even if you have 10 + * debugging messages within one context. + * + * Contexts can be nested, of course. You must use ctx_enter() to enter a + * context (push it onto stack). It is probably safe to exit several nested + * contexts at _once_ by calling ctx_exit() at the top level (this will pop + * all context till current one). However, as in any stack, you cannot start + * in the middle. + * + * Analysis: + * i) locate debugging message, + * ii) locate current context by going _upstream_ in your log file, + * iii) hack away. + * + * + * To-Do: + * ----- + * + * decide if we want to dup() descriptions (adds overhead) but allows to + * add printf()-style interface + * + * implementation: + * --------------- + * + * descriptions for contexts over CTX_MAX_LEVEL limit are ignored, you probably + * have a bug if your nesting goes that deep. + */ + +#define CTX_MAX_LEVEL 255 + +/* + * produce a warning when nesting reaches this level and then double + * the level + */ +static int Ctx_Warn_Level = 32; +/* all descriptions has been printed up to this level */ +static int Ctx_Reported_Level = -1; +/* descriptions are still valid or active up to this level */ +static int Ctx_Valid_Level = -1; +/* current level, the number of nested ctx_enter() calls */ +static int Ctx_Current_Level = -1; +/* saved descriptions (stack) */ +static const char *Ctx_Descrs[CTX_MAX_LEVEL + 1]; +/* "safe" get secription */ +static const char *ctx_get_descr(Ctx ctx); + + +Ctx +ctx_enter(const char *descr) +{ + Ctx_Current_Level++; + + if (Ctx_Current_Level <= CTX_MAX_LEVEL) + Ctx_Descrs[Ctx_Current_Level] = descr; + + if (Ctx_Current_Level == Ctx_Warn_Level) { + debug(0, 0) ("# ctx: suspiciously deep (%d) nesting:\n", Ctx_Warn_Level); + Ctx_Warn_Level *= 2; + } + return Ctx_Current_Level; +} + +void +ctx_exit(Ctx ctx) +{ + assert(ctx >= 0); + Ctx_Current_Level = (ctx >= 0) ? ctx - 1 : -1; + if (Ctx_Valid_Level > Ctx_Current_Level) + Ctx_Valid_Level = Ctx_Current_Level; +} + +/* + * the idea id to print each context description at most once but provide enough + * info for deducing the current execution stack + */ +void +ctx_print(void) +{ + /* lock so _db_print will not call us recursively */ + Ctx_Lock++; + /* ok, user saw [0,Ctx_Reported_Level] descriptions */ + /* first inform about entries popped since user saw them */ + if (Ctx_Valid_Level < Ctx_Reported_Level) { + if (Ctx_Reported_Level != Ctx_Valid_Level + 1) + _db_print("ctx: exit levels from %2d down to %2d\n", + Ctx_Reported_Level, Ctx_Valid_Level + 1); + else + _db_print("ctx: exit level %2d\n", Ctx_Reported_Level); + Ctx_Reported_Level = Ctx_Valid_Level; + } + /* report new contexts that were pushed since last report */ + while (Ctx_Reported_Level < Ctx_Current_Level) { + Ctx_Reported_Level++; + Ctx_Valid_Level++; + _db_print("ctx: enter level %2d: '%s'\n", Ctx_Reported_Level, + ctx_get_descr(Ctx_Reported_Level)); + } + /* unlock */ + Ctx_Lock--; +} + +/* checks for nulls and overflows */ +static const char * +ctx_get_descr(Ctx ctx) +{ + if (ctx < 0 || ctx > CTX_MAX_LEVEL) + return ""; + return Ctx_Descrs[ctx] ? Ctx_Descrs[ctx] : ""; +} --- /dev/null Mon Dec 3 01:19:29 2007 +++ squid/libcore/ctx.h Mon Dec 3 01:19:29 2007 @@ -0,0 +1,11 @@ +#ifndef __LIBCORE_CTX_H__ +#define __LIBCORE_CTX_H__ + +typedef int Ctx; +extern int Ctx_Lock; + +extern void ctx_print(void); +extern Ctx ctx_enter(const char *descr); +extern void ctx_exit(Ctx ctx); + +#endif --- /dev/null Mon Dec 3 01:19:29 2007 +++ squid/libcore/debug.c Mon Dec 3 01:19:29 2007 @@ -0,0 +1,11 @@ +#include +#include +#include + + +#include "tools.h" +#include "debug.h" + +int debugLevels[MAX_DEBUG_SECTIONS]; +int _db_level; + --- /dev/null Mon Dec 3 01:19:29 2007 +++ squid/libcore/debug.h Mon Dec 3 01:19:29 2007 @@ -0,0 +1,20 @@ +#ifndef __LIBCORE_DEBUG_H__ +#define __LIBCORE_DEBUG_H__ + +#define MAX_DEBUG_SECTIONS 100 +extern int debugLevels[MAX_DEBUG_SECTIONS]; +extern int _db_level; + +#define do_debug(SECTION, LEVEL) \ + ((_db_level = (LEVEL)) <= debugLevels[SECTION]) +#define debug(SECTION, LEVEL) \ + !do_debug(SECTION, LEVEL) ? (void) 0 : _db_print + +#if STDC_HEADERS +extern void +_db_print(const char *,...) PRINTF_FORMAT_ARG1; +#else +extern void _db_print(); +#endif + +#endif /* __LIBCORE_DEBUG_H__ */ --- /dev/null Mon Dec 3 01:19:29 2007 +++ squid/libcore/tools.c Mon Dec 3 01:19:29 2007 @@ -0,0 +1,159 @@ +/* + * tools.c - Useful stuff, ripped from places .. + * + * Adrian Chadd + * + * $adrian: libraries/iapp/src/tools.c,v 1.3 2002/01/20 13:03:00 adrian Exp $ + */ + +#include +#include +#include + +#include "tools.h" + +/* + * frob some memory. debugging time. + * -- adrian + */ +void +mem_frob(void *data, int len) +{ + /* correct for Intel only! little endian */ + unsigned char b[4] = { 0xef, 0xbe, 0xad, 0xde }; + int i; + char *cdata = data; + for (i = 0; i < len; i++) { + *cdata = b[i % 4]; + cdata++; + } +} + +/* + * dlink_ routines are stolen from squid, except for dlinkAddBefore, + * which is mine. + * -- adrian + */ +void +dlinkAdd(void *data, dlink_node * m, dlink_list * list) +{ + m->data = data; + m->prev = NULL; + m->next = list->head; + if (list->head) + list->head->prev = m; + list->head = m; + if (list->tail == NULL) + list->tail = m; +} + +void +dlinkAddBefore(dlink_node *b, void *data, dlink_node *m, dlink_list *list) +{ + /* Shortcut - if its the first one, call dlinkAdd only */ + if (b == list->head) + dlinkAdd(data, m, list); + else { + m->data = data; + b->prev->next = m; + m->prev = b->prev; + b->prev = m; + m->next = b; + } +} + +void +dlinkAddTail(void *data, dlink_node *m, dlink_list *list) +{ + m->data = data; + m->next = NULL; + m->prev = list->tail; + if (list->tail) + list->tail->next = m; + list->tail = m; + if (list->head == NULL) + list->head = m; +} + +void +dlinkDelete(dlink_node *m, dlink_list *list) +{ + if (m->next) + m->next->prev = m->prev; + if (m->prev) + m->prev->next = m->next; + + if (m == list->head) + list->head = m->next; + if (m == list->tail) + list->tail = m->prev; + + m->next = m->prev = NULL; +} + + +/* + * dlink_list_length + * inputs - pointer to a dlink_list + * output - return the length (>=0) of a chain of links. + * side effects - + */ +extern int dlink_list_length(dlink_list *list) +{ + dlink_node *ptr; + int count = 0; + + for (ptr = list->head; ptr; ptr = ptr->next) + count++; + return count; +} + +/* + * dlinkFind + * inputs - list to search + * - data + * output - pointer to link or NULL if not found + * side effects - Look for ptr in the linked listed pointed to by link. + */ +dlink_node *dlinkFind(dlink_list *list, void * data ) +{ + dlink_node *ptr; + + for (ptr = list->head; ptr; ptr = ptr->next) + { + if (ptr->data == data) + return (ptr); + } + return (NULL); +} + +void +dlinkMoveList(dlink_list *from, dlink_list *to) +{ + /* There are three cases */ + /* case one, nothing in from list */ + + if(from->head == NULL) + return; + + /* case two, nothing in to list */ + /* actually if to->head is NULL and to->tail isn't, thats a bug */ + + if(to->head == NULL) { + to->head = from->head; + to->tail = from->tail; + from->head = from->tail = NULL; + return; + } + + /* third case play with the links */ + + from->tail->next = to->head; + from->head->prev = to->head->prev; + to->head->prev = from->tail; + to->head = from->head; + from->head = from->tail = NULL; + + /* I think I got that right */ +} + --- /dev/null Mon Dec 3 01:19:29 2007 +++ squid/libcore/tools.h Mon Dec 3 01:19:29 2007 @@ -0,0 +1,42 @@ +/* + * tools.h + * + * Definitions/prototypes for src/tools.c + * + * Adrian Chadd + * + * $Id: tools.h,v 1.1.2.1 2007/12/02 02:01:33 adri Exp $ + */ +#ifndef __LIBCORE_TOOLS_H__ +#define __LIBCORE_TOOLS_H__ + + +/* + * double-linked-list stuff + */ +typedef struct _dlink_node dlink_node; +typedef struct _dlink_list dlink_list; + +struct _dlink_node { + void *data; + dlink_node *prev; + dlink_node *next; + +}; + +struct _dlink_list { + dlink_node *head; + dlink_node *tail; +}; + +extern void dlinkAdd(void *data, dlink_node * m, dlink_list * list); +extern void dlinkAddBefore(dlink_node *b, void *data, dlink_node *m, dlink_list *list); +extern void dlinkAddTail(void *data, dlink_node *m, dlink_list *list); +extern void dlinkDelete(dlink_node *m, dlink_list *list); +extern void dlinkMoveList(dlink_list *from, dlink_list *to); +extern int dlink_list_length(dlink_list *m); +dlink_node * dlinkFind(dlink_list *m, void *data); + +void mem_frob(void *data, int len); + +#endif /* __LIBCORE_TOOLS_H__ */ Index: squid/src/Makefile.am =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Makefile.am,v retrieving revision 1.54.2.1 retrieving revision 1.54.2.1.4.1 diff -u -r1.54.2.1 -r1.54.2.1.4.1 --- squid/src/Makefile.am 27 Nov 2007 08:12:24 -0000 1.54.2.1 +++ squid/src/Makefile.am 2 Dec 2007 02:01:33 -0000 1.54.2.1.4.1 @@ -272,6 +272,7 @@ squid_LDADD = \ -L../lib \ + -L../libcore \ @XTRA_OBJS@ \ @REPL_OBJS@ \ @STORE_OBJS@ \ @@ -283,6 +284,7 @@ @SSLLIB@ \ @LIB_EPOLL@ \ -lmiscutil \ + -lcore \ @XTRA_LIBS@ \ $(MINGWEXLIB) @@ -320,7 +322,7 @@ data_DATA = \ mib.txt -LDADD = -L../lib -lmiscutil @XTRA_LIBS@ +LDADD = -L../lib -L../libcore -lcore -lmiscutil @XTRA_LIBS@ EXTRA_DIST = \ cf_gen_defines \ Index: squid/src/debug.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/debug.c,v retrieving revision 1.19 retrieving revision 1.19.8.1 diff -u -r1.19 -r1.19.8.1 --- squid/src/debug.c 24 Sep 2007 13:52:07 -0000 1.19 +++ squid/src/debug.c 2 Dec 2007 02:01:34 -0000 1.19.8.1 @@ -1,6 +1,6 @@ /* - * $Id: debug.c,v 1.19 2007/09/24 13:52:07 squidadm Exp $ + * $Id: debug.c,v 1.19.8.1 2007/12/02 02:01:34 adri Exp $ * * DEBUG: section 0 Debug Routines * AUTHOR: Harvest Derived @@ -36,9 +36,7 @@ #include "squid.h" static char *debug_log_file = NULL; -static int Ctx_Lock = 0; static const char *debugLogTime(time_t); -static void ctx_print(void); #if HAVE_SYSLOG static void _db_print_syslog(const char *format, va_list args); #endif @@ -505,159 +503,3 @@ abort(); } -/* - * Context-based Debugging - * - * Rationale - * --------- - * - * When you have a long nested processing sequence, it is often impossible - * for low level routines to know in what larger context they operate. If a - * routine coredumps, one can restore the context using debugger trace. - * However, in many case you do not want to coredump, but just want to report - * a potential problem. A report maybe useless out of problem context. - * - * To solve this potential problem, use the following approach: - * - * int - * top_level_foo(const char *url) - * { - * // define current context - * // note: we stack but do not dup ctx descriptions! - * Ctx ctx = ctx_enter(url); - * ... - * // go down; middle_level_bar will eventually call bottom_level_boo - * middle_level_bar(method, protocol); - * ... - * // exit, clean after yourself - * ctx_exit(ctx); - * } - * - * void - * bottom_level_boo(int status, void *data) - * { - * // detect exceptional condition, and simply report it, the context - * // information will be available somewhere close in the log file - * if (status == STRANGE_STATUS) - * debug(13, 6) ("DOS attack detected, data: %p\n", data); - * ... - * } - * - * Current implementation is extremely simple but still very handy. It has a - * negligible overhead (descriptions are not duplicated). - * - * When the _first_ debug message for a given context is printed, it is - * prepended with the current context description. Context is printed with - * the same debugging level as the original message. - * - * Note that we do not print context every type you do ctx_enter(). This - * approach would produce too many useless messages. For the same reason, a - * context description is printed at most _once_ even if you have 10 - * debugging messages within one context. - * - * Contexts can be nested, of course. You must use ctx_enter() to enter a - * context (push it onto stack). It is probably safe to exit several nested - * contexts at _once_ by calling ctx_exit() at the top level (this will pop - * all context till current one). However, as in any stack, you cannot start - * in the middle. - * - * Analysis: - * i) locate debugging message, - * ii) locate current context by going _upstream_ in your log file, - * iii) hack away. - * - * - * To-Do: - * ----- - * - * decide if we want to dup() descriptions (adds overhead) but allows to - * add printf()-style interface - * - * implementation: - * --------------- - * - * descriptions for contexts over CTX_MAX_LEVEL limit are ignored, you probably - * have a bug if your nesting goes that deep. - */ - -#define CTX_MAX_LEVEL 255 - -/* - * produce a warning when nesting reaches this level and then double - * the level - */ -static int Ctx_Warn_Level = 32; -/* all descriptions has been printed up to this level */ -static int Ctx_Reported_Level = -1; -/* descriptions are still valid or active up to this level */ -static int Ctx_Valid_Level = -1; -/* current level, the number of nested ctx_enter() calls */ -static int Ctx_Current_Level = -1; -/* saved descriptions (stack) */ -static const char *Ctx_Descrs[CTX_MAX_LEVEL + 1]; -/* "safe" get secription */ -static const char *ctx_get_descr(Ctx ctx); - - -Ctx -ctx_enter(const char *descr) -{ - Ctx_Current_Level++; - - if (Ctx_Current_Level <= CTX_MAX_LEVEL) - Ctx_Descrs[Ctx_Current_Level] = descr; - - if (Ctx_Current_Level == Ctx_Warn_Level) { - debug(0, 0) ("# ctx: suspiciously deep (%d) nesting:\n", Ctx_Warn_Level); - Ctx_Warn_Level *= 2; - } - return Ctx_Current_Level; -} - -void -ctx_exit(Ctx ctx) -{ - assert(ctx >= 0); - Ctx_Current_Level = (ctx >= 0) ? ctx - 1 : -1; - if (Ctx_Valid_Level > Ctx_Current_Level) - Ctx_Valid_Level = Ctx_Current_Level; -} - -/* - * the idea id to print each context description at most once but provide enough - * info for deducing the current execution stack - */ -static void -ctx_print(void) -{ - /* lock so _db_print will not call us recursively */ - Ctx_Lock++; - /* ok, user saw [0,Ctx_Reported_Level] descriptions */ - /* first inform about entries popped since user saw them */ - if (Ctx_Valid_Level < Ctx_Reported_Level) { - if (Ctx_Reported_Level != Ctx_Valid_Level + 1) - _db_print("ctx: exit levels from %2d down to %2d\n", - Ctx_Reported_Level, Ctx_Valid_Level + 1); - else - _db_print("ctx: exit level %2d\n", Ctx_Reported_Level); - Ctx_Reported_Level = Ctx_Valid_Level; - } - /* report new contexts that were pushed since last report */ - while (Ctx_Reported_Level < Ctx_Current_Level) { - Ctx_Reported_Level++; - Ctx_Valid_Level++; - _db_print("ctx: enter level %2d: '%s'\n", Ctx_Reported_Level, - ctx_get_descr(Ctx_Reported_Level)); - } - /* unlock */ - Ctx_Lock--; -} - -/* checks for nulls and overflows */ -static const char * -ctx_get_descr(Ctx ctx) -{ - if (ctx < 0 || ctx > CTX_MAX_LEVEL) - return ""; - return Ctx_Descrs[ctx] ? Ctx_Descrs[ctx] : ""; -} Index: squid/src/defines.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/defines.h,v retrieving revision 1.43 retrieving revision 1.43.8.1 diff -u -r1.43 -r1.43.8.1 --- squid/src/defines.h 24 Sep 2007 13:52:08 -0000 1.43 +++ squid/src/defines.h 2 Dec 2007 02:01:34 -0000 1.43.8.1 @@ -1,6 +1,6 @@ /* - * $Id: defines.h,v 1.43 2007/09/24 13:52:08 squidadm Exp $ + * $Id: defines.h,v 1.43.8.1 2007/12/02 02:01:34 adri Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -88,17 +88,11 @@ /* Select types. */ #define COMM_SELECT_READ (0x1) #define COMM_SELECT_WRITE (0x2) -#define MAX_DEBUG_SECTIONS 100 #define COMM_NONBLOCKING 0x01 #define COMM_NOCLOEXEC 0x02 #define COMM_REUSEADDR 0x04 -#define do_debug(SECTION, LEVEL) \ - ((_db_level = (LEVEL)) <= debugLevels[SECTION]) -#define debug(SECTION, LEVEL) \ - !do_debug(SECTION, LEVEL) ? (void) 0 : _db_print - #define safe_free(x) if (x) { xxfree(x); x = NULL; } #define DISK_OK (0) Index: squid/src/globals.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/globals.h,v retrieving revision 1.31 retrieving revision 1.31.8.1 diff -u -r1.31 -r1.31.8.1 --- squid/src/globals.h 24 Sep 2007 13:52:08 -0000 1.31 +++ squid/src/globals.h 2 Dec 2007 02:01:34 -0000 1.31.8.1 @@ -1,6 +1,6 @@ /* - * $Id: globals.h,v 1.31 2007/09/24 13:52:08 squidadm Exp $ + * $Id: globals.h,v 1.31.8.1 2007/12/02 02:01:34 adri Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -76,7 +76,6 @@ extern int RESERVED_FD; extern int Squid_MaxFD; /* SQUID_MAXFD */ extern int config_lineno; /* 0 */ -extern int debugLevels[MAX_DEBUG_SECTIONS]; extern int do_mallinfo; /* 0 */ extern int opt_reuseaddr; /* 1 */ extern int icmp_sock; /* -1 */ @@ -133,7 +132,6 @@ extern const String StringNull; /* { 0, 0, NULL } */ extern const MemBuf MemBufNull; /* MemBufNULL */ extern int hot_obj_count; /* 0 */ -extern int _db_level; extern const int CacheDigestHashFuncCount; /* 4 */ extern CacheDigest *store_digest; /* NULL */ extern const char *StoreDigestFileName; /* "store_digest" */ Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,v retrieving revision 1.146.2.4 retrieving revision 1.146.2.4.4.1 diff -u -r1.146.2.4 -r1.146.2.4.4.1 --- squid/src/protos.h 27 Nov 2007 08:12:28 -0000 1.146.2.4 +++ squid/src/protos.h 2 Dec 2007 02:01:34 -0000 1.146.2.4.4.1 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.146.2.4 2007/11/27 08:12:28 adri Exp $ + * $Id: protos.h,v 1.146.2.4.4.1 2007/12/02 02:01:34 adri Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -216,20 +216,10 @@ #endif -/* see debug.c for info on context-based debugging */ -extern Ctx ctx_enter(const char *descr); -extern void ctx_exit(Ctx ctx); - extern void _db_set_syslog(const char *facility); extern void _db_init(const char *logfile, const char *options); extern void _db_rotate_log(void); -#if STDC_HEADERS -extern void -_db_print(const char *,...) PRINTF_FORMAT_ARG1; -#else -extern void _db_print(); -#endif extern int debug_log_flush(void); extern void xassert(const char *, const char *, int); @@ -1202,9 +1192,6 @@ extern void asnFreeMemory(void); /* tools.c */ -extern void dlinkAdd(void *data, dlink_node *, dlink_list *); -extern void dlinkAddTail(void *data, dlink_node *, dlink_list *); -extern void dlinkDelete(dlink_node * m, dlink_list * list); extern void dlinkNodeDelete(dlink_node * m); extern dlink_node *dlinkNodeNew(void); Index: squid/src/squid.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/squid.h,v retrieving revision 1.36 retrieving revision 1.36.24.1 diff -u -r1.36 -r1.36.24.1 --- squid/src/squid.h 8 Sep 2006 19:50:59 -0000 1.36 +++ squid/src/squid.h 2 Dec 2007 02:01:34 -0000 1.36.24.1 @@ -1,6 +1,6 @@ /* - * $Id: squid.h,v 1.36 2006/09/08 19:50:59 squidadm Exp $ + * $Id: squid.h,v 1.36.24.1 2007/12/02 02:01:34 adri Exp $ * * AUTHOR: Duane Wessels * @@ -396,6 +396,11 @@ #include "ssl_support.h" #endif +/* libcore */ +#include "../libcore/tools.h" +#include "../libcore/debug.h" +#include "../libcore/ctx.h" + #include "Stack.h" /* Needed for poll() on Linux at least */ Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/structs.h,v retrieving revision 1.158.2.5 retrieving revision 1.158.2.5.4.1 diff -u -r1.158.2.5 -r1.158.2.5.4.1 --- squid/src/structs.h 27 Nov 2007 08:12:29 -0000 1.158.2.5 +++ squid/src/structs.h 2 Dec 2007 02:01:34 -0000 1.158.2.5.4.1 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.158.2.5 2007/11/27 08:12:29 adri Exp $ + * $Id: structs.h,v 1.158.2.5.4.1 2007/12/02 02:01:34 adri Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -39,17 +39,6 @@ #define PEER_MULTICAST_SIBLINGS 1 -struct _dlink_node { - void *data; - dlink_node *prev; - dlink_node *next; -}; - -struct _dlink_list { - dlink_node *head; - dlink_node *tail; -}; - #if USE_SSL struct _acl_cert_data { splayNode *values; Index: squid/src/tools.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/tools.c,v retrieving revision 1.62.2.3 retrieving revision 1.62.2.3.4.1 diff -u -r1.62.2.3 -r1.62.2.3.4.1 --- squid/src/tools.c 30 Nov 2007 16:42:26 -0000 1.62.2.3 +++ squid/src/tools.c 2 Dec 2007 02:01:35 -0000 1.62.2.3.4.1 @@ -1,6 +1,6 @@ /* - * $Id: tools.c,v 1.62.2.3 2007/11/30 16:42:26 adri Exp $ + * $Id: tools.c,v 1.62.2.3.4.1 2007/12/02 02:01:35 adri Exp $ * * DEBUG: section 21 Misc Functions * AUTHOR: Harvest Derived @@ -945,46 +945,6 @@ } void -dlinkAdd(void *data, dlink_node * m, dlink_list * list) -{ - m->data = data; - m->prev = NULL; - m->next = list->head; - if (list->head) - list->head->prev = m; - list->head = m; - if (list->tail == NULL) - list->tail = m; -} - -void -dlinkAddTail(void *data, dlink_node * m, dlink_list * list) -{ - m->data = data; - m->next = NULL; - m->prev = list->tail; - if (list->tail) - list->tail->next = m; - list->tail = m; - if (list->head == NULL) - list->head = m; -} - -void -dlinkDelete(dlink_node * m, dlink_list * list) -{ - if (m->next) - m->next->prev = m->prev; - if (m->prev) - m->prev->next = m->next; - if (m == list->head) - list->head = m->next; - if (m == list->tail) - list->tail = m->prev; - m->next = m->prev = NULL; -} - -void kb_incr(kb_t * k, squid_off_t v) { k->bytes += v; Index: squid/src/typedefs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/typedefs.h,v retrieving revision 1.43.2.3 retrieving revision 1.43.2.3.4.1 diff -u -r1.43.2.3 -r1.43.2.3.4.1 --- squid/src/typedefs.h 27 Nov 2007 08:12:29 -0000 1.43.2.3 +++ squid/src/typedefs.h 2 Dec 2007 02:01:35 -0000 1.43.2.3.4.1 @@ -1,6 +1,6 @@ /* - * $Id: typedefs.h,v 1.43.2.3 2007/11/27 08:12:29 adri Exp $ + * $Id: typedefs.h,v 1.43.2.3.4.1 2007/12/02 02:01:35 adri Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -191,8 +191,6 @@ typedef struct _refresh_cc refresh_cc; typedef struct _CommWriteStateData CommWriteStateData; typedef struct _ErrorState ErrorState; -typedef struct _dlink_node dlink_node; -typedef struct _dlink_list dlink_list; typedef struct _StatCounters StatCounters; typedef struct _tlv tlv; typedef struct _storeSwapLogData storeSwapLogData; @@ -382,9 +380,6 @@ /* MD5 cache keys */ typedef unsigned char cache_key; -/* context-based debugging, the actual type is subject to change */ -typedef int Ctx; - /* in case we want to change it later */ typedef int mb_size_t;