diff options
author | njl <njl@FreeBSD.org> | 2002-10-25 01:17:32 +0000 |
---|---|---|
committer | njl <njl@FreeBSD.org> | 2002-10-25 01:17:32 +0000 |
commit | 06c0d543e055fe863043c9596feb551e0cf9c02f (patch) | |
tree | 6aafd9452a5fa806927f199abc7b17b4dcebcb0c /lib/libfetch | |
parent | 6b1611bd949afb58a84ad54e4bbcf960b0ef28b1 (diff) | |
download | FreeBSD-src-06c0d543e055fe863043c9596feb551e0cf9c02f.zip FreeBSD-src-06c0d543e055fe863043c9596feb551e0cf9c02f.tar.gz |
The FTP connection caching needs a better interface -- connections are
closed through _fetch_close() which is the only one who knows the connection
REALLY was closed (since ref -> 0). However, FTP keeps its own local
cached_connection and checks if it is valid by comparing it to NULL. This
is bogus since it may have been freed elsewhere by _fetch_close().
This change checks if we are closing the cached_connection and the ref is 1
(soon to be 0). If so, set cached_connection to NULL so we don't
accidentally reuse it. The REAL fix should be to move connection caching
to the common.c level (_fetch_* functions) and NULL the cache(s) in
_fetch_close(). Then all layers could benefit from caching.
Diffstat (limited to 'lib/libfetch')
-rw-r--r-- | lib/libfetch/ftp.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/libfetch/ftp.c b/lib/libfetch/ftp.c index 0ee7488..f564592 100644 --- a/lib/libfetch/ftp.c +++ b/lib/libfetch/ftp.c @@ -419,6 +419,8 @@ _ftp_closefn(void *v) io->dconn = NULL; DEBUG(fprintf(stderr, "Waiting for final status\n")); r = _ftp_chkerr(io->cconn); + if (io->cconn == cached_connection && io->cconn->ref == 1) + cached_connection = NULL; _fetch_close(io->cconn); free(io); return (r == FTP_TRANSFER_COMPLETE) ? 0 : -1; @@ -833,6 +835,8 @@ static void _ftp_disconnect(conn_t *conn) { (void)_ftp_cmd(conn, "QUIT"); + if (conn == cached_connection && conn->ref == 1) + cached_connection = NULL; _fetch_close(conn); } |