to replace it later!) and just call storeAbort directly now.
/*
- * $Id: errorpage.cc,v 1.56 1997/06/04 06:15:51 wessels Exp $
+ * $Id: errorpage.cc,v 1.57 1997/06/19 22:51:48 wessels Exp $
*
* DEBUG: section 4 Error Generation
* AUTHOR: Duane Wessels
meta_data.misc += MAX_URL * 3;
}
-void
-squid_error_entry(StoreEntry * entry, log_type type, const char *msg)
-{
- int error_index;
-
- if (entry == NULL)
- return;
- if (entry->store_status != STORE_PENDING)
- return;
- if (type < ERR_MIN || type > ERR_MAX)
- fatal_dump("squid_error_entry: type out of range.");
- error_index = (int) (type - ERR_MIN);
- debug(4, 1) ("%s: %s\n", ErrorData[error_index].tag, entry->url);
- sprintf(tmp_error_buf, SQUID_ERROR_MSG_P1,
- entry->url,
- entry->url,
- ErrorData[error_index].shrt);
- if (msg) {
- sprintf(tbuf, SQUID_ERROR_MSG_P2, msg);
- strcat(tmp_error_buf, tbuf);
- }
- sprintf(tbuf, SQUID_ERROR_MSG_P3,
- ErrorData[error_index].lng,
- Config.errHtmlText,
- appname,
- version_string,
- getMyHostname());
- strcat(tmp_error_buf, tbuf);
- if (entry->mem_obj) {
- entry->mem_obj->abort_code = type;
- if (entry->mem_obj->reply->code == 0)
- entry->mem_obj->reply->code = 400;
- }
- storeAbort(entry, tmp_error_buf);
-}
-
-
-
char *
squid_error_url(const char *url, int method, int type, const char *address, int code, const char *msg)
{
/*
- * $Id: ftp.cc,v 1.124 1997/06/18 04:04:13 wessels Exp $
+ * $Id: ftp.cc,v 1.125 1997/06/19 22:51:50 wessels Exp $
*
* DEBUG: section 9 File Transfer Protocol (FTP)
* AUTHOR: Harvest Derived
FtpStateData *ftpState = data;
StoreEntry *entry = ftpState->entry;
debug(9, 4) ("ftpLifeTimeExpire: FD %d: '%s'\n", fd, entry->url);
- squid_error_entry(entry, ERR_READ_TIMEOUT, NULL);
+ storeAbort(entry, ERR_READ_TIMEOUT, NULL, 0);
if (ftpState->data.fd >= 0)
comm_close(ftpState->data.fd);
comm_close(ftpState->ctrl.fd);
StoreEntry *entry = ftpState->entry;
assert(fd == ftpState->data.fd);
if (protoAbortFetch(entry)) {
- squid_error_entry(entry, ERR_CLIENT_ABORT, NULL);
+ storeAbort(entry, ERR_CLIENT_ABORT, NULL, 0);
ftpDataTransferDone(ftpState);
return;
}
} else {
BIT_RESET(entry->flag, ENTRY_CACHABLE);
storeReleaseRequest(entry);
- squid_error_entry(entry, ERR_READ_ERROR, xstrerror());
+ storeAbort(entry, ERR_READ_ERROR, xstrerror(), 0);
ftpDataTransferDone(ftpState);
}
} else if (len == 0 && entry->mem_obj->e_current_len == 0) {
- squid_error_entry(entry,
- ERR_ZERO_SIZE_OBJECT,
- errno ? xstrerror() : NULL);
+ storeAbort(entry, ERR_ZERO_SIZE_OBJECT, errno ? xstrerror() : NULL, 0);
ftpDataTransferDone(ftpState);
} else if (len == 0) {
/* Connection closed; retrieval done. */
url);
if (fd == COMM_ERROR) {
debug(9, 4) ("ftpStart: Failed because we're out of sockets.\n");
- squid_error_entry(entry, ERR_NO_FDS, xstrerror());
+ storeAbort(entry, ERR_NO_FDS, xstrerror(), 0);
return;
}
ftpState->ctrl.fd = fd;
FtpStateData *ftpState = data;
debug(9, 3) ("ftpConnectDone\n");
if (status == COMM_ERROR) {
- squid_error_entry(ftpState->entry, ERR_CONNECT_FAIL, xstrerror());
+ storeAbort(ftpState->entry, ERR_CONNECT_FAIL, xstrerror(), 0);
comm_close(fd);
return;
}
if (errflag) {
BIT_RESET(entry->flag, ENTRY_CACHABLE);
storeReleaseRequest(entry);
- squid_error_entry(entry, ERR_WRITE_ERROR, xstrerror());
+ storeAbort(entry, ERR_WRITE_ERROR, xstrerror(), 0);
comm_close(fd);
}
}
} else {
BIT_RESET(entry->flag, ENTRY_CACHABLE);
storeReleaseRequest(entry);
- squid_error_entry(entry, ERR_READ_ERROR, xstrerror());
+ storeAbort(entry, ERR_READ_ERROR, xstrerror(), 0);
comm_close(fd);
}
return;
debug(9, 1) ("Read 0 bytes from FTP control socket?\n");
BIT_RESET(entry->flag, ENTRY_CACHABLE);
storeReleaseRequest(entry);
- squid_error_entry(entry, ERR_READ_ERROR, xstrerror());
+ storeAbort(entry, ERR_READ_ERROR, xstrerror(), 0);
comm_close(fd);
return;
}
FtpStateData *ftpState = data;
debug(9, 3) ("ftpPasvCallback\n");
if (status == COMM_ERROR) {
- squid_error_entry(ftpState->entry, ERR_CONNECT_FAIL, xstrerror());
+ storeAbort(ftpState->entry, ERR_CONNECT_FAIL, xstrerror(), 0);
comm_close(fd);
return;
}
/*
- * $Id: gopher.cc,v 1.85 1997/06/18 01:43:43 wessels Exp $
+ * $Id: gopher.cc,v 1.86 1997/06/19 22:51:50 wessels Exp $
*
* DEBUG: section 10 Gopher
* AUTHOR: Harvest Derived
GopherStateData *gopherState = data;
StoreEntry *entry = gopherState->entry;
debug(10, 4) ("gopherTimeout: FD %d: '%s'\n", fd, entry->url);
- squid_error_entry(entry, ERR_READ_TIMEOUT, NULL);
+ storeAbort(entry, ERR_READ_TIMEOUT, NULL, 0);
comm_close(fd);
}
int off;
int bin;
if (protoAbortFetch(entry)) {
- squid_error_entry(entry, ERR_CLIENT_ABORT, NULL);
+ storeAbort(entry, ERR_CLIENT_ABORT, NULL, 0);
comm_close(fd);
return;
}
} else {
BIT_RESET(entry->flag, ENTRY_CACHABLE);
storeReleaseRequest(entry);
- squid_error_entry(entry, ERR_READ_ERROR, xstrerror());
+ storeAbort(entry, ERR_READ_ERROR, xstrerror(), 0);
comm_close(fd);
}
} else if (len == 0 && entry->mem_obj->e_current_len == 0) {
- squid_error_entry(entry,
- ERR_ZERO_SIZE_OBJECT,
- errno ? xstrerror() : NULL);
+ storeAbort(entry, ERR_ZERO_SIZE_OBJECT, errno ? xstrerror() : NULL, 0);
comm_close(fd);
} else if (len == 0) {
/* Connection closed; retrieval done. */
debug(10, 5) ("gopherSendComplete: FD %d size: %d errflag: %d\n",
fd, size, errflag);
if (errflag) {
- squid_error_entry(entry, ERR_CONNECT_FAIL, xstrerror());
+ storeAbort(entry, ERR_CONNECT_FAIL, xstrerror(), 0);
comm_close(fd);
if (buf)
put_free_4k_page(buf); /* Allocated by gopherSendRequest. */
/* Parse url. */
if (gopher_url_parser(url, gopherState->host, &gopherState->port,
&gopherState->type_id, gopherState->request)) {
- squid_error_entry(entry, ERR_INVALID_URL, NULL);
+ storeAbort(entry, ERR_INVALID_URL, NULL, 0);
gopherStateFree(-1, gopherState);
return;
}
url);
if (fd == COMM_ERROR) {
debug(10, 4) ("gopherStart: Failed because we're out of sockets.\n");
- squid_error_entry(entry, ERR_NO_FDS, xstrerror());
+ storeAbort(entry, ERR_NO_FDS, xstrerror(), 0);
gopherStateFree(-1, gopherState);
return;
}
* Otherwise, we cannot check return code for connect. */
if (!ipcache_gethostbyname(gopherState->host, 0)) {
debug(10, 4) ("gopherStart: Called without IP entry in ipcache. OR lookup failed.\n");
- squid_error_entry(entry, ERR_DNS_FAIL, dns_error_message);
+ storeAbort(entry, ERR_DNS_FAIL, dns_error_message, 0);
comm_close(fd);
return;
}
{
GopherStateData *gopherState = data;
if (status == COMM_ERROR) {
- squid_error_entry(gopherState->entry, ERR_CONNECT_FAIL, xstrerror());
+ storeAbort(gopherState->entry, ERR_CONNECT_FAIL, xstrerror(), 0);
comm_close(fd);
return;
}
/*
- * $Id: http.cc,v 1.173 1997/06/18 04:04:14 wessels Exp $
+ * $Id: http.cc,v 1.174 1997/06/19 22:51:51 wessels Exp $
*
* DEBUG: section 11 Hypertext Transfer Protocol (HTTP)
* AUTHOR: Harvest Derived
HttpStateData *httpState = data;
StoreEntry *entry = httpState->entry;
debug(11, 4) ("httpTimeout: FD %d: '%s'\n", fd, entry->url);
- squid_error_entry(entry, ERR_READ_TIMEOUT, NULL);
+ storeAbort(entry, ERR_READ_TIMEOUT, NULL, 0);
comm_close(fd);
}
int clen;
int off;
if (protoAbortFetch(entry)) {
- squid_error_entry(entry, ERR_CLIENT_ABORT, NULL);
+ storeAbort(entry, ERR_CLIENT_ABORT, NULL, 0);
comm_close(fd);
return;
}
} else {
BIT_RESET(entry->flag, ENTRY_CACHABLE);
storeReleaseRequest(entry);
- squid_error_entry(entry, ERR_READ_ERROR, xstrerror());
+ storeAbort(entry, ERR_READ_ERROR, xstrerror(), 0);
comm_close(fd);
}
debug(50, 2) ("httpReadReply: FD %d: read failure: %s.\n",
fd, xstrerror());
} else if (len == 0 && entry->mem_obj->e_current_len == 0) {
httpState->eof = 1;
- squid_error_entry(entry,
- ERR_ZERO_SIZE_OBJECT,
- errno ? xstrerror() : NULL);
+ storeAbort(entry, ERR_ZERO_SIZE_OBJECT, errno ? xstrerror() : NULL, 0);
comm_close(fd);
} else if (len == 0) {
/* Connection closed; retrieval done. */
fd, size, errflag);
if (errflag) {
- squid_error_entry(entry, ERR_CONNECT_FAIL, xstrerror());
+ storeAbort(entry, ERR_CONNECT_FAIL, xstrerror(), 0);
comm_close(fd);
return;
} else {
entry->url);
if (fd == COMM_ERROR) {
debug(11, 4) ("proxyhttpStart: Failed because we're out of sockets.\n");
- squid_error_entry(entry, ERR_NO_FDS, xstrerror());
+ storeAbort(entry, ERR_NO_FDS, xstrerror(), 0);
return;
}
storeLockObject(entry);
StoreEntry *entry = httpState->entry;
if (status == COMM_ERR_DNS) {
debug(11, 4) ("httpConnectDone: Unknown host: %s\n", request->host);
- squid_error_entry(entry, ERR_DNS_FAIL, dns_error_message);
+ storeAbort(entry, ERR_DNS_FAIL, dns_error_message, 0);
comm_close(fd);
} else if (status != COMM_OK) {
- squid_error_entry(entry, ERR_CONNECT_FAIL, xstrerror());
+ storeAbort(entry, ERR_CONNECT_FAIL, xstrerror(), 0);
if (httpState->neighbor)
peerCheckConnectStart(httpState->neighbor);
comm_close(fd);
entry->url);
if (fd == COMM_ERROR) {
debug(11, 4) ("httpStart: Failed because we're out of sockets.\n");
- squid_error_entry(entry, ERR_NO_FDS, xstrerror());
+ storeAbort(entry, ERR_NO_FDS, xstrerror(), 0);
return;
}
storeLockObject(entry);
/*
- * $Id: store.cc,v 1.259 1997/06/18 16:15:53 wessels Exp $
+ * $Id: store.cc,v 1.260 1997/06/19 22:51:55 wessels Exp $
*
* DEBUG: section 20 Storeage Manager
* AUTHOR: Harvest Derived
}
/*
- * Fetch aborted. Tell all clients to go home. Negatively cache
- * abort message, freeing the data for this object
+ * Someone wants to abort this transfer. Set the reason in the
+ * request structure, call the server-side callback and mark the
+ * entry for releasing
*/
void
-storeAbort(StoreEntry * e, const char *msg)
+storeAbort(StoreEntry * e, log_type abort_code, const char *msg, int cbflag)
{
- LOCAL_ARRAY(char, mime_hdr, 300);
- char *abort_msg;
MemObject *mem = e->mem_obj;
assert(e->store_status == STORE_PENDING);
assert(mem != NULL);
- /*assert(ping_status != PING_WAITING); */
- debug(20, 6) ("storeAbort: '%s'\n", e->key);
+ safe_free(mem->e_abort_msg);
+ mem->e_abort_msg = xstrdup(msg);
+ debug(20, 6) ("storeAbort: %s %s\n", log_tags[abort_code], e->key);
storeNegativeCache(e);
+ storeReleaseRequest(e);
e->store_status = STORE_ABORTED;
storeSetMemStatus(e, IN_MEMORY);
/* No DISK swap for negative cached object */
e->swap_status = NO_SWAP;
e->lastref = squid_curtime;
- storeLockObject(e);
/* Count bytes faulted through cache but not moved to disk */
HTTPCacheInfo->proto_touchobject(HTTPCacheInfo,
mem->request ? mem->request->protocol : PROTO_NONE,
mem->e_current_len);
- if (msg) {
- abort_msg = get_free_8k_page();
- strcpy(abort_msg, "HTTP/1.0 400 Cache Detected Error\r\n");
- mk_mime_hdr(mime_hdr,
- "text/html",
- strlen(msg),
- (time_t) Config.negativeTtl,
- squid_curtime);
- strcat(abort_msg, mime_hdr);
- strcat(abort_msg, "\r\n");
- strncat(abort_msg, msg, 8191 - strlen(abort_msg));
- storeAppend(e, abort_msg, strlen(abort_msg));
- safe_free(mem->e_abort_msg);
- mem->e_abort_msg = xstrdup(abort_msg);
- /* Set up object for negative caching */
- BIT_SET(e->flag, ABORT_MSG_PENDING);
- put_free_8k_page(abort_msg);
- }
/* We assign an object length here--The only other place we assign the
* object length is in storeComplete() */
+ storeLockObject(e);
e->object_len = mem->e_current_len;
- if (mem->abort.callback) {
+ /* Notify the server side */
+ if (cbflag && mem->abort.callback) {
mem->abort.callback(mem->abort.data);
mem->abort.callback = NULL;
}
+ /* Notify the client side */
InvokeHandlers(e);
storeUnlockObject(e);
- return;
}
/* get the first in memory object entry in the storage */
static int
swapInError(int fd_unused, StoreEntry * entry)
{
- squid_error_entry(entry, ERR_DISK_IO, xstrerror());
+ storeAbort(entry, ERR_DISK_IO, xstrerror(), 1);
return 0;
}
/*
- * $Id: wais.cc,v 1.77 1997/06/18 01:43:46 wessels Exp $
+ * $Id: wais.cc,v 1.78 1997/06/19 22:51:57 wessels Exp $
*
* DEBUG: section 24 WAIS Relay
* AUTHOR: Harvest Derived
WaisStateData *waisState = data;
StoreEntry *entry = waisState->entry;
debug(24, 4) ("waisTimeout: FD %d: '%s'\n", fd, entry->url);
- squid_error_entry(entry, ERR_READ_TIMEOUT, NULL);
+ storeAbort(entry, ERR_READ_TIMEOUT, NULL, 0);
comm_close(fd);
}
int off;
int bin;
if (protoAbortFetch(entry)) {
- squid_error_entry(entry, ERR_CLIENT_ABORT, NULL);
+ storeAbort(entry, ERR_CLIENT_ABORT, NULL, 0);
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);
+ storeAbort(entry, ERR_NO_CLIENTS_BIG_OBJ, NULL, 0);
comm_close(fd);
return;
}
} else {
BIT_RESET(entry->flag, ENTRY_CACHABLE);
storeReleaseRequest(entry);
- squid_error_entry(entry, ERR_READ_ERROR, xstrerror());
+ storeAbort(entry, ERR_READ_ERROR, xstrerror(), 0);
comm_close(fd);
}
} else if (len == 0 && entry->mem_obj->e_current_len == 0) {
- squid_error_entry(entry,
- ERR_ZERO_SIZE_OBJECT,
- errno ? xstrerror() : NULL);
+ storeAbort(entry, ERR_ZERO_SIZE_OBJECT, errno ? xstrerror() : NULL, 0);
comm_close(fd);
} else if (len == 0) {
/* Connection closed; retrieval done. */
debug(24, 5) ("waisSendComplete: FD %d size: %d errflag: %d\n",
fd, size, errflag);
if (errflag) {
- squid_error_entry(entry, ERR_CONNECT_FAIL, xstrerror());
+ storeAbort(entry, ERR_CONNECT_FAIL, xstrerror(), 0);
comm_close(fd);
} else {
/* Schedule read reply. */
debug(24, 3) ("waisStart: \"%s %s\"\n", RequestMethodStr[method], url);
if (!Config.Wais.relayHost) {
debug(24, 0) ("waisStart: Failed because no relay host defined!\n");
- squid_error_entry(entry, ERR_NO_RELAY, NULL);
+ storeAbort(entry, ERR_NO_RELAY, NULL, 0);
return;
}
fd = comm_open(SOCK_STREAM,
url);
if (fd == COMM_ERROR) {
debug(24, 4) ("waisStart: Failed because we're out of sockets.\n");
- squid_error_entry(entry, ERR_NO_FDS, xstrerror());
+ storeAbort(entry, ERR_NO_FDS, xstrerror(), 0);
return;
}
waisState = xcalloc(1, sizeof(WaisStateData));
{
WaisStateData *waisState = data;
if (status == COMM_ERR_DNS) {
- squid_error_entry(waisState->entry, ERR_DNS_FAIL, dns_error_message);
+ storeAbort(waisState->entry, ERR_DNS_FAIL, dns_error_message, 0);
comm_close(fd);
return;
} else if (status != COMM_OK) {
- squid_error_entry(waisState->entry, ERR_CONNECT_FAIL, xstrerror());
+ storeAbort(waisState->entry, ERR_CONNECT_FAIL, xstrerror(), 0);
comm_close(fd);
return;
}