#
# Makefile for the Squid Object Cache server
#
-# $Id: Makefile.in,v 1.75 1997/06/16 22:01:42 wessels Exp $
+# $Id: Makefile.in,v 1.76 1997/06/17 03:03:19 wessels Exp $
#
# Uncomment and customize the following to suit your needs:
#
aiops.o \
async_io.o \
cache_cf.o \
+ callback.o \
client_db.o \
client_side.o \
comm.o \
/*
- * $Id: acl.cc,v 1.97 1997/06/16 22:01:43 wessels Exp $
+ * $Id: acl.cc,v 1.98 1997/06/17 03:03:20 wessels Exp $
*
* DEBUG: section 28 Access Control
* AUTHOR: Duane Wessels
checklist->state[ACL_DST_IP] = ACL_LOOKUP_PENDING;
ipcache_nbgethostbyname(checklist->request->host,
aclLookupDstIPDone,
- checklist);
+ checklist,
+ &checklist->cbm_list);
return;
} else if (checklist->state[ACL_SRC_DOMAIN] == ACL_LOOKUP_NEEDED) {
checklist->state[ACL_SRC_DOMAIN] = ACL_LOOKUP_PENDING;
fqdncacheUnregister(checklist->src_addr, checklist);
if (checklist->state[ACL_DST_DOMAIN] == ACL_LOOKUP_PENDING)
fqdncacheUnregister(checklist->dst_addr, checklist);
- if (checklist->state[ACL_DST_IP] == ACL_LOOKUP_PENDING)
- ipcacheUnregister(checklist->request->host, checklist);
requestUnlink(checklist->request);
+ callbackUnlinkList(checklist->cbm_list);
xfree(checklist);
}
/*
- * $Id: comm.cc,v 1.162 1997/06/16 22:01:44 wessels Exp $
+ * $Id: comm.cc,v 1.163 1997/06/17 03:03:21 wessels Exp $
*
* DEBUG: section 5 Socket Functions
* AUTHOR: Harvest Derived
struct in_addr in_addr;
int locks;
int fd;
+ callback_meta *cbm_list;
} ConnectStateData;
/* GLOBAL */
cs->data = data;
comm_add_close_handler(fd, commConnectFree, cs);
cs->locks++;
- ipcache_nbgethostbyname(host, commConnectDnsHandle, cs);
+ ipcache_nbgethostbyname(host, commConnectDnsHandle, cs, &cs->cbm_list);
}
static void
commConnectFree(int fdunused, void *data)
{
ConnectStateData *cs = data;
- if (cs->locks)
- ipcacheUnregister(cs->host, cs);
+ callbackUnlinkList(cs->cbm_list);
xfree(cs->host);
xfree(cs);
}
cs->S.sin_addr.s_addr = 0;
ipcacheCycleAddr(cs->host);
cs->locks++;
- ipcache_nbgethostbyname(cs->host, commConnectDnsHandle, cs);
+ ipcache_nbgethostbyname(cs->host, commConnectDnsHandle, cs, &cs->cbm_list);
} else {
ipcacheRemoveBadAddr(cs->host, cs->S.sin_addr);
commConnectCallback(cs, COMM_ERR_CONNECT);
/*
- * $Id: ipcache.cc,v 1.121 1997/06/16 22:01:48 wessels Exp $
+ * $Id: ipcache.cc,v 1.122 1997/06/17 03:03:22 wessels Exp $
*
* DEBUG: section 14 IP Cache
* AUTHOR: Harvest Derived
struct _ip_pending {
IPH *handler;
- void *handlerData;
+ callback_meta *cbm;
struct _ip_pending *next;
};
static ipcache_entry *ipcache_get _PARAMS((const char *));
static IPH dummy_handler;
static int ipcacheExpiredEntry _PARAMS((ipcache_entry *));
-static void ipcacheAddPending _PARAMS((ipcache_entry *, IPH *, void *));
+static void ipcacheAddPending _PARAMS((ipcache_entry *, IPH *, void *, callback_meta **));
static void ipcacheEnqueue _PARAMS((ipcache_entry *));
static void *ipcacheDequeue _PARAMS((void));
static void ipcache_dnsDispatch _PARAMS((dnsserver_t *, ipcache_entry *));
static void ipcacheLockEntry _PARAMS((ipcache_entry *));
static void ipcacheNudgeQueue _PARAMS((void));
static void ipcacheChangeKey _PARAMS((ipcache_entry * i));
+static UNREG ipcacheUnregister;
static ipcache_addrs static_addrs;
static HashID ip_table = 0;
ipcache_release(ipcache_entry * i)
{
hash_link *table_entry = NULL;
-
if ((table_entry = hash_lookup(ip_table, i->name)) == NULL) {
debug(14, 0) ("ipcache_release: Could not find key '%s'\n", i->name);
return;
}
- if (i != (ipcache_entry *) table_entry)
- fatal_dump("ipcache_release: i != table_entry!");
+ assert (i == (ipcache_entry *) table_entry);
if (i->locks) {
i->expires = squid_curtime;
ipcacheChangeKey(i);
{
struct _ip_pending *p = NULL;
int nhandler = 0;
-
+ void *handlerData;
i->lastref = squid_curtime;
-
ipcacheLockEntry(i);
while (i->pending_head != NULL) {
p = i->pending_head;
i->pending_head = p->next;
- if (p->handler) {
+ handlerData = callbackCheck(p->cbm);
+ if (p->handler && handlerData) {
nhandler++;
dns_error_message = i->error_message;
- p->handler(i->status == IP_CACHED ? &i->addrs : NULL,
- p->handlerData);
+ p->handler(i->status == IP_CACHED ? &i->addrs : NULL, handlerData);
}
+ callbackUnlink(p->cbm);
safe_free(p);
}
i->pending_head = NULL; /* nuke list */
}
static void
-ipcacheAddPending(ipcache_entry * i, IPH * handler, void *handlerData)
+ipcacheAddPending(ipcache_entry * i, IPH * handler, void *handlerData, callback_meta **head)
{
struct _ip_pending *pending = xcalloc(1, sizeof(struct _ip_pending));
struct _ip_pending **I = NULL;
i->lastref = squid_curtime;
pending->handler = handler;
- pending->handlerData = handlerData;
+ pending->cbm = callbackRegister(handlerData, ipcacheUnregister, pending, head);
for (I = &(i->pending_head); *I; I = &((*I)->next));
*I = pending;
if (i->status == IP_PENDING)
}
void
-ipcache_nbgethostbyname(const char *name, IPH * handler, void *handlerData)
+ipcache_nbgethostbyname(const char *name, IPH * handler, void *handlerData, callback_meta **cbmhead)
{
ipcache_entry *i = NULL;
dnsserver_t *dnsData = NULL;
debug(14, 5) ("ipcache_nbgethostbyname: MISS for '%s'\n", name);
IpcacheStats.misses++;
i = ipcacheAddNew(name, NULL, IP_PENDING);
- ipcacheAddPending(i, handler, handlerData);
+ ipcacheAddPending(i, handler, handlerData, cbmhead);
} else if (i->status == IP_CACHED || i->status == IP_NEGATIVE_CACHED) {
/* HIT */
debug(14, 4) ("ipcache_nbgethostbyname: HIT for '%s'\n", name);
IpcacheStats.negative_hits++;
else
IpcacheStats.hits++;
- ipcacheAddPending(i, handler, handlerData);
+ ipcacheAddPending(i, handler, handlerData, cbmhead);
ipcache_call_pending(i);
return;
} else if (i->status == IP_PENDING || i->status == IP_DISPATCHED) {
debug(14, 4) ("ipcache_nbgethostbyname: PENDING for '%s'\n", name);
IpcacheStats.pending_hits++;
- ipcacheAddPending(i, handler, handlerData);
+ ipcacheAddPending(i, handler, handlerData, cbmhead);
if (squid_curtime - i->expires > 600) {
debug(14, 0) ("ipcache_nbgethostbyname: '%s' PENDING for %d seconds, aborting\n", name, squid_curtime + Config.negativeDnsTtl - i->expires);
ipcacheChangeKey(i);
(float) Config.ipcache.low) / (float) 100);
}
-/* clean up the pending entries in dnsserver */
-/* return 1 if we found the host, 0 otherwise */
-int
-ipcacheUnregister(const char *name, void *data)
+static void
+ipcacheUnregister(void *data)
{
- ipcache_entry *i = NULL;
- struct _ip_pending *p = NULL;
- int n = 0;
- debug(14, 3) ("ipcacheUnregister: FD %d, name '%s'\n", name);
- if ((i = ipcache_get(name)) == NULL)
- return 0;
- if (i->status == IP_PENDING || i->status == IP_DISPATCHED) {
- for (p = i->pending_head; p; p = p->next) {
- if (p->handlerData != data)
- continue;
- p->handler = NULL;
- n++;
- }
- }
- if (n == 0)
- debug_trap("ipcacheUnregister: callback data not found");
- debug(14, 3) ("ipcacheUnregister: unregistered %d handlers\n", n);
- return n;
+ struct _ip_pending *p = data;
+ p->handler = NULL;
+ debug(14, 3) ("ipcacheUnregister: unregistered something\n");
}
const ipcache_addrs *
}
}
if (flags & IP_LOOKUP_IF_MISS)
- ipcache_nbgethostbyname(name, dummy_handler, NULL);
+ ipcache_nbgethostbyname(name, dummy_handler, NULL, NULL);
return NULL;
}
/*
- * $Id: main.cc,v 1.153 1997/06/16 22:01:49 wessels Exp $
+ * $Id: main.cc,v 1.154 1997/06/17 03:03:23 wessels Exp $
*
* DEBUG: section 1 Startup and Main Loop
* AUTHOR: Harvest Derived
icpHandleUdp,
NULL, 0);
for (s = Config.mcast_group_list; s; s = s->next)
- ipcache_nbgethostbyname(s->key, mcastJoinGroups, NULL);
+ ipcache_nbgethostbyname(s->key, mcastJoinGroups, NULL, NULL);
debug(1, 1) ("Accepting ICP connections on port %d, FD %d.\n",
(int) port, theInIcpConnection);
/*
- * $Id: neighbors.cc,v 1.144 1997/06/16 22:01:50 wessels Exp $
+ * $Id: neighbors.cc,v 1.145 1997/06/17 03:03:24 wessels Exp $
*
* DEBUG: section 15 Neighbor Routines
* AUTHOR: Harvest Derived
safe_free(l->domain);
safe_free(l);
}
- if (p->ip_lookup_pending)
- ipcacheUnregister(p->host, p);
+ callbackUnlinkList(p->cbm_list);
safe_free(p->host);
safe_free(p);
}
peer *p = data;
struct sockaddr_in *ap;
int j;
- p->ip_lookup_pending = 0;
if (p->n_addresses == 0) {
debug(15, 1) ("Configuring %s %s/%d/%d\n", neighborTypeStr(p),
p->host, p->http_port, p->icp_port);
peer *next = Peers.peers_head;
while ((p = next)) {
next = p->next;
- p->ip_lookup_pending = 1;
/* some random, bogus FD for ipcache */
p->test_fd = Squid_MaxFD + current_time.tv_usec;
- ipcache_nbgethostbyname(p->host, peerDNSConfigure, p);
+ ipcache_nbgethostbyname(p->host, peerDNSConfigure, p, &p->cbm_list);
}
/* Reconfigure the peers every hour */
eventAdd("peerRefreshDNS", peerRefreshDNS, NULL, 3600);
0, COMM_NONBLOCKING, p->host);
if (fd < 0)
return;
- p->ip_lookup_pending = 1;
p->test_fd = fd;
- ipcache_nbgethostbyname(p->host, peerCheckConnect2, p);
+ ipcache_nbgethostbyname(p->host, peerCheckConnect2, p, &p->cbm_list);
}
static void
peerCheckConnect2(const ipcache_addrs * ia, void *data)
{
peer *p = data;
- p->ip_lookup_pending = 0;
commConnectStart(p->test_fd,
p->host,
p->http_port,
/*
- * $Id: net_db.cc,v 1.39 1997/06/04 07:00:32 wessels Exp $
+ * $Id: net_db.cc,v 1.40 1997/06/17 03:03:25 wessels Exp $
*
* DEBUG: section 37 Network Measurement Database
* AUTHOR: Duane Wessels
}
static void
-netdbSendPing(int fdunused, const ipcache_addrs * ia, void *data)
+netdbSendPing(const ipcache_addrs * ia, void *data)
{
struct in_addr addr;
char *hostname = data;
if (n->next_ping_time > squid_curtime)
return;
ipcache_nbgethostbyname(hostname,
- -1,
netdbSendPing,
- (void *) xstrdup(hostname));
+ (void *) xstrdup(hostname),
+ NULL);
#endif
}
/*
- * $Id: send-announce.cc,v 1.37 1997/06/16 22:01:51 wessels Exp $
+ * $Id: send-announce.cc,v 1.38 1997/06/17 03:03:26 wessels Exp $
*
* DEBUG: section 27 Cache Announcer
* AUTHOR: Duane Wessels
{
if (!Config.Announce.on)
return;
- ipcache_nbgethostbyname(Config.Announce.host, send_announce, NULL);
+ ipcache_nbgethostbyname(Config.Announce.host, send_announce, NULL, NULL);
eventAdd("send_announce", start_announce, NULL, Config.Announce.rate);
}
/*
- * $Id: squid.h,v 1.120 1997/06/16 22:01:52 wessels Exp $
+ * $Id: squid.h,v 1.121 1997/06/17 03:03:26 wessels Exp $
*
* AUTHOR: Duane Wessels
*
#include "cache_cf.h"
#include "fd.h"
+#include "callback.h"
#include "comm.h"
#include "disk.h"
#include "debug.h"