Curl_resolv() now returns a different struct, and it contains a reference

counter so that the caller needs to decrease that counter when done with
the returned data.

If compiled with MALLOCDEBUG I've added some extra checking that the counter
is decreased before a handle is closed etc.
This commit is contained in:
Daniel Stenberg
2002-11-05 10:51:41 +00:00
parent 73d996bf26
commit 2cff251863
10 changed files with 164 additions and 115 deletions

View File

@@ -1184,7 +1184,6 @@ CURLcode ftp_use_port(struct connectdata *conn)
*/
struct sockaddr_in sa;
struct hostent *h=NULL;
char *hostdataptr=NULL;
unsigned short porttouse;
char myhost[256] = "";
bool sa_filled_in = FALSE;
@@ -1215,6 +1214,9 @@ CURLcode ftp_use_port(struct connectdata *conn)
sa_filled_in = TRUE; /* the sa struct is filled in */
}
if(h)
h->inuse--; /* when we return from here, we can forget about this */
if ( h || sa_filled_in) {
if( (portsock = socket(AF_INET, SOCK_STREAM, 0)) >= 0 ) {
int size;
@@ -1250,19 +1252,16 @@ CURLcode ftp_use_port(struct connectdata *conn)
if ( listen(portsock, 1) < 0 ) {
failf(data, "listen(2) failed on socket");
free(hostdataptr);
return CURLE_FTP_PORT_FAILED;
}
}
else {
failf(data, "bind(2) failed on socket");
free(hostdataptr);
return CURLE_FTP_PORT_FAILED;
}
}
else {
failf(data, "socket(2) failed (%s)");
free(hostdataptr);
return CURLE_FTP_PORT_FAILED;
}
}
@@ -1332,7 +1331,7 @@ CURLcode ftp_use_pasv(struct connectdata *conn,
char *buf = data->state.buffer; /* this is our buffer */
int ftpcode; /* receive FTP response codes in this */
CURLcode result;
Curl_addrinfo *addr=NULL;
struct Curl_dns_entry *addr=NULL;
Curl_ipconnect *conninfo;
/*
@@ -1480,6 +1479,8 @@ CURLcode ftp_use_pasv(struct connectdata *conn,
&conninfo,
connected);
addr->inuse--; /* we're done using this address */
/*
* When this is used from the multi interface, this might've returned with
* the 'connected' set to FALSE and thus we are now awaiting a non-blocking