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.
This commit is contained in:
jkh 1996-06-17 23:16:04 +00:00
parent cdc8a8df54
commit 6690bcda70

View File

@ -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;
}
}