From 2379c52210dc2f98ef1f2e5dad773f8ed6f528c2 Mon Sep 17 00:00:00 2001 From: "Jordan K. Hubbard" Date: Mon, 17 Jun 1996 23:16:04 +0000 Subject: [PATCH] Manage control connections a little better for the URL routines. This will do as a stop-gap until I figure out a more fault-tolerant way of having deferred closes against the control connection work without blocking. --- lib/libftpio/ftpio.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/libftpio/ftpio.c b/lib/libftpio/ftpio.c index da451b8e64fa..bfc3a667946e 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.4 1996/06/17 20:36:57 jkh Exp $ + * $Id: ftpio.c,v 1.5 1996/06/17 22:10:15 jkh Exp $ * */ @@ -238,13 +238,17 @@ ftpGetURL(char *url, char *user, char *passwd) { char host[255], name[255]; int port; - FILE *fp, *fp2; + static FILE *fp = NULL; + FILE *fp2; + 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); if (fp) { fp2 = ftpGet(fp, name, NULL); - fclose(fp); return fp2; } } @@ -256,13 +260,17 @@ ftpPutURL(char *url, char *user, char *passwd) { char host[255], name[255]; int port; - FILE *fp, *fp2; + static FILE *fp = NULL; + FILE *fp2; + 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); if (fp) { fp2 = ftpPut(fp, name); - fclose(fp); return fp2; } }