/*
- * $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
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
} 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
* 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;
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
/*
- * $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
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();
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 {
/*
- * $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
*
#if HAVE_GETOPT_H
#include <getopt.h>
#endif
-
#if HAVE_POLL_H
#include <poll.h>
#endif
+#if HAVE_ASSERT_H
+#include <assert.h>
+#else
+#define assert(X) ((void)0)
+#endif
#ifdef __STDC__
#include <stdarg.h>
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"
/*
- * $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
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);
}
/*
- * $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
}
/* 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
{
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;
}
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;
}
/* 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;
i = oldsize;
}
mem->clients[i].callback_data = data;
- mem->clients[i].last_offset = last_offset;
+ mem->clients[i].offset = offset;
return i;
}
}
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;
/*
- * $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
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);
}