socketpair() usage tracking to allow fd leak detection

This commit is contained in:
Yang Tse 2011-07-29 13:25:52 +02:00
parent 5cdbfa1837
commit bcbac913d6
7 changed files with 156 additions and 30 deletions

View file

@ -285,6 +285,24 @@ curl_socket_t curl_socket(int domain, int type, int protocol,
return sockfd;
}
#ifdef HAVE_SOCKETPAIR
int curl_socketpair(int domain, int type, int protocol,
curl_socket_t socket_vector[2],
int line, const char *source)
{
const char *fmt = (sizeof(curl_socket_t) == sizeof(int)) ?
"FD %s:%d socketpair() = %d %d\n" :
(sizeof(curl_socket_t) == sizeof(long)) ?
"FD %s:%d socketpair() = %ld %ld\n" :
"FD %s:%d socketpair() = %zd %zd\n" ;
int res = socketpair(domain, type, protocol, socket_vector);
if(source && (0 == res))
curl_memlog(fmt, source, line, socket_vector[0], socket_vector[1]);
return res;
}
#endif
curl_socket_t curl_accept(curl_socket_t s, void *saddr, void *saddrlen,
int line, const char *source)
{