- changed storeDirCloseSwapLogs() to take a 'reopen' arg.
if not set, we don't reopen the logs for writing again.
- added FD_CLOSING flag to avoid recursive calls to comm_close().
- added 'non_peers' structure to keep stats on offendors, instead
of logging every bad reply.
/*
- * $Id: cache_cf.cc,v 1.222 1997/08/25 15:55:22 wessels Exp $
+ * $Id: cache_cf.cc,v 1.223 1997/08/25 22:35:50 wessels Exp $
*
* DEBUG: section 3 Configuration File Parsing
* AUTHOR: Harvest Derived
{
free_all();
}
-
-
/*
- * $Id: cachemgr.cc,v 1.58 1997/08/25 15:55:22 wessels Exp $
+ * $Id: cachemgr.cc,v 1.59 1997/08/25 22:35:51 wessels Exp $
*
* DEBUG: section 0 CGI Cache Manager
* AUTHOR: Harvest Derived
-
/*
- * $Id: client.cc,v 1.27 1997/08/25 03:52:18 wessels Exp $
+ * $Id: client.cc,v 1.28 1997/08/25 22:35:51 wessels Exp $
*
* DEBUG: section 0 WWW Client
* AUTHOR: Harvest Derived
/*
- * $Id: comm.cc,v 1.185 1997/08/10 06:34:27 wessels Exp $
+ * $Id: comm.cc,v 1.186 1997/08/25 22:35:52 wessels Exp $
*
* DEBUG: section 5 Socket Functions
* AUTHOR: Harvest Derived
#define min(x,y) ((x)<(y)? (x) : (y))
#define max(a,b) ((a)>(b)? (a) : (b))
-struct _cwstate {
- char *buf;
- long size;
- long offset;
- CWCB *handler;
- void *handler_data;
- void (*free) (void *);
-};
-
typedef struct {
char *host;
u_short port;
static struct timeval zero_tv;
-void
-commCancelWriteHandler(int fd)
-{
- CommWriteStateData *CommWriteState = fd_table[fd].rwstate;
- if (CommWriteState) {
- CommWriteState->handler = NULL;
- CommWriteState->handler_data = NULL;
- }
-}
-
static void
CommWriteStateCallbackAndFree(int fd, int code)
{
assert(fd >= 0);
assert(fd < Squid_MaxFD);
F = &fd_table[fd];
+ if (BIT_TEST(F->flags, FD_CLOSING))
+ return;
assert(F->open);
assert(F->type != FD_FILE);
+ BIT_SET(F->flags, FD_CLOSING);
CommWriteStateCallbackAndFree(fd, COMM_ERROR);
commCallCloseHandlers(fd);
if (F->uses) /* assume persistent connect count */
#else
close(fd);
#endif
- memset(F, '\0', sizeof(fde));
}
#define FD_CLOSE_REQUEST 0x02
#define FD_WRITE_DAEMON 0x04
#define FD_WRITE_PENDING 0x08
+#define FD_CLOSING 0x10
#define FD_DESC_SZ 64
MGR_REMOVE,
MGR_REPLY_HDRS,
MGR_SERVER_LIST,
+ MGR_NON_PEERS,
MGR_SHUTDOWN,
MGR_UTILIZATION,
MGR_VM_OBJECTS,
/*
- * $Id: errorpage.cc,v 1.68 1997/08/25 02:38:52 wessels Exp $
+ * $Id: errorpage.cc,v 1.69 1997/08/25 22:35:54 wessels Exp $
*
* DEBUG: section 4 Error Generation
* AUTHOR: Duane Wessels
}
if (p == NULL)
p = "<NULL>";
- debug(4, 1) ("errorConvert: %%%c --> '%s'\n", token, p);
+ debug(4, 3) ("errorConvert: %%%c --> '%s'\n", token, p);
return p;
}
/*
- * $Id: http.cc,v 1.184 1997/08/24 00:37:03 wessels Exp $
+ * $Id: http.cc,v 1.185 1997/08/25 22:35:55 wessels Exp $
*
* DEBUG: section 11 Hypertext Transfer Protocol (HTTP)
* AUTHOR: Harvest Derived
}
/* register the handler to free HTTP state data when the FD closes */
comm_add_close_handler(httpState->fd, httpStateFree, httpState);
+ storeRegisterAbort(entry, httpAbort, httpState);
return httpState;
}
if ((fd = httpSocketOpen(entry, NULL)) < 0)
return;
httpState = httpBuildState(fd, entry, request, e);
- storeRegisterAbort(entry, httpAbort, httpState);
commSetTimeout(httpState->fd,
Config.Timeout.connect,
httpTimeout,
/*
- * $Id: main.cc,v 1.172 1997/08/10 04:42:41 wessels Exp $
+ * $Id: main.cc,v 1.173 1997/08/25 22:35:57 wessels Exp $
*
* DEBUG: section 1 Startup and Main Loop
* AUTHOR: Harvest Derived
if (rotate_pending) {
icmpClose();
_db_rotate_log(); /* cache.log */
- storeWriteCleanLogs();
+ storeWriteCleanLogs(1);
storeRotateLog(); /* store.log */
accessLogRotate(); /* access.log */
useragentRotateLog(); /* useragent.log */
/*
- * $Id: neighbors.cc,v 1.158 1997/08/25 02:19:32 wessels Exp $
+ * $Id: neighbors.cc,v 1.159 1997/08/25 22:35:58 wessels Exp $
*
* DEBUG: section 15 Neighbor Routines
* AUTHOR: Harvest Derived
static void peerCountMcastPeersStart _PARAMS((void *data));
static void peerCountMcastPeersSchedule _PARAMS((peer * p, time_t when));
static IRCB peerCountHandleIcpReply;
+static void neighborIgnoreNonPeer _PARAMS((const struct sockaddr_in *, icp_opcode));
static icp_common_t echo_hdr;
static u_short echo_port;
char *
neighborTypeStr(const peer * p)
{
+ if (p->type == PEER_NONE)
+ return "Non-Peer";
if (p->type == PEER_SIBLING)
return "Sibling";
if (p->type == PEER_MULTICAST)
NLateReplies++;
}
+static peer *non_peers = NULL;
+
+static void
+neighborIgnoreNonPeer(const struct sockaddr_in *from, icp_opcode opcode)
+{
+ peer *np;
+ double x;
+ for (np = non_peers; np; np = np->next) {
+ if (np->in_addr.sin_addr.s_addr != from->sin_addr.s_addr)
+ continue;
+ if (np->in_addr.sin_port != from->sin_port)
+ continue;
+ break;
+ }
+ if (np == NULL) {
+ np = xcalloc(1, sizeof(peer));
+ np->in_addr.sin_addr = from->sin_addr;
+ np->in_addr.sin_port = from->sin_port;
+ np->icp_port = ntohl(from->sin_port);
+ np->type = PEER_NONE;
+ np->host = xstrdup(inet_ntoa(from->sin_addr));
+ np->next = non_peers;
+ non_peers = np;
+ }
+ np->stats.ignored_replies++;
+ np->stats.counts[opcode]++;
+ x = log(np->stats.ignored_replies) / log(10.0);
+ if (0.0 != x - (double) (int) x)
+ return;
+ debug(15, 1) ("WARNING: Ignored %d replies from non-peer %s\n",
+ np->stats.ignored_replies, np->host);
+}
+
+void
+neighborDumpNonPeers(StoreEntry * sentry)
+{
+ dump_peers(sentry, non_peers);
+}
+
/* ignoreMulticastReply
*
* We want to ignore replies from multicast peers if the
}
} else if (opcode == ICP_OP_MISS) {
if (p == NULL) {
- debug(15, 1) ("Ignoring MISS from non-peer %s\n",
- inet_ntoa(from->sin_addr));
+ neighborIgnoreNonPeer(from, opcode);
} else if (ntype != PEER_PARENT) {
(void) 0; /* ignore MISS from non-parent */
} else {
}
} else if (opcode == ICP_OP_HIT || opcode == ICP_OP_HIT_OBJ) {
if (p == NULL) {
- debug(15, 1) ("Ignoring HIT from non-peer %s\n",
- inet_ntoa(from->sin_addr));
+ neighborIgnoreNonPeer(from, opcode);
} else {
header->opcode = ICP_OP_HIT;
mem->icp_reply_callback(p, ntype, header, mem->ircb_data);
}
} else if (opcode == ICP_OP_DECHO) {
if (p == NULL) {
- debug(15, 1) ("Ignoring DECHO from non-peer %s\n",
- inet_ntoa(from->sin_addr));
+ neighborIgnoreNonPeer(from, opcode);
} else if (ntype == PEER_SIBLING) {
debug_trap("neighborsUdpAck: Found non-ICP cache as SIBLING\n");
debug_trap("neighborsUdpAck: non-ICP neighbors must be a PARENT\n");
}
} else if (opcode == ICP_OP_DENIED) {
if (p == NULL) {
- debug(15, 1) ("Ignoring DENIED from non-peer %s\n",
- inet_ntoa(from->sin_addr));
+ neighborIgnoreNonPeer(from, opcode);
} else if (p->stats.pings_acked > 100) {
if (100 * p->stats.counts[ICP_OP_DENIED] / p->stats.pings_acked > 95) {
debug(15, 0) ("95%% of replies from '%s' are UDP_DENIED\n", p->host);
void *handler_data,
FREE *));
extern void commCallCloseHandlers _PARAMS((int fd));
-extern void commCancelWriteHandler _PARAMS((int fd));
extern int commSetTimeout _PARAMS((int fd, int, PF *, void *));
extern void _db_init _PARAMS((const char *logfile, const char *options));
STCB * callback,
void *data));
extern int storePendingNClients _PARAMS((const StoreEntry *));
-extern int storeWriteCleanLogs _PARAMS((void));
+extern int storeWriteCleanLogs _PARAMS((int reopen));
extern HASHCMP urlcmp;
extern EVH storeMaintainSwapSpace;
extern void storeExpireNow _PARAMS((StoreEntry *));
extern OBJH log_enable;
extern OBJH info_get;
extern OBJH server_list;
+extern OBJH neighborDumpNonPeers;
extern OBJH dump_config;
extern OBJH storeDirStats;
extern OBJH pconnHistDump;
+extern void dump_peers _PARAMS((StoreEntry * sentry, peer * peers));
extern void pconnPush _PARAMS((int, const char *host, u_short port));
extern int pconnPop _PARAMS((const char *host, u_short port));
/*
- * $Id: stat.cc,v 1.155 1997/08/25 03:51:53 wessels Exp $
+ * $Id: stat.cc,v 1.156 1997/08/25 22:36:00 wessels Exp $
*
* DEBUG: section 18 Cache Manager Statistics
* AUTHOR: Harvest Derived
void
server_list(StoreEntry * sentry)
+{
+ dump_peers(sentry, Config.peers);
+}
+
+void
+dump_peers(StoreEntry * sentry, peer * peers)
{
peer *e = NULL;
struct _domain_ping *d = NULL;
icp_opcode op;
-
storeAppendPrintf(sentry, open_bracket);
-
- if (getFirstPeer() == NULL)
+ if (peers == NULL)
storeAppendPrintf(sentry, "{There are no neighbors installed.}\n");
- for (e = getFirstPeer(); e; e = getNextPeer(e)) {
- if (e->host == NULL)
- fatal_dump("Found an peer without a hostname!");
+ for (e = peers; e; e = e->next) {
+ assert(e->host != NULL);
storeAppendPrintf(sentry, "\n{%-11.11s: %s/%d/%d}\n",
neighborTypeStr(e),
e->host,
/*
- * $Id: store.cc,v 1.282 1997/08/25 05:29:58 wessels Exp $
+ * $Id: store.cc,v 1.283 1997/08/25 22:36:01 wessels Exp $
*
* DEBUG: section 20 Storeage Manager
* AUTHOR: Harvest Derived
} else if (e->mem_obj->e_current_len > Config.Store.maxObjectSize) {
debug(20, 2) ("storeCheckSwapable: NO: too big\n");
} else if (BIT_TEST(e->flag, KEY_PRIVATE)) {
- debug(20, 1) ("storeCheckSwapable: NO: private key\n");
+ debug(20, 3) ("storeCheckSwapable: NO: private key\n");
} else {
return 1;
}
* Writes a "clean" swap log file from in-memory metadata.
*/
int
-storeWriteCleanLogs(void)
+storeWriteCleanLogs(int reopen)
{
StoreEntry *e = NULL;
int *fd;
}
}
storeDirCloseSwapLogs();
- storeDirOpenSwapLogs();
+ if (reopen)
+ storeDirOpenSwapLogs();
stop = squid_curtime;
r = stop - start;
debug(20, 1) (" Finished. Wrote %d lines.\n", n);
void (*free) (void *);
};
-
struct _fde {
unsigned int type;
unsigned int open;
/*
- * $Id: tools.cc,v 1.119 1997/08/25 15:55:25 wessels Exp $
+ * $Id: tools.cc,v 1.120 1997/08/25 22:36:03 wessels Exp $
*
* DEBUG: section 21 Misc Functions
* AUTHOR: Harvest Derived
signal(sig, SIG_DFL);
#endif
releaseServerSockets();
- storeWriteCleanLogs();
+ storeWriteCleanLogs(0);
PrintRusage();
dumpMallocStats();
if (squid_curtime - SQUID_RELEASE_TIME < 864000) {
}
releaseServerSockets();
unlinkdClose();
- storeWriteCleanLogs();
+ storeWriteCleanLogs(0);
PrintRusage();
dumpMallocStats();
storeCloseLog();
* used in early initialization phases, long before we ever
* get to the store log. */
if (!store_rebuilding)
- storeWriteCleanLogs();
+ storeWriteCleanLogs(0);
fatal_common(message);
exit(1);
}
if (message)
fatal_common(message);
if (opt_catch_signals)
- storeWriteCleanLogs();
+ storeWriteCleanLogs(0);
abort();
}