From: robertc <> Date: Fri, 17 Oct 2003 03:40:16 +0000 (+0000) Subject: Move HierarchyLogEntry, all depended classes, and their dependents out of structs... X-Git-Tag: SQUID_3_0_PRE4~1185 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b24880fe399d60b710b71b49cb75134f0a58882d;p=thirdparty%2Fsquid.git Move HierarchyLogEntry, all depended classes, and their dependents out of structs, assigning constructors. Ensure that ps_state objects created will use the constructor --- diff --git a/src/AccessLogEntry.h b/src/AccessLogEntry.h index 3baf4e3502..0cd23a7c5e 100644 --- a/src/AccessLogEntry.h +++ b/src/AccessLogEntry.h @@ -1,6 +1,6 @@ /* - * $Id: AccessLogEntry.h,v 1.2 2003/09/04 11:54:23 hno Exp $ + * $Id: AccessLogEntry.h,v 1.3 2003/10/16 21:40:16 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -36,6 +36,7 @@ #define SQUID_HTTPACCESSLOGENTRY_H #include "HttpVersion.h" +#include "HierarchyLogEntry.h" class AccessLogEntry { diff --git a/src/HierarchyLogEntry.h b/src/HierarchyLogEntry.h new file mode 100644 index 0000000000..31f005752c --- /dev/null +++ b/src/HierarchyLogEntry.h @@ -0,0 +1,60 @@ + +/* + * $Id: HierarchyLogEntry.h,v 1.1 2003/10/16 21:40:16 robertc Exp $ + * + * + * SQUID Web Proxy Cache http://www.squid-cache.org/ + * ---------------------------------------------------------- + * + * Squid is the result of efforts by numerous individuals from + * the Internet community; see the CONTRIBUTORS file for full + * details. Many organizations have provided support for Squid's + * development; see the SPONSORS file for full details. Squid is + * Copyrighted (C) 2001 by the Regents of the University of + * California; see the COPYRIGHT file for full details. Squid + * incorporates software developed and/or copyrighted by other + * sources; see the CREDITS file for full details. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. + * + * Copyright (c) 2003, Robert Collins + */ + +#ifndef SQUID_HTTPHIERARCHYLOGENTRY_H +#define SQUID_HTTPHIERARCHYLOGENTRY_H + +#include "PingData.h" + +class HierarchyLogEntry +{ + +public: + HierarchyLogEntry(); + hier_code code; + char host[SQUIDHOSTNAMELEN]; + ping_data ping; + char cd_host[SQUIDHOSTNAMELEN]; /* the host of selected by cd peer */ + lookup_t cd_lookup; /* cd prediction: none, miss, hit */ + int n_choices; /* #peers we selected from (cd only) */ + int n_ichoices; /* #peers with known rtt we selected from (cd only) */ + + struct timeval peer_select_start; + + struct timeval store_complete_stop; +}; + +extern void hierarchyNote(HierarchyLogEntry *, hier_code, const char *); + +#endif /* SQUID_HTTPHIERARCHYLOGENTRY_H */ diff --git a/src/HttpRequest.h b/src/HttpRequest.h index bc3333e8a7..1e42c7d33b 100644 --- a/src/HttpRequest.h +++ b/src/HttpRequest.h @@ -1,6 +1,6 @@ /* - * $Id: HttpRequest.h,v 1.8 2003/09/01 03:49:37 robertc Exp $ + * $Id: HttpRequest.h,v 1.9 2003/10/16 21:40:17 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -38,6 +38,7 @@ #include "HttpHeader.h" #include "client_side.h" #include "HttpVersion.h" +#include "HierarchyLogEntry.h" /* Http Request */ extern HttpRequest *requestCreate(method_t, protocol_t, const char *urlpath); diff --git a/src/Makefile.am b/src/Makefile.am index 10d4ff1ecf..0aca024fbf 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,7 +1,7 @@ # # Makefile for the Squid Object Cache server # -# $Id: Makefile.am,v 1.90 2003/09/01 03:49:37 robertc Exp $ +# $Id: Makefile.am,v 1.91 2003/10/16 21:40:17 robertc Exp $ # # Uncomment and customize the following to suit your needs: # @@ -352,6 +352,7 @@ squid_SOURCES = \ gopher.cc \ helper.cc \ helper.h \ + HierarchyLogEntry.h \ $(HTCPSOURCE) \ http.cc \ http.h \ @@ -404,6 +405,8 @@ squid_SOURCES = \ pconn.cc \ peer_digest.cc \ peer_select.cc \ + PeerSelectState.h \ + PingData.h \ protos.h \ redirect.cc \ referer.cc \ diff --git a/src/PeerSelectState.h b/src/PeerSelectState.h new file mode 100644 index 0000000000..9002a0406b --- /dev/null +++ b/src/PeerSelectState.h @@ -0,0 +1,82 @@ + +/* + * $Id: PeerSelectState.h,v 1.1 2003/10/16 21:40:16 robertc Exp $ + * + * AUTHOR: Robert Collins + * + * SQUID Web Proxy Cache http://www.squid-cache.org/ + * ---------------------------------------------------------- + * + * Squid is the result of efforts by numerous individuals from + * the Internet community; see the CONTRIBUTORS file for full + * details. Many organizations have provided support for Squid's + * development; see the SPONSORS file for full details. Squid is + * Copyrighted (C) 2001 by the Regents of the University of + * California; see the COPYRIGHT file for full details. Squid + * incorporates software developed and/or copyrighted by other + * sources; see the CREDITS file for full details. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. + * + * Copyright (c) 2003, Robert Collins + */ + +#ifndef SQUID_PEERSELECTSTATE_H +#define SQUID_PEERSELECTSTATE_H + +#include "PingData.h" + +class ps_state +{ + +public: + void *operator new(size_t); + ps_state(); + HttpRequest *request; + StoreEntry *entry; + int always_direct; + int never_direct; + int direct; + PSC *callback; + void *callback_data; + FwdServer *servers; + /* + * Why are these struct sockaddr_in instead of peer *? Because a + * peer structure can become invalid during the peer selection + * phase, specifically after a reconfigure. Thus we need to lookup + * the peer * based on the address when we are finally ready to + * reference the peer structure. + */ + + struct sockaddr_in first_parent_miss; + + struct sockaddr_in closest_parent_miss; + /* + * ->hit and ->secho can be peer* because they should only be + * accessed during the thread when they are set + */ + peer *hit; + peer_t hit_type; +#if ALLOW_SOURCE_PING + + peer *secho; +#endif + + ping_data ping; + ACLChecklist *acl_checklist; +}; + + +#endif /* SQUID_PEERSELECTSTATE_H */ diff --git a/src/PingData.h b/src/PingData.h new file mode 100644 index 0000000000..ea5b99e358 --- /dev/null +++ b/src/PingData.h @@ -0,0 +1,56 @@ + +/* + * $Id: PingData.h,v 1.1 2003/10/16 21:40:16 robertc Exp $ + * + * + * SQUID Web Proxy Cache http://www.squid-cache.org/ + * ---------------------------------------------------------- + * + * Squid is the result of efforts by numerous individuals from + * the Internet community; see the CONTRIBUTORS file for full + * details. Many organizations have provided support for Squid's + * development; see the SPONSORS file for full details. Squid is + * Copyrighted (C) 2001 by the Regents of the University of + * California; see the COPYRIGHT file for full details. Squid + * incorporates software developed and/or copyrighted by other + * sources; see the CREDITS file for full details. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. + * + * Copyright (c) 2003, Robert Collins + */ + +#ifndef SQUID_PINGDATA_H +#define SQUID_PINGDATA_H + +class ping_data +{ + +public: + ping_data(); + + struct timeval start; + + struct timeval stop; + int n_sent; + int n_recv; + int n_replies_expected; + int timeout; /* msec */ + int timedout; + int w_rtt; + int p_rtt; +}; + +#endif /* SQUID_PINGDATA_H */ diff --git a/src/access_log.cc b/src/access_log.cc index 5e6396ce84..b48798db47 100644 --- a/src/access_log.cc +++ b/src/access_log.cc @@ -1,6 +1,6 @@ /* - * $Id: access_log.cc,v 1.95 2003/09/01 03:49:37 robertc Exp $ + * $Id: access_log.cc,v 1.96 2003/10/16 21:40:16 robertc Exp $ * * DEBUG: section 46 Access Log * AUTHOR: Duane Wessels @@ -1454,6 +1454,22 @@ accessLogClose(void) #endif } +HierarchyLogEntry::HierarchyLogEntry() : + code(HIER_NONE), + cd_lookup(LOOKUP_NONE), + n_choices(0), + n_ichoices(0) +{ + memset(host, '\0', SQUIDHOSTNAMELEN); + memset(cd_host, '\0', SQUIDHOSTNAMELEN); + + peer_select_start.tv_sec =0; + peer_select_start.tv_usec =0; + + store_complete_stop.tv_sec =0; + store_complete_stop.tv_usec =0; +} + void hierarchyNote(HierarchyLogEntry * hl, hier_code code, diff --git a/src/cbdata.cc b/src/cbdata.cc index bf4832af21..727d599301 100644 --- a/src/cbdata.cc +++ b/src/cbdata.cc @@ -1,6 +1,6 @@ /* - * $Id: cbdata.cc,v 1.61 2003/10/08 21:21:14 robertc Exp $ + * $Id: cbdata.cc,v 1.62 2003/10/16 21:40:16 robertc Exp $ * * DEBUG: section 45 Callback Data Registry * ORIGINAL AUTHOR: Duane Wessels @@ -52,6 +52,9 @@ #endif #include "Generic.h" +/* XXX Remove me */ +#include "PeerSelectState.h" + static int cbdataCount = 0; #if CBDATA_DEBUG dlink_list cbdataEntries; diff --git a/src/neighbors.cc b/src/neighbors.cc index 535e066815..11c8227294 100644 --- a/src/neighbors.cc +++ b/src/neighbors.cc @@ -1,6 +1,6 @@ /* - * $Id: neighbors.cc,v 1.323 2003/09/21 00:30:47 robertc Exp $ + * $Id: neighbors.cc,v 1.324 2003/10/16 21:40:16 robertc Exp $ * * DEBUG: section 15 Neighbor Routines * AUTHOR: Harvest Derived @@ -40,6 +40,7 @@ #include "MemObject.h" #include "ACLChecklist.h" #include "htcp.h" +#include "PeerSelectState.h" /* count mcast group peers every 15 minutes */ #define MCAST_COUNT_RATE 900 @@ -1470,7 +1471,7 @@ peerCountMcastPeersStart(void *data) p->mcast.flags.count_event_pending = 0; snprintf(url, MAX_URL, "http://%s/", inet_ntoa(p->in_addr.sin_addr)); fake = storeCreateEntry(url, url, request_flags(), METHOD_GET); - psstate = cbdataAlloc(ps_state); + psstate = new ps_state; psstate->request = requestLink(urlParse(METHOD_GET, url)); psstate->entry = fake; psstate->callback = NULL; diff --git a/src/peer_select.cc b/src/peer_select.cc index e857a00e31..ce2a82a92b 100644 --- a/src/peer_select.cc +++ b/src/peer_select.cc @@ -1,6 +1,6 @@ /* - * $Id: peer_select.cc,v 1.131 2003/08/10 11:00:44 robertc Exp $ + * $Id: peer_select.cc,v 1.132 2003/10/16 21:40:16 robertc Exp $ * * DEBUG: section 44 Peer Selection Algorithm * AUTHOR: Duane Wessels @@ -34,6 +34,7 @@ */ #include "squid.h" +#include "PeerSelectState.h" #include "Store.h" #include "ICP.h" #include "HttpRequest.h" @@ -157,7 +158,7 @@ peerSelect(HttpRequest * request, else debug(44, 3) ("peerSelect: %s\n", RequestMethodStr[request->method]); - psstate = cbdataAlloc(ps_state); + psstate = new ps_state; psstate->request = requestLink(request); @@ -783,3 +784,44 @@ peerAddFwdServer(FwdServer ** FS, peer * p, hier_code code) *FS = fs; } + +void * +ps_state::operator new(size_t) +{ + return cbdataAlloc(ps_state); +} + +ps_state::ps_state() : request (NULL), + entry (NULL), + always_direct (0), + never_direct (0), + direct (0), + callback (NULL), + callback_data (NULL), + servers (NULL), + hit(NULL), + hit_type(PEER_NONE), +#if ALLOW_SOURCE_PING + + secho( NULL), +#endif + acl_checklist (NULL) +{ + memset(&first_parent_miss, '\0', sizeof(first_parent_miss)); + memset(&closest_parent_miss, '\0', sizeof(closest_parent_miss)); +} + +ping_data::ping_data() : + n_sent(0), + n_recv(0), + n_replies_expected(0), + timeout(0), + timedout(0), + w_rtt(0), + p_rtt(0) +{ + start.tv_sec = 0; + start.tv_usec = 0; + stop.tv_sec = 0; + stop.tv_usec = 0; +} diff --git a/src/protos.h b/src/protos.h index 41a389f599..7895c7de31 100644 --- a/src/protos.h +++ b/src/protos.h @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.492 2003/09/01 03:49:39 robertc Exp $ + * $Id: protos.h,v 1.493 2003/10/16 21:40:16 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -34,7 +34,6 @@ #ifndef SQUID_PROTOS_H #define SQUID_PROTOS_H -SQUIDCEXTERN void hierarchyNote(HierarchyLogEntry *, hier_code, const char *); #if FORW_VIA_DB SQUIDCEXTERN void fvdbCountVia(const char *key); SQUIDCEXTERN void fvdbCountForw(const char *key); diff --git a/src/structs.h b/src/structs.h index 2585aed8a3..c22c9c5fcb 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.482 2003/09/21 04:31:25 robertc Exp $ + * $Id: structs.h,v 1.483 2003/10/16 21:40:16 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -950,37 +950,6 @@ unsigned int originpeer: 1; }; -struct _ping_data -{ - - struct timeval start; - - struct timeval stop; - int n_sent; - int n_recv; - int n_replies_expected; - int timeout; /* msec */ - int timedout; - int w_rtt; - int p_rtt; -}; - -struct _HierarchyLogEntry -{ - hier_code code; - char host[SQUIDHOSTNAMELEN]; - ping_data ping; - char cd_host[SQUIDHOSTNAMELEN]; /* the host of selected by cd peer */ - lookup_t cd_lookup; /* cd prediction: none, miss, hit */ - int n_choices; /* #peers we selected from (cd only) */ - int n_ichoices; /* #peers with known rtt we selected from (cd only) */ - - struct timeval peer_select_start; - - struct timeval store_complete_stop; -}; - - struct _ipcache_addrs { @@ -1345,41 +1314,6 @@ struct _netdbEntry int n_peers; }; -struct _ps_state -{ - HttpRequest *request; - StoreEntry *entry; - int always_direct; - int never_direct; - int direct; - PSC *callback; - void *callback_data; - FwdServer *servers; - /* - * Why are these struct sockaddr_in instead of peer *? Because a - * peer structure can become invalid during the peer selection - * phase, specifically after a reconfigure. Thus we need to lookup - * the peer * based on the address when we are finally ready to - * reference the peer structure. - */ - - struct sockaddr_in first_parent_miss; - - struct sockaddr_in closest_parent_miss; - /* - * ->hit and ->secho can be peer* because they should only be - * accessed during the thread when they are set - */ - peer *hit; - peer_t hit_type; -#if ALLOW_SOURCE_PING - - peer *secho; -#endif - - ping_data ping; - ACLChecklist *acl_checklist; -}; #if USE_ICMP diff --git a/src/typedefs.h b/src/typedefs.h index 13395a6305..450b0f8f16 100644 --- a/src/typedefs.h +++ b/src/typedefs.h @@ -1,6 +1,6 @@ /* - * $Id: typedefs.h,v 1.170 2003/09/01 03:49:40 robertc Exp $ + * $Id: typedefs.h,v 1.171 2003/10/16 21:40:16 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -163,12 +163,6 @@ typedef struct _net_db_peer net_db_peer; typedef struct _netdbEntry netdbEntry; -typedef struct _ping_data ping_data; - -typedef struct _ps_state ps_state; - -typedef struct _HierarchyLogEntry HierarchyLogEntry; - typedef struct _pingerEchoData pingerEchoData; typedef struct _pingerReplyData pingerReplyData;