-/* $Id: ftp.cc,v 1.13 1996/03/27 18:15:45 wessels Exp $ */
+/* $Id: ftp.cc,v 1.14 1996/03/28 20:42:46 wessels Exp $ */
#include "squid.h"
if (len < 0 || ((len == 0) && (entry->mem_obj->e_current_len == 0))) {
if (len < 0)
debug(0, 1, "ftpReadReply: read error: %s\n", xstrerror());
- cached_error_entry(entry, ERR_READ_ERROR, NULL);
- comm_close(fd);
- safe_free(data);
+ if (errno == ECONNRESET) {
+ /* Connection reset by peer */
+ /* consider it as a EOF */
+ if (!(entry->flag & DELETE_BEHIND))
+ entry->expires = cached_curtime + ttlSet(entry);
+ sprintf(tmp_error_buf, "\nWarning: The Remote Server sent RESET at the end of transmission.\n");
+ storeAppend(entry, tmp_error_buf, strlen(tmp_error_buf));
+ storeComplete(entry);
+ comm_close(fd);
+ safe_free(data);
+ } else if (errno == EAGAIN || errno == EWOULDBLOCK) {
+ /* reinstall handlers */
+ /* XXX This may loop forever */
+ comm_set_select_handler(fd, COMM_SELECT_READ,
+ (PF) ftpReadReply, (caddr_t) data);
+ /* note there is no ftpReadReplyTimeout. Timeouts are handled
+ * by `ftpget'. */
+ } else {
+ cached_error_entry(entry, ERR_READ_ERROR, xstrerror());
+ comm_close(fd);
+ safe_free(data);
+ }
} else if (len == 0) {
/* Connection closed; retrieval done. */
if (!data->got_marker) {
-/* $Id: gopher.cc,v 1.9 1996/03/27 18:15:45 wessels Exp $ */
+/* $Id: gopher.cc,v 1.10 1996/03/28 20:42:47 wessels Exp $ */
#include "squid.h"
}
}
buf = get_free_4k_page();
+ errno = 0;
len = read(fd, buf, TEMP_BUF_SIZE - 1); /* leave one space for \0 in gopherToHTML */
- debug(0, 5, "gopherReadReply - fd: %d read len:%d\n", fd, len);
+ debug(0, 5, "gopherReadReply: FD %d read len=%d\n", fd, len);
if (len < 0 || ((len == 0) && (entry->mem_obj->e_current_len == 0))) {
- debug(0, 1, "gopherReadReply - error reading: %s\n",
+ debug(0, 1, "gopherReadReply: error reading: %s\n",
xstrerror());
- cached_error_entry(entry, ERR_READ_ERROR, xstrerror());
- comm_close(fd);
- freeGopherData(data);
+ if (errno == ECONNRESET) {
+ /* Connection reset by peer */
+ /* consider it as a EOF */
+ if (!(entry->flag & DELETE_BEHIND))
+ entry->expires = cached_curtime + ttlSet(entry);
+ sprintf(tmp_error_buf, "\nWarning: The Remote Server sent RESET at the end of transmission.\n");
+ storeAppend(entry, tmp_error_buf, strlen(tmp_error_buf));
+ storeComplete(entry);
+ comm_close(fd);
+ freeGopherData(data);
+ } else if (errno == EAGAIN || errno == EWOULDBLOCK) {
+ /* reinstall handlers */
+ /* XXX This may loop forever */
+ comm_set_select_handler(fd, COMM_SELECT_READ,
+ (PF) gopherReadReply, (caddr_t) data);
+ comm_set_select_handler_plus_timeout(fd, COMM_SELECT_TIMEOUT,
+ (PF) gopherReadReplyTimeout, (caddr_t) data, getReadTimeout());
+ } else {
+ cached_error_entry(entry, ERR_READ_ERROR, xstrerror());
+ comm_close(fd);
+ freeGopherData(data);
+ }
} else if (len == 0) {
/* Connection closed; retrieval done. */
/* flush the rest of data in temp buf if there is one. */
storeComplete(entry);
comm_close(fd);
freeGopherData(data);
-
} else if (((entry->mem_obj->e_current_len + len) > getGopherMax()) &&
!(entry->flag & DELETE_BEHIND)) {
/* accept data, but start to delete behind it */
{
StoreEntry *entry = NULL;
entry = data->entry;
- debug(0, 5, "gopherSendComplete - fd: %d size: %d errflag: %d\n",
+ debug(0, 5, "gopherSendComplete: FD %d size: %d errflag: %d\n",
fd, size, errflag);
if (errflag) {
cached_error_entry(entry, ERR_CONNECT_FAIL, xstrerror());
sprintf(buf, "%s%c%c", data->request, CR, LF);
}
- debug(0, 5, "gopherSendRequest - fd: %d\n", fd);
+ debug(0, 5, "gopherSendRequest: FD %d\n", fd);
data->icp_rwd_ptr = icpWrite(fd,
buf,
len,
data->entry = entry;
- debug(0, 3, "gopherStart - url: %s\n", url);
+ debug(0, 3, "gopherStart: url: %s\n", url);
/* Parse url. */
if (gopher_url_parser(url, data->host, &data->port,
freeGopherData(data);
return COMM_ERROR;
} else {
- debug(0, 5, "startGopher - conn %d EINPROGRESS\n", sock);
+ debug(0, 5, "startGopher: conn %d EINPROGRESS\n", sock);
}
}
/* Install connection complete handler. */
-/* $Id: http.cc,v 1.11 1996/03/27 18:15:46 wessels Exp $ */
+/* $Id: http.cc,v 1.12 1996/03/28 20:42:48 wessels Exp $ */
#include "squid.h"
sprintf(tmp_error_buf, "\n<p>Warning: The Remote Server sent RESET at the end of transmission.\n");
storeAppend(entry, tmp_error_buf, strlen(tmp_error_buf));
storeComplete(entry);
-#ifdef POSSIBLE_FIX
+ comm_close(fd);
+ safe_free(data);
} else if (errno == EAGAIN || errno == EWOULDBLOCK) {
/* reinstall handlers */
+ /* XXX This may loop forever */
comm_set_select_handler(fd, COMM_SELECT_READ,
(PF) httpReadReply, (caddr_t) data);
comm_set_select_handler_plus_timeout(fd, COMM_SELECT_TIMEOUT,
(PF) httpReadReplyTimeout, (caddr_t) data, getReadTimeout());
-#endif
} else {
cached_error_entry(entry, ERR_READ_ERROR, xstrerror());
+ comm_close(fd);
+ safe_free(data);
}
- comm_close(fd);
- safe_free(data);
} else if (len == 0) {
/* Connection closed; retrieval done. */
if (!(entry->flag & DELETE_BEHIND))
-/* $Id: wais.cc,v 1.12 1996/03/28 05:39:21 wessels Exp $ */
+/* $Id: wais.cc,v 1.13 1996/03/28 20:42:48 wessels Exp $ */
#include "squid.h"
if (errno == ECONNRESET) {
/* Connection reset by peer */
/* consider it as a EOF */
- entry->expires = cached_curtime;
-
- sprintf(tmp_error_buf, "\n<p>Warning: The Remote Server sent RESET at the end of transmission.\n");
+ if (!(entry->flag & DELETE_BEHIND))
+ entry->expires = cached_curtime + ttlSet(entry);
+ sprintf(tmp_error_buf, "\nWarning: The Remote Server sent RESET at the end of transmission.\n");
storeAppend(entry, tmp_error_buf, strlen(tmp_error_buf));
storeComplete(entry);
+ comm_close(fd);
+ safe_free(data);
+ } else if (errno == EAGAIN || errno == EWOULDBLOCK) {
+ /* reinstall handlers */
+ /* XXX This may loop forever */
+ comm_set_select_handler(fd, COMM_SELECT_READ,
+ (PF) waisReadReply, (caddr_t) data);
+ comm_set_select_handler_plus_timeout(fd, COMM_SELECT_TIMEOUT,
+ (PF) waisReadReplyTimeout, (caddr_t) data, getReadTimeout());
} else {
cached_error_entry(entry, ERR_READ_ERROR, xstrerror());
+ comm_close(fd);
+ safe_free(data);
}
- comm_close(fd);
- safe_free(data);
} else if (len == 0) {
/* Connection closed; retrieval done. */
entry->expires = cached_curtime;
storeStartDeleteBehind(entry);
storeAppend(entry, buf, len);
- comm_set_select_handler(fd, COMM_SELECT_READ, (PF) waisReadReply, (caddr_t) data);
- comm_set_select_handler_plus_timeout(fd, COMM_SELECT_TIMEOUT, (PF) waisReadReplyTimeout,
- (caddr_t) data, getReadTimeout());
-
+ comm_set_select_handler(fd,
+ COMM_SELECT_READ,
+ (PF) waisReadReply,
+ (caddr_t) data);
+ comm_set_select_handler_plus_timeout(fd,
+ COMM_SELECT_TIMEOUT,
+ (PF) waisReadReplyTimeout,
+ (caddr_t) data,
+ getReadTimeout());
} else {
storeAppend(entry, buf, len);
- comm_set_select_handler(fd, COMM_SELECT_READ, (PF) waisReadReply, (caddr_t) data);
- comm_set_select_handler_plus_timeout(fd, COMM_SELECT_TIMEOUT, (PF) waisReadReplyTimeout,
- (caddr_t) data, getReadTimeout());
+ comm_set_select_handler(fd,
+ COMM_SELECT_READ,
+ (PF) waisReadReply,
+ (caddr_t) data);
+ comm_set_select_handler_plus_timeout(fd,
+ COMM_SELECT_TIMEOUT,
+ (PF) waisReadReplyTimeout,
+ (caddr_t) data,
+ getReadTimeout());
}
}
safe_free(data);
} else {
/* Schedule read reply. */
- comm_set_select_handler(fd, COMM_SELECT_READ, (PF) waisReadReply, (caddr_t) data);
- comm_set_select_handler_plus_timeout(fd, COMM_SELECT_TIMEOUT, (PF) waisReadReplyTimeout,
- (caddr_t) data, getReadTimeout());
+ comm_set_select_handler(fd,
+ COMM_SELECT_READ,
+ (PF) waisReadReply,
+ (caddr_t) data);
+ comm_set_select_handler_plus_timeout(fd,
+ COMM_SELECT_TIMEOUT,
+ (PF) waisReadReplyTimeout,
+ (caddr_t) data,
+ getReadTimeout());
}
safe_free(buf); /* Allocated by waisSendRequest. */
}