* line in a response or continue reading. */
int sockfd = conn->firstsocket;
- int nread; /* total size read */
int perline; /* count bytes per line */
bool keepon=TRUE;
ssize_t gotbytes;
ptr=buf;
line_start = buf;
- nread=0;
+ *nreadp=0;
perline=0;
keepon=TRUE;
- while((nread<BUFSIZE) && (keepon && !result)) {
+ while((*nreadp<BUFSIZE) && (keepon && !result)) {
/* check and reset timeout value every lap */
if(data->set.timeout)
/* if timeout is requested, find out how much remaining time we have */
ftp->cache_size = 0; /* zero the size just in case */
}
else {
- int res = Curl_read(conn, sockfd, ptr, BUFSIZE-nread, &gotbytes);
+ int res = Curl_read(conn, sockfd, ptr, BUFSIZE-*nreadp, &gotbytes);
if(res < 0)
/* EWOULDBLOCK */
continue; /* go looping again */
* line */
int i;
- nread += gotbytes;
+ *nreadp += gotbytes;
for(i = 0; i < gotbytes; ptr++, i++) {
perline++;
if(*ptr=='\n') {
if(ftpcode)
*ftpcode=code; /* return the initial number like this */
- *nreadp = nread; /* total amount of bytes read */
return result;
}
/* no need to duplicate them, the data struct won't change */
ftp->user = data->state.user;
ftp->passwd = data->state.passwd;
-
- ftp->response_time = 3600; /* default response time-out */
+ ftp->response_time = 3600; /* set default response time-out */
if (data->set.tunnel_thru_httpproxy) {
/* We want "seamless" FTP operations through HTTP proxy tunnel */
conn->secondarysocket = -1;
if(!ftp->no_transfer) {
- /* now let's see what the server says about the transfer we just
- performed: */
+ /* Let's see what the server says about the transfer we just performed,
+ but lower the timeout as sometimes this connection has died while
+ the data has been transfered. This happens when doing through NATs
+ etc that abandon old silent connections.
+ */
+ ftp->response_time = 60; /* give it only a minute for now */
+
result = Curl_GetFTPResponse(&nread, conn, &ftpcode);
+
+ ftp->response_time = 3600; /* set this back to one hour waits */
+
+ if(!nread && (CURLE_OPERATION_TIMEDOUT == result)) {
+ failf(data, "control connection looks dead");
+ return result;
+ }
+
if(result)
return result;