From: wessels <> Date: Thu, 15 May 1997 12:55:44 +0000 (+0000) Subject: register icpHandleStore, not icpSendMoreData; requires lots of rearranging X-Git-Tag: SQUID_3_0_PRE1~5012 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f990ccccabae8e4c9d1f95d82dac3dc14b5a6073;p=thirdparty%2Fsquid.git register icpHandleStore, not icpSendMoreData; requires lots of rearranging --- diff --git a/src/client_side.cc b/src/client_side.cc index f6ed189818..7ff6c441dd 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -1,6 +1,6 @@ /* - * $Id: client_side.cc,v 1.102 1997/05/08 07:22:01 wessels Exp $ + * $Id: client_side.cc,v 1.103 1997/05/15 06:55:44 wessels Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -351,9 +351,9 @@ icpProcessExpired(int fd, void *data) entry->refcount++; /* EXPIRED CASE */ http->entry = entry; http->out.offset = 0; - /* Register with storage manager to receive updates when data comes in. */ - storeRegister(entry, fd, icpHandleIMSReply, http); protoDispatch(fd, http->entry, http->request); + /* Register with storage manager to receive updates when data comes in. */ + storeRegister(entry, icpHandleIMSReply, http, http->out.offset); } static int @@ -409,10 +409,7 @@ icpHandleIMSReply(void *data) } else if (mem->reply->code == 0) { debug(33, 3, "icpHandleIMSReply: Incomplete headers for '%s'\n", entry->url); - storeRegister(entry, - fd, - icpHandleIMSReply, - http); + storeRegister(entry, icpHandleIMSReply, http, http->out.offset); return; } else if (clientGetsOldEntry(entry, http->old_entry, http->request)) { /* We initiated the IMS request, the client is not expecting @@ -420,10 +417,7 @@ icpHandleIMSReply(void *data) * headers have been loaded from disk. */ oldentry = http->old_entry; if (oldentry->mem_obj->e_current_len == 0) { - storeRegister(entry, - fd, - icpHandleIMSReply, - http); + storeRegister(entry, icpHandleIMSReply, http, http->out.offset); return; } http->log_type = LOG_TCP_REFRESH_HIT; @@ -464,7 +458,7 @@ icpHandleIMSReply(void *data) storeUnlockObject(http->old_entry); } http->old_entry = NULL; /* done with old_entry */ - icpSendMoreData(fd, http); /* give data to the client */ + storeRegister(http->entry, icpHandleStore, http, http->out.offset); } int diff --git a/src/main.cc b/src/main.cc index 4637008c8f..7beec0601f 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,5 +1,5 @@ /* - * $Id: main.cc,v 1.145 1997/05/15 01:18:46 wessels Exp $ + * $Id: main.cc,v 1.146 1997/05/15 06:55:46 wessels Exp $ * * DEBUG: section 1 Startup and Main Loop * AUTHOR: Harvest Derived @@ -374,8 +374,8 @@ serverConnectionsOpen(void) icpHandleUdp, NULL, 0); comm_join_mcast_groups(theInIcpConnection); - debug(1, 1, "Accepting ICP connections on FD %d.\n", - theInIcpConnection); + debug(1, 1, "Accepting ICP connections on port %d, FD %d.\n", + (int) port, theInIcpConnection); if ((addr = Config.Addrs.udp_outgoing).s_addr != no_addr.s_addr) { enter_suid(); @@ -392,8 +392,8 @@ serverConnectionsOpen(void) COMM_SELECT_READ, icpHandleUdp, NULL, 0); - debug(1, 1, "Accepting ICP connections on FD %d.\n", - theOutIcpConnection); + debug(1, 1, "Accepting ICP connections on port %d, FD %d.\n", + (int) port, theInIcpConnection); fd_note(theOutIcpConnection, "Outgoing ICP socket"); fd_note(theInIcpConnection, "Incoming ICP socket"); } else { diff --git a/src/squid.h b/src/squid.h index 746aab3cd5..376f8c970b 100644 --- a/src/squid.h +++ b/src/squid.h @@ -1,6 +1,6 @@ /* - * $Id: squid.h,v 1.112 1997/05/15 01:18:48 wessels Exp $ + * $Id: squid.h,v 1.113 1997/05/15 06:55:49 wessels Exp $ * * AUTHOR: Duane Wessels * @@ -161,10 +161,14 @@ #if HAVE_GETOPT_H #include #endif - #if HAVE_POLL_H #include #endif +#if HAVE_ASSERT_H +#include +#else +#define assert(X) ((void)0) +#endif #ifdef __STDC__ #include @@ -264,6 +268,7 @@ typedef unsigned long u_num32; typedef void SIH _PARAMS((void *, int)); /* swap in */ typedef int QS _PARAMS((const void *, const void *)); /* qsort */ +typedef void STCB _PARAMS((void *)); /* store callback */ #include "cache_cf.h" #include "fd.h" diff --git a/src/ssl.cc b/src/ssl.cc index 74fb5be78d..d8d001e10a 100644 --- a/src/ssl.cc +++ b/src/ssl.cc @@ -1,6 +1,6 @@ /* - * $Id: ssl.cc,v 1.49 1997/05/08 07:22:07 wessels Exp $ + * $Id: ssl.cc,v 1.50 1997/05/15 06:55:49 wessels Exp $ * * DEBUG: section 26 Secure Sockets Layer Proxy * AUTHOR: Duane Wessels @@ -92,10 +92,7 @@ sslClientClosed(int fd, void *data) debug(26, 3, "sslClientClosed: FD %d\n", fd); /* we have been called from comm_close for the client side, so * just need to clean up the server side */ - protoUnregister(sslState->server.fd, - NULL, - sslState->request, - no_addr); + protoUnregister(NULL, sslState->request, no_addr); comm_close(sslState->server.fd); } diff --git a/src/store.cc b/src/store.cc index 95242f4469..1ff506ee5a 100644 --- a/src/store.cc +++ b/src/store.cc @@ -1,6 +1,6 @@ /* - * $Id: store.cc,v 1.233 1997/05/15 01:07:03 wessels Exp $ + * $Id: store.cc,v 1.234 1997/05/15 06:55:50 wessels Exp $ * * DEBUG: section 20 Storeage Manager * AUTHOR: Harvest Derived @@ -884,19 +884,26 @@ storeAddDiskRestore(const char *url, int file_number, int size, time_t expires, } /* Register interest in an object currently being retrieved. */ -int -storeRegister(StoreEntry * e, int fd, STCB * handler, void *data) +void +storeRegister(StoreEntry * e, STCB * callback, void *data, off_t offset) { int i; MemObject *mem = e->mem_obj; - debug(20, 3, "storeRegister: FD %d '%s'\n", fd, e->key); + struct _store_client *sc; + debug(20, 3, "storeRegister: '%s'\n", e->key); if ((i = storeClientListSearch(mem, data)) < 0) i = storeClientListAdd(e, data, 0); - if (mem->clients[i].callback) - fatal_dump("storeRegister: handler already exists"); - mem->clients[i].callback = handler; - mem->clients[i].callback_data = data; - return 0; + sc = &mem->clients[i]; + if (sc->callback) + fatal_dump("storeRegister: callback already exists"); + sc->offset = offset; + sc->callback = callback; + sc->callback_data = data; + if (offset < e->object_len) { + sc->callback = NULL; + /* Don't NULL the callback_data, its used to identify the client */ + callback(data); + } } int @@ -904,14 +911,16 @@ storeUnregister(StoreEntry * e, void *data) { int i; MemObject *mem = e->mem_obj; + struct _store_client *sc; if (mem == NULL) return 0; debug(20, 3, "storeUnregister: called for '%s'\n", e->key); if ((i = storeClientListSearch(mem, data)) < 0) return 0; - mem->clients[i].last_offset = 0; - mem->clients[i].callback = NULL; - mem->clients[i].callback_data = NULL; + sc = &mem->clients[i]; + sc->offset = 0; + sc->callback = NULL; + sc->callback_data = NULL; debug(20, 9, "storeUnregister: returning 1\n"); return 1; } @@ -925,8 +934,8 @@ storeGetLowestReaderOffset(const StoreEntry * entry) for (i = 0; i < mem->nclients; i++) { if (mem->clients[i].callback_data == NULL) continue; - if (mem->clients[i].last_offset < lowest) - lowest = mem->clients[i].last_offset; + if (mem->clients[i].offset < lowest) + lowest = mem->clients[i].offset; } return lowest; } @@ -2227,7 +2236,7 @@ storeClientListSearch(const MemObject * mem, void *data) /* add client with fd to client list */ int -storeClientListAdd(StoreEntry * e, void *data, int last_offset) +storeClientListAdd(StoreEntry * e, void *data, int offset) { int i; MemObject *mem = e->mem_obj; @@ -2256,7 +2265,7 @@ storeClientListAdd(StoreEntry * e, void *data, int last_offset) i = oldsize; } mem->clients[i].callback_data = data; - mem->clients[i].last_offset = last_offset; + mem->clients[i].offset = offset; return i; } @@ -2290,7 +2299,7 @@ storeClientCopy(StoreEntry * e, } sz = (available_to_write >= maxSize) ? maxSize : available_to_write; /* update the lowest requested offset */ - mem->clients[ci].last_offset = stateoffset + sz; + mem->clients[ci].offset = stateoffset + sz; if (sz > 0) if (mem->data->mem_copy(mem->data, stateoffset, buf, sz) < 0) return -1; diff --git a/src/tunnel.cc b/src/tunnel.cc index 4c8aba2117..8ee39c45ff 100644 --- a/src/tunnel.cc +++ b/src/tunnel.cc @@ -1,6 +1,6 @@ /* - * $Id: tunnel.cc,v 1.49 1997/05/08 07:22:07 wessels Exp $ + * $Id: tunnel.cc,v 1.50 1997/05/15 06:55:49 wessels Exp $ * * DEBUG: section 26 Secure Sockets Layer Proxy * AUTHOR: Duane Wessels @@ -92,10 +92,7 @@ sslClientClosed(int fd, void *data) debug(26, 3, "sslClientClosed: FD %d\n", fd); /* we have been called from comm_close for the client side, so * just need to clean up the server side */ - protoUnregister(sslState->server.fd, - NULL, - sslState->request, - no_addr); + protoUnregister(NULL, sslState->request, no_addr); comm_close(sslState->server.fd); }