From a48acddc8fb03f1dae5c0e555514f1d7e1c879c7 Mon Sep 17 00:00:00 2001 From: ache Date: Thu, 14 Nov 1996 09:44:09 +0000 Subject: Since ftpPutURL not use hostname cache, optimize it by always closing connection at the end of operation, so it not leave opened file without a reason. --- lib/libftpio/ftpio.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'lib/libftpio') diff --git a/lib/libftpio/ftpio.c b/lib/libftpio/ftpio.c index 5df25b5..447d71a 100644 --- a/lib/libftpio/ftpio.c +++ b/lib/libftpio/ftpio.c @@ -14,7 +14,7 @@ * Turned inside out. Now returns xfers as new file ids, not as a special * `state' of FTP_t * - * $Id: ftpio.c,v 1.17 1996/11/14 05:22:12 ache Exp $ + * $Id: ftpio.c,v 1.18 1996/11/14 06:59:39 ache Exp $ * */ @@ -357,25 +357,17 @@ ftpPutURL(char *url, char *user, char *passwd, int *retcode) { char host[255], name[255]; int port; - static FILE *fp = NULL; - FILE *fp2; + FILE *fp, *fp2; if (retcode) *retcode = 0; - if (fp) { /* Close previous managed connection */ - fclose(fp); - fp = NULL; - } if (get_url_info(url, host, &port, name) == SUCCESS) { fp = ftpLogin(host, user, passwd, port, 0, retcode); if (fp) { fp2 = ftpPut(fp, name); - if (!fp2) { - if (retcode) - *retcode = ftpErrno(fp); - fclose(fp); - fp = NULL; - } + if (!fp2 && retcode) + *retcode = ftpErrno(fp); + fclose(fp); return fp2; } } -- cgit v1.1