summaryrefslogtreecommitdiff
path: root/lib/memdebug.c
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2011-07-29 13:25:52 +0200
committerYang Tse <yangsita@gmail.com>2011-07-29 13:27:10 +0200
commitbcbac913d65275cc9e22534a8b4cda6994b75977 (patch)
treece057b99e26849afbf3421790dd9fe54134bf1d2 /lib/memdebug.c
parent5cdbfa1837394c3ac06828c8322d1441b084aec1 (diff)
downloadcurl-bcbac913d65275cc9e22534a8b4cda6994b75977.tar.gz
socketpair() usage tracking to allow fd leak detection
Diffstat (limited to 'lib/memdebug.c')
-rw-r--r--lib/memdebug.c18
1 files changed, 18 insertions, 0 deletions
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)
{