/*
- * $Id: ftp.cc,v 1.115 1997/06/02 01:06:11 wessels Exp $
+ * $Id: ftp.cc,v 1.116 1997/06/02 05:39:43 wessels Exp $
*
* DEBUG: section 9 File Transfer Protocol (FTP)
* AUTHOR: Harvest Derived
static void ftpReadQuit _PARAMS((FtpStateData * ftpState));
static void ftpDataTransferDone _PARAMS((FtpStateData * ftpState));
static void ftpAppendSuccessHeader _PARAMS((FtpStateData * ftpState));
+static STABH ftpAbort;
static FTPSM ftpReadWelcome;
static FTPSM ftpReadUser;
if (ftpState == NULL)
return;
storeUnlockObject(ftpState->entry);
+ storeUnregisterAbort(ftpState->entry);
if (ftpState->reply_hdr) {
put_free_8k_page(ftpState->reply_hdr);
ftpState->reply_hdr = NULL;
int clen;
int off;
int bin;
- StoreEntry *entry = NULL;
+ StoreEntry *entry = ftpState->entry;
assert(fd == ftpState->data.fd);
- entry = ftpState->entry;
if (protoAbortFetch(entry)) {
- squid_error_entry(entry, ERR_CLIENT_ABORT, NULL);
- ftpDataTransferDone(ftpState);
- return;
+ squid_error_entry(entry, ERR_CLIENT_ABORT, NULL);
+ ftpDataTransferDone(ftpState);
+ return;
}
/* check if we want to defer reading */
clen = entry->mem_obj->e_current_len;
off = storeGetLowestReaderOffset(entry);
if ((clen - off) > FTP_DELETE_GAP) {
- if (entry->flag & CLIENT_ABORT_REQUEST) {
- squid_error_entry(entry, ERR_CLIENT_ABORT, NULL);
- ftpDataTransferDone(ftpState);
- }
IOStats.Ftp.reads_deferred++;
debug(9, 3, "ftpReadData: Read deferred for Object: %s\n",
entry->url);
storeTimestampsSet(entry);
storeComplete(entry);
ftpDataTransferDone(ftpState);
- } else if (entry->flag & CLIENT_ABORT_REQUEST) {
- squid_error_entry(entry, ERR_CLIENT_ABORT, NULL);
- ftpDataTransferDone(ftpState);
} else {
if (EBIT_TEST(ftpState->flags, FTP_ISDIR)) {
ftpParseListing(ftpState, len);
ftpState->ctrl.fd = fd;
comm_add_close_handler(fd, ftpStateFree, ftpState);
commSetTimeout(fd, Config.Timeout.connect, ftpTimeout, ftpState);
+ storeRegisterAbort(entry, ftpAbort, ftpState);
ipcache_nbgethostbyname(request->host, fd, ftpConnect, ftpState);
}
debug(9, 5, "ftpReadControlReply: FD %d, Read %d bytes\n", fd, len);
if (len > 0)
commSetTimeout(fd, Config.Timeout.read, NULL, NULL);
- if (entry->flag & CLIENT_ABORT_REQUEST) {
- squid_error_entry(entry, ERR_CLIENT_ABORT, NULL);
- comm_close(fd);
- return;
- }
if (len < 0) {
debug(50, 1, "ftpReadControlReply: read error: %s\n", xstrerror());
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) {
assert(e->flag & KEY_PRIVATE);
storeSetPublicKey(e);
}
+
+static void
+ftpAbort(void *data)
+{
+ FtpStateData *ftpState = data;
+ debug(9, 1, "ftpAbort: %s\n", ftpState->entry->url);
+ ftpDataTransferDone(ftpState);
+}
/*
- * $Id: gopher.cc,v 1.81 1997/05/22 15:51:54 wessels Exp $
+ * $Id: gopher.cc,v 1.82 1997/06/02 05:39:44 wessels Exp $
*
* DEBUG: section 10 Gopher
* AUTHOR: Harvest Derived
int cso_recno;
int len;
char *buf; /* pts to a 4k page */
+ int fd;
} GopherStateData;
static PF gopherStateFree;
static PF gopherSendRequest;
static GopherStateData *CreateGopherStateData _PARAMS((void));
static CNCB gopherConnectDone;
+static STABH gopherAbort;
static char def_gopher_bin[] = "www/unknown";
static char def_gopher_text[] = "text/plain";
GopherStateData *gopherState = data;
if (gopherState == NULL)
return;
- if (gopherState->entry)
+ if (gopherState->entry) {
storeUnlockObject(gopherState->entry);
+ storeUnregisterAbort(gopherState->entry);
+ }
put_free_4k_page(gopherState->buf);
xfree(gopherState);
}
gopherReadReply(int fd, void *data)
{
GopherStateData *gopherState = data;
+ StoreEntry *entry = gopherState->entry;
char *buf = NULL;
int len;
int clen;
int off;
- StoreEntry *entry = NULL;
int bin;
-
- entry = gopherState->entry;
if (protoAbortFetch(entry)) {
- squid_error_entry(entry, ERR_CLIENT_ABORT, NULL);
- comm_close(fd);
- return;
+ squid_error_entry(entry, ERR_CLIENT_ABORT, NULL);
+ comm_close(fd);
+ return;
}
/* check if we want to defer reading */
clen = entry->mem_obj->e_current_len;
off = storeGetLowestReaderOffset(entry);
if ((clen - off) > GOPHER_DELETE_GAP) {
- if (entry->flag & CLIENT_ABORT_REQUEST) {
- squid_error_entry(entry, ERR_CLIENT_ABORT, NULL);
- comm_close(fd);
- return;
- }
IOStats.Gopher.reads_deferred++;
debug(10, 3, "gopherReadReply: Read deferred for Object: %s\n",
entry->url);
BIT_RESET(entry->flag, DELAY_SENDING);
storeComplete(entry);
comm_close(fd);
- } else if (entry->flag & CLIENT_ABORT_REQUEST) {
- squid_error_entry(entry, ERR_CLIENT_ABORT, NULL);
- if (gopherState->conversion != NORMAL)
- gopherEndHTML(data);
- BIT_RESET(entry->flag, DELAY_SENDING);
- comm_close(fd);
} else {
if (gopherState->conversion != NORMAL) {
gopherToHTML(data, buf, len);
gopherStateFree(-1, gopherState);
return;
}
- comm_add_close_handler(fd,
- gopherStateFree,
- gopherState);
+ comm_add_close_handler(fd, gopherStateFree, gopherState);
+ storeRegisterAbort(entry, gopherAbort, gopherState);
/* check if IP is already in cache. It must be.
* It should be done before this route is called.
* Otherwise, we cannot check return code for connect. */
gopherState->port,
gopherConnectDone,
gopherState);
+ gopherState->fd = fd;
}
static void
gd->buf = get_free_4k_page();
return (gd);
}
+
+static void
+gopherAbort(void *data)
+{
+ GopherStateData *gopherState = data;
+ debug(10,1,"gopherAbort: %s\n", gopherState->entry->url);
+ comm_close(gopherState->fd);
+}
/*
- * $Id: http.cc,v 1.166 1997/06/01 23:22:20 wessels Exp $
+ * $Id: http.cc,v 1.167 1997/06/02 05:39:45 wessels Exp $
*
* DEBUG: section 11 Hypertext Transfer Protocol (HTTP)
* AUTHOR: Harvest Derived
static void httpCacheNegatively _PARAMS((StoreEntry *));
static void httpMakePrivate _PARAMS((StoreEntry *));
static void httpMakePublic _PARAMS((StoreEntry *));
+static STABH httpAbort;
static void
httpStateFree(int fd, void *data)
if (httpState == NULL)
return;
storeUnlockObject(httpState->entry);
+ storeUnregisterAbort(httpState->entry);
if (httpState->reply_hdr) {
put_free_8k_page(httpState->reply_hdr);
httpState->reply_hdr = NULL;
{
HttpStateData *httpState = data;
LOCAL_ARRAY(char, buf, SQUID_TCP_SO_RCVBUF);
+ StoreEntry *entry = httpState->entry;
int len;
int bin;
int clen;
int off;
- StoreEntry *entry = NULL;
-
- entry = httpState->entry;
if (protoAbortFetch(entry)) {
- squid_error_entry(entry, ERR_CLIENT_ABORT, NULL);
- comm_close(fd);
- return;
+ squid_error_entry(entry, ERR_CLIENT_ABORT, NULL);
+ comm_close(fd);
+ return;
}
/* check if we want to defer reading */
clen = entry->mem_obj->e_current_len;
off = storeGetLowestReaderOffset(entry);
if ((clen - off) > HTTP_DELETE_GAP) {
- if (entry->flag & CLIENT_ABORT_REQUEST) {
- squid_error_entry(entry, ERR_CLIENT_ABORT, NULL);
- comm_close(fd);
- return;
- }
IOStats.Http.reads_deferred++;
debug(11, 3, "httpReadReply: Read deferred for Object: %s\n",
entry->url);
storeAppend(entry, buf, len); /* invoke handlers! */
storeComplete(entry); /* deallocates mem_obj->request */
comm_close(fd);
- } else if (entry->flag & CLIENT_ABORT_REQUEST) {
- squid_error_entry(entry, ERR_CLIENT_ABORT, NULL);
- comm_close(fd);
} else {
if (httpState->reply_hdr_state < 2)
httpProcessReplyHeader(httpState, buf, len);
peerCheckConnectStart(httpState->neighbor);
comm_close(fd);
} else {
- /* Install connection complete handler. */
if (opt_no_ipcache)
ipcacheInvalidate(request->host);
fd_note(fd, entry->url);
- commSetSelect(fd, COMM_SELECT_WRITE,
- httpSendRequest, httpState, 0);
+ storeRegisterAbort(entry, httpAbort, httpState);
+ commSetSelect(fd, COMM_SELECT_WRITE, httpSendRequest, httpState, 0);
}
}
ReplyHeaderStats.cc[i]);
storeAppendPrintf(entry, close_bracket);
}
+
+static void
+httpAbort(void *data)
+{
+ HttpStateData *httpState = data;
+ debug(11, 1, "httpAbort: %s\n", httpState->entry->url);
+ comm_close(httpState->fd);
+}
/*
- * $Id: stat.cc,v 1.139 1997/05/02 21:34:13 wessels Exp $
+ * $Id: stat.cc,v 1.140 1997/06/02 05:39:48 wessels Exp $
*
* DEBUG: section 18 Cache Manager Statistics
* AUTHOR: Harvest Derived
#endif
if (BIT_TEST(flags, DELETE_BEHIND))
strcat(buf, "DB,");
+#ifdef OLD_CODE
if (BIT_TEST(flags, CLIENT_ABORT_REQUEST))
strcat(buf, "CA,");
+#endif
if (BIT_TEST(flags, DELAY_SENDING))
strcat(buf, "DS,");
if (BIT_TEST(flags, ABORT_MSG_PENDING))
/*
- * $Id: store.cc,v 1.248 1997/06/02 01:06:17 wessels Exp $
+ * $Id: store.cc,v 1.249 1997/06/02 05:39:50 wessels Exp $
*
* DEBUG: section 20 Storeage Manager
* AUTHOR: Harvest Derived
e->swap_file_number = file_number;
e->object_len = size;
e->lock_count = 0;
- BIT_RESET(e->flag, CLIENT_ABORT_REQUEST);
e->refcount = 0;
e->lastref = timestamp;
e->timestamp = timestamp;
/* We assign an object length here--The only other place we assign the
* object length is in storeComplete() */
e->object_len = mem->e_current_len;
+ if (mem->abort.callback) {
+ mem->abort.callback(mem->abort.data);
+ mem->abort.callback = NULL;
+ }
InvokeHandlers(e);
storeUnlockObject(e);
return;
else
unlinkdUnlink(storeSwapFullPath(fileno, NULL));
}
+
+void
+storeRegisterAbort(StoreEntry * e, STABH * cb, void *data)
+{
+ MemObject *mem = e->mem_obj;
+ assert(mem);
+ assert(mem->abort.callback == NULL);
+ mem->abort.callback = cb;
+ mem->abort.data = data;
+}
+
+void
+storeUnregisterAbort(StoreEntry * e)
+{
+ MemObject *mem = e->mem_obj;
+ assert(mem);
+ mem->abort.callback = NULL;
+}
+
/*
- * $Id: wais.cc,v 1.73 1997/06/02 01:06:19 wessels Exp $
+ * $Id: wais.cc,v 1.74 1997/06/02 05:39:51 wessels Exp $
*
* DEBUG: section 24 WAIS Relay
* AUTHOR: Harvest Derived
static CWCB waisSendComplete;
static PF waisSendRequest;
static CNCB waisConnectDone;
+static STABH waisAbort;
static void
waisStateFree(int fd, void *data)
if (waisState == NULL)
return;
storeUnlockObject(waisState->entry);
+ storeUnregisterAbort(waisState->entry);
xfree(waisState);
}
{
WaisStateData *waisState = data;
LOCAL_ARRAY(char, buf, 4096);
- int len;
StoreEntry *entry = waisState->entry;
+ int len;
int clen;
int off;
int bin;
-
+ if (protoAbortFetch(entry)) {
+ squid_error_entry(entry, ERR_CLIENT_ABORT, NULL);
+ comm_close(fd);
+ return;
+ }
if (entry->flag & DELETE_BEHIND && !storeClientWaiting(entry)) {
/* we can terminate connection right now */
squid_error_entry(entry, ERR_NO_CLIENTS_BIG_OBJ, NULL);
clen = entry->mem_obj->e_current_len;
off = storeGetLowestReaderOffset(entry);
if ((clen - off) > WAIS_DELETE_GAP) {
- if (entry->flag & CLIENT_ABORT_REQUEST) {
- squid_error_entry(entry, ERR_CLIENT_ABORT, NULL);
- comm_close(fd);
- return;
- }
IOStats.Wais.reads_deferred++;
debug(24, 3, "waisReadReply: Read deferred for Object: %s\n",
entry->url);
waisState->fd = fd;
waisState->entry = entry;
xstrncpy(waisState->request, url, MAX_URL);
- comm_add_close_handler(waisState->fd,
- waisStateFree,
- waisState);
+ comm_add_close_handler(waisState->fd, waisStateFree, waisState);
+ storeRegisterAbort(entry, waisAbort, waisState);
commSetTimeout(fd, Config.Timeout.read, waisTimeout, waisState);
storeLockObject(entry);
commConnectStart(waisState->fd,
waisSendRequest,
waisState, 0);
}
+
+static void
+waisAbort(void *data)
+{
+ HttpStateData *waisState = data;
+ debug(24, 1, "waisAbort: %s\n", waisState->entry->url);
+ comm_close(waisState->fd);
+}