fixed accept() for memory debugging
This commit is contained in:
@@ -197,6 +197,8 @@ static CURLcode AllowServerConnect(struct UrlData *data,
|
|||||||
getsockname(sock, (struct sockaddr *) &add, (int *)&size);
|
getsockname(sock, (struct sockaddr *) &add, (int *)&size);
|
||||||
s=accept(sock, (struct sockaddr *) &add, (int *)&size);
|
s=accept(sock, (struct sockaddr *) &add, (int *)&size);
|
||||||
|
|
||||||
|
sclose(sock); /* close the first socket */
|
||||||
|
|
||||||
if( -1 == s) {
|
if( -1 == s) {
|
||||||
/* DIE! */
|
/* DIE! */
|
||||||
failf(data, "Error accept()ing server connect");
|
failf(data, "Error accept()ing server connect");
|
||||||
|
@@ -133,6 +133,15 @@ int curl_socket(int domain, int type, int protocol, int line, char *source)
|
|||||||
return sockfd;
|
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 */
|
/* this is our own defined way to close sockets on *ALL* platforms */
|
||||||
int curl_sclose(int sockfd, int line, char *source)
|
int curl_sclose(int sockfd, int line, char *source)
|
||||||
{
|
{
|
||||||
|
@@ -9,6 +9,8 @@ void curl_memdebug(char *logname);
|
|||||||
/* file descriptor manipulators */
|
/* file descriptor manipulators */
|
||||||
int curl_socket(int domain, int type, int protocol, int, char *);
|
int curl_socket(int domain, int type, int protocol, int, char *);
|
||||||
int curl_sclose(int sockfd, 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 */
|
/* Set this symbol on the command-line, recompile all lib-sources */
|
||||||
#define strdup(ptr) curl_dostrdup(ptr, __LINE__, __FILE__)
|
#define strdup(ptr) curl_dostrdup(ptr, __LINE__, __FILE__)
|
||||||
@@ -18,6 +20,8 @@ int curl_sclose(int sockfd, int, char *);
|
|||||||
|
|
||||||
#define socket(domain,type,protocol)\
|
#define socket(domain,type,protocol)\
|
||||||
curl_socket(domain,type,protocol,__LINE__,__FILE__)
|
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! */
|
/* sclose is probably already defined, redefine it! */
|
||||||
#undef sclose
|
#undef sclose
|
||||||
|
@@ -84,6 +84,11 @@ while(<STDIN>) {
|
|||||||
$getfile{$1}="$source:$linenum";
|
$getfile{$1}="$source:$linenum";
|
||||||
$openfile++;
|
$openfile++;
|
||||||
}
|
}
|
||||||
|
elsif($function =~ /accept\(\) = (\d*)/) {
|
||||||
|
$filedes{$1}=1;
|
||||||
|
$getfile{$1}="$source:$linenum";
|
||||||
|
$openfile++;
|
||||||
|
}
|
||||||
elsif($function =~ /sclose\((\d*)\)/) {
|
elsif($function =~ /sclose\((\d*)\)/) {
|
||||||
if($filedes{$1} != 1) {
|
if($filedes{$1} != 1) {
|
||||||
print "Close without open: $line\n";
|
print "Close without open: $line\n";
|
||||||
|
Reference in New Issue
Block a user