/*
- * $Id: client_side.cc,v 1.157 1997/11/23 06:50:27 wessels Exp $
+ * $Id: client_side.cc,v 1.158 1997/11/24 22:32:36 wessels Exp $
*
* DEBUG: section 33 Client-side Routines
* AUTHOR: Duane Wessels
httpRequestFree(http);
if ((http = conn->chr) != NULL) {
debug(12, 1) ("clientWriteComplete: FD %d Sending next request\n", fd);
- storeClientCopy(entry,
- http->out.offset,
- http->out.offset,
- SM_PAGE_SIZE,
- get_free_4k_page(),
- clientSendMoreData,
- http);
+ if (!storeClientCopyPending(http->entry, http))
+ storeClientCopy(http->entry,
+ http->out.offset,
+ http->out.offset,
+ SM_PAGE_SIZE,
+ get_free_4k_page(),
+ clientSendMoreData,
+ http);
} else {
debug(12, 5) ("clientWriteComplete: FD %d Setting read handler for next request\n", fd);
fd_note(fd, "Reading next request");
{
ushortlist *u;
int fd;
-debug(0,0)("clientHttpConnectionsOpen\n");
+ debug(0, 0) ("clientHttpConnectionsOpen\n");
for (u = Config.Port.http; u; u = u->next) {
-debug(0,0)("clientHttpConnectionsOpen: port=%d\n", (int) u->i);
- enter_suid();
- fd = comm_open(SOCK_STREAM,
- 0,
- Config.Addrs.tcp_incoming,
- u->i,
- COMM_NONBLOCKING,
- "HTTP Socket");
- leave_suid();
- if (fd < 0)
- continue;
- comm_listen(fd);
- commSetSelect(fd, COMM_SELECT_READ, httpAccept, NULL, 0);
- commSetDefer(fd, httpAcceptDefer, NULL);
- debug(1, 1) ("Accepting HTTP connections on port %d, FD %d.\n",
- (int) u->i, fd);
- HttpSockets[NHttpSockets++] = fd;
+ debug(0, 0) ("clientHttpConnectionsOpen: port=%d\n", (int) u->i);
+ enter_suid();
+ fd = comm_open(SOCK_STREAM,
+ 0,
+ Config.Addrs.tcp_incoming,
+ u->i,
+ COMM_NONBLOCKING,
+ "HTTP Socket");
+ leave_suid();
+ if (fd < 0)
+ continue;
+ comm_listen(fd);
+ commSetSelect(fd, COMM_SELECT_READ, httpAccept, NULL, 0);
+ commSetDefer(fd, httpAcceptDefer, NULL);
+ debug(1, 1) ("Accepting HTTP connections on port %d, FD %d.\n",
+ (int) u->i, fd);
+ HttpSockets[NHttpSockets++] = fd;
}
if (NHttpSockets < 1)
- fatal("Cannot open HTTP Port");
+ fatal("Cannot open HTTP Port");
}
extern void storeFreeMemory(void);
extern int expiresMoreThan(time_t, time_t);
extern void storeClientListAdd(StoreEntry *, void *);
+extern int storeClientCopyPending(StoreEntry *, void *);
extern void InvokeHandlers(StoreEntry *);
extern int storeEntryValidToSend(StoreEntry *);
extern void storeTimestampsSet(StoreEntry *);
/*
- * $Id: store.cc,v 1.346 1997/11/18 01:02:42 wessels Exp $
+ * $Id: store.cc,v 1.347 1997/11/24 22:32:38 wessels Exp $
*
* DEBUG: section 20 Storeage Manager
* AUTHOR: Harvest Derived
{
int i = 0;
MemObject *mem = e->mem_obj;
- STCB *callback = NULL;
store_client *sc;
store_client *nx = NULL;
assert(mem->clients != NULL || mem->nclients == 0);
/* walk the entire list looking for valid callbacks */
for (sc = mem->clients; sc; sc = nx) {
nx = sc->next;
- debug(20, 3) ("InvokeHandlers: checking client #%d\n", i++);
+ debug(20, 0) ("InvokeHandlers: checking client #%d\n", i++);
if (sc->callback_data == NULL)
continue;
- if ((callback = sc->callback) == NULL)
+ if (sc->callback == NULL)
continue;
storeClientCopy2(e, sc);
}
{
store_client *sc;
static int recurse_detect = 0;
- assert(e->store_status != STORE_ABORTED);
+ /*assert(e->store_status != STORE_ABORTED); */
assert(recurse_detect < 3); /* could == 1 for IMS not modified's */
debug(20, 3) ("storeClientCopy: %s, seen %d, want %d, size %d, cb %p, cbdata %p\n",
storeKeyText(e->key),
callback(sc->callback_data, sc->copy_buf, len);
}
+int
+storeClientCopyPending(StoreEntry * e, void *data)
+{
+ /* return 1 if there is a callback registered for this client */
+ store_client *sc = storeClientListSearch(e->mem_obj, data);
+ if (sc == NULL)
+ return 0;
+ if (sc->callback == NULL)
+ return 0;
+ return 1;
+}
+
static int
storeEntryValidLength(const StoreEntry * e)
{
/* this just sets DELAY_SENDING */
void
-storeBuffer(StoreEntry *e)
+storeBuffer(StoreEntry * e)
{
- EBIT_SET(e->flag, DELAY_SENDING);
+ EBIT_SET(e->flag, DELAY_SENDING);
}
/* this just clears DELAY_SENDING and Invokes the handlers */
void
-storeBufferFlush(StoreEntry *e)
+storeBufferFlush(StoreEntry * e)
{
- EBIT_CLR(e->flag, DELAY_SENDING);
- InvokeHandlers(e);
+ EBIT_CLR(e->flag, DELAY_SENDING);
+ InvokeHandlers(e);
}