From bcbac913d65275cc9e22534a8b4cda6994b75977 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 29 Jul 2011 13:25:52 +0200 Subject: socketpair() usage tracking to allow fd leak detection --- lib/memdebug.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'lib/memdebug.c') diff --git a/lib/memdebug.c b/lib/memdebug.c index 60d938ade..3e3c1bc4f 100644 --- a/lib/memdebug.c +++ b/lib/memdebug.c @@ -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) { -- cgit v1.2.3