curl-library
Re: libcurl not sending QUIT to terminate control connection
Date: Mon, 19 Jan 2004 00:07:08 +0100 (CET)
On Sun, 18 Jan 2004, Joe Halpin wrote:
> I added the following function
>
> void Curl_ftp_quit(struct connectdata *conn)
> {
> int nread;
> int ftpcode;
>
> (void) Curl_ftpsendf(conn, "%s", "QUIT");
> (void) Curl_GetFTPResponse(&nread, conn, &ftpcode);
> }
Just note that having the (void)s there is not very nice code. Actually caring
about errors is better.
> And called it like this from Curl_disconnect()
>
> if(-1 != conn->sock[FIRSTSOCKET]) {
> /*
> * If this is an ftp connection, then FIRSTSOCKET is the control
> * connection. Send a QUIT message and get any response back
> * before actually closing the connection.
> */
> if(PROT_FTP == conn->protocol)
> Curl_ftp_quit(conn);
>
> sclose(conn->sock[FIRSTSOCKET]);
> }
>
> It crashes in Curl_GETFTPResponse at line 296
>
> memcpy(ptr, ftp->cache, (int)ftp->cache_size);
>
> According to GDB, ftp->cache is an invalid pointer here.
FTP-specific disconnect code should be written in the Curl_ftp_disconnect()
function (which is called from the Curl_disconnect()) function.
My guess is that you called Curl_ftp_quit() after Curl_ftp_disconnect() is
called, and then the ftp struct is cleaned up already!
-- Daniel Stenberg -- http://curl.haxx.se/ -- http://daniel.haxx.se/ [[ Do not send mails to this email address. They won't reach me. ]] ------------------------------------------------------- The SF.Net email is sponsored by EclipseCon 2004 Premiere Conference on Open Tools Development and Integration See the breadth of Eclipse activity. February 3-5 in Anaheim, CA. http://www.eclipsecon.org/osdnReceived on 2004-01-19