summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2000-12-18 16:13:37 +0000
committerDaniel Stenberg <daniel@haxx.se>2000-12-18 16:13:37 +0000
commit184ad46a27dc65a82faa2cda76fe91bcca3404cf (patch)
tree34cd8bc1c63d52318f6c686f0da4f47d96712fc4
parent74d35416a2ee4d0baa84e2b5daab2fc96dda5a58 (diff)
downloadgnurl-184ad46a27dc65a82faa2cda76fe91bcca3404cf.tar.gz
gnurl-184ad46a27dc65a82faa2cda76fe91bcca3404cf.tar.bz2
gnurl-184ad46a27dc65a82faa2cda76fe91bcca3404cf.zip
fixed accept() for memory debugging
-rw-r--r--lib/ftp.c2
-rw-r--r--lib/memdebug.c9
-rw-r--r--lib/memdebug.h4
-rwxr-xr-xmemanalyze.pl5
4 files changed, 20 insertions, 0 deletions
diff --git a/lib/ftp.c b/lib/ftp.c
index 705d090c8..93f1d3048 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -197,6 +197,8 @@ static CURLcode AllowServerConnect(struct UrlData *data,
getsockname(sock, (struct sockaddr *) &add, (int *)&size);
s=accept(sock, (struct sockaddr *) &add, (int *)&size);
+ sclose(sock); /* close the first socket */
+
if( -1 == s) {
/* DIE! */
failf(data, "Error accept()ing server connect");
diff --git a/lib/memdebug.c b/lib/memdebug.c
index cbd860ec1..1bd945e0d 100644
--- a/lib/memdebug.c
+++ b/lib/memdebug.c
@@ -133,6 +133,15 @@ int curl_socket(int domain, int type, int protocol, int line, char *source)
return sockfd;
}
+int curl_accept(int s, struct sockaddr *addr, int *addrlen,
+ int line, char *source)
+{
+ int sockfd=(accept)(s, addr, addrlen);
+ fprintf(logfile?logfile:stderr, "FD %s:%d accept() = %d\n",
+ source, line, sockfd);
+ return sockfd;
+}
+
/* this is our own defined way to close sockets on *ALL* platforms */
int curl_sclose(int sockfd, int line, char *source)
{
diff --git a/lib/memdebug.h b/lib/memdebug.h
index 21330a0b2..86271b5b2 100644
--- a/lib/memdebug.h
+++ b/lib/memdebug.h
@@ -9,6 +9,8 @@ void curl_memdebug(char *logname);
/* file descriptor manipulators */
int curl_socket(int domain, int type, int protocol, int, char *);
int curl_sclose(int sockfd, int, char *);
+int curl_accept(int s, struct sockaddr *addr, int *addrlen,
+ int line, char *source);
/* Set this symbol on the command-line, recompile all lib-sources */
#define strdup(ptr) curl_dostrdup(ptr, __LINE__, __FILE__)
@@ -18,6 +20,8 @@ int curl_sclose(int sockfd, int, char *);
#define socket(domain,type,protocol)\
curl_socket(domain,type,protocol,__LINE__,__FILE__)
+#define accept(sock,addr,len)\
+ curl_accept(sock,addr,len,__LINE__,__FILE__)
/* sclose is probably already defined, redefine it! */
#undef sclose
diff --git a/memanalyze.pl b/memanalyze.pl
index 48fff8f27..aa8dddb13 100755
--- a/memanalyze.pl
+++ b/memanalyze.pl
@@ -84,6 +84,11 @@ while(<STDIN>) {
$getfile{$1}="$source:$linenum";
$openfile++;
}
+ elsif($function =~ /accept\(\) = (\d*)/) {
+ $filedes{$1}=1;
+ $getfile{$1}="$source:$linenum";
+ $openfile++;
+ }
elsif($function =~ /sclose\((\d*)\)/) {
if($filedes{$1} != 1) {
print "Close without open: $line\n";