/*
- * $Id: ftp.cc,v 1.156 1997/10/29 22:39:52 wessels Exp $
+ * $Id: ftp.cc,v 1.157 1997/10/30 00:47:48 wessels Exp $
*
* DEBUG: section 9 File Transfer Protocol (FTP)
* AUTHOR: Harvest Derived
ftpState->data.fd = -1;
}
comm_close(ftpState->ctrl.fd);
+ ftpState->ctrl.fd = -1;
}
static void
}
line = get_free_4k_page();
end++;
+ /* XXX there is an ABR bug here. We need to make sure buf is NULL terminated */
for (s = buf; s < end; s += strcspn(s, crlf), s += strspn(s, crlf)) {
linelen = strcspn(s, crlf) + 1;
if (linelen > 4096)
fd_bytes(fd, len, FD_READ);
debug(9, 5) ("ftpReadData: FD %d, Read %d bytes\n", fd, len);
if (len > 0) {
- commSetTimeout(fd, Config.Timeout.read, NULL, NULL);
IOStats.Ftp.reads++;
for (clen = len - 1, bin = 0; clen; bin++)
clen >>= 1;
if (len < 0) {
debug(50, 1) ("ftpReadData: read error: %s\n", xstrerror());
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) {
- commSetSelect(fd, COMM_SELECT_READ, ftpReadData, data, 0);
+ commSetSelect(fd, COMM_SELECT_READ, ftpReadData, data, Config.Timeout.read);
} else {
if (entry->mem_obj->inmem_hi == 0) {
err = xcalloc(1, sizeof(ErrorState));
COMM_SELECT_READ,
ftpReadControlReply,
ftpState,
- 0);
+ Config.Timeout.read);
} else {
if (EBIT_TEST(ftpState->flags, FTP_ISDIR)) {
ftpParseListing(ftpState, len);
assert(ftpState->data.offset == 0);
storeAppend(entry, ftpState->data.buf, len);
}
- commSetSelect(fd, COMM_SELECT_READ, ftpReadData, data, 0);
+ commSetSelect(fd, COMM_SELECT_READ, ftpReadData, data, Config.Timeout.read);
}
}
ftpState->data.buf = xmalloc(SQUID_TCP_SO_RCVBUF);
ftpState->data.size = SQUID_TCP_SO_RCVBUF;
ftpState->data.freefunc = xfree;
- commSetSelect(fd, COMM_SELECT_READ, ftpReadControlReply, ftpState, 0);
+ commSetSelect(fd, COMM_SELECT_READ, ftpReadControlReply, ftpState, Config.Timeout.read);
}
}
COMM_SELECT_READ,
ftpReadControlReply,
ftpState,
- 0);
+ Config.Timeout.read);
}
static void
ftpState->ctrl.size - ftpState->ctrl.offset);
fd_bytes(fd, len, FD_READ);
debug(9, 5) ("ftpReadControlReply: FD %d, Read %d bytes\n", fd, len);
- if (len > 0)
- commSetTimeout(fd, Config.Timeout.read, NULL, NULL);
if (len < 0) {
debug(50, 1) ("ftpReadControlReply: read error: %s\n", xstrerror());
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) {
COMM_SELECT_READ,
ftpReadControlReply,
ftpState,
- 0);
+ Config.Timeout.read);
} else {
if (entry->mem_obj->inmem_hi == 0) {
err = xcalloc(1, sizeof(ErrorState));
ftpState->ctrl.freefunc(oldbuf);
ftpState->ctrl.freefunc = xfree;
}
- commSetSelect(fd, COMM_SELECT_READ, ftpReadControlReply, ftpState, 0);
+ commSetSelect(fd, COMM_SELECT_READ, ftpReadControlReply, ftpState, Config.Timeout.read);
return;
}
for (W = &ftpState->ctrl.message; *W && (*W)->next; W = &(*W)->next);
return;
}
ftpState->data.fd = fd;
- commSetTimeout(fd, Config.Timeout.read, ftpTimeout, ftpState);
snprintf(cbuf, 1024, "PASV\r\n");
ftpWriteCommand(cbuf, ftpState);
ftpState->state = SENT_PASV;
COMM_SELECT_READ,
ftpReadData,
ftpState,
- 0);
+ Config.Timeout.read);
commSetDefer(ftpState->data.fd, protoCheckDeferRead, ftpState->entry);
ftpState->state = READING_DATA;
return;
COMM_SELECT_READ,
ftpReadData,
ftpState,
- 0);
+ Config.Timeout.read);
commSetDefer(ftpState->data.fd, protoCheckDeferRead, ftpState->entry);
ftpState->state = READING_DATA;
+ /* Cancel the timeout on the Control socket and establish one
+ * on the data socket */
+ commSetTimeout(ftpState->ctrl.fd, -1, NULL, NULL);
+ commSetTimeout(ftpState->data.fd, Config.Timeout.read, ftpTimeout, ftpState);
} else {
ftpFail(ftpState);
}
mime_type = mimeGetContentType(filename);
mime_enc = mimeGetContentEncoding(filename);
}
+ BIT_SET(e->flag, DELAY_SENDING);
storeAppendPrintf(e, "HTTP/1.0 200 Gatewaying\r\n");
reply->code = 200;
reply->version = 1.0;
storeAppendPrintf(e, "Last-Modified: %s\r\n", mkrfc1123(ftpState->mdtm));
reply->last_modified = ftpState->mdtm;
}
+ BIT_CLR(e->flag, DELAY_SENDING);
storeAppendPrintf(e, "\r\n");
+ reply->hdr_sz = e->mem_obj->inmem_hi;
storeTimestampsSet(e);
storeSetPublicKey(e);
}