aboutsummaryrefslogtreecommitdiff
path: root/lib/memdebug.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2017-10-10 16:56:35 +0200
committerDaniel Stenberg <daniel@haxx.se>2017-10-14 17:40:12 +0200
commitad164eceb3ce6721d34a3418e0dacabd4f4ff904 (patch)
tree7ae3bdc1411b57b96b68a9a0ccef16904ec22c98 /lib/memdebug.c
parent4af3c777a9996f32c5a23db0ecf29996197dfdbc (diff)
memdebug: trace send, recv and socket
... to allow them to be included in torture tests too. closes #1980
Diffstat (limited to 'lib/memdebug.c')
-rw-r--r--lib/memdebug.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/lib/memdebug.c b/lib/memdebug.c
index 0eb249ce9..8e61aba71 100644
--- a/lib/memdebug.c
+++ b/lib/memdebug.c
@@ -343,7 +343,12 @@ curl_socket_t curl_socket(int domain, int type, int protocol,
"FD %s:%d socket() = %ld\n" :
"FD %s:%d socket() = %zd\n";
- curl_socket_t sockfd = socket(domain, type, protocol);
+ curl_socket_t sockfd;
+
+ if(countcheck("socket", line, source))
+ return CURL_SOCKET_BAD;
+
+ sockfd = socket(domain, type, protocol);
if(source && (sockfd != CURL_SOCKET_BAD))
curl_memlog(fmt, source, line, sockfd);
@@ -351,6 +356,32 @@ curl_socket_t curl_socket(int domain, int type, int protocol,
return sockfd;
}
+ssize_t curl_dosend(int sockfd, const void *buf, size_t len, int flags,
+ int line, const char *source)
+{
+ ssize_t rc;
+ if(countcheck("send", line, source))
+ return -1;
+ rc = send(sockfd, buf, len, flags);
+ if(source)
+ curl_memlog("SEND %s:%d send(%zu) = %zd\n",
+ source, line, len, rc);
+ return rc;
+}
+
+ssize_t curl_dorecv(int sockfd, void *buf, size_t len, int flags,
+ int line, const char *source)
+{
+ ssize_t rc;
+ if(countcheck("recv", line, source))
+ return -1;
+ rc = recv(sockfd, buf, len, flags);
+ if(source)
+ curl_memlog("RECV %s:%d recv(%zu) = %zd\n",
+ source, line, len, rc);
+ return rc;
+}
+
#ifdef HAVE_SOCKETPAIR
int curl_socketpair(int domain, int type, int protocol,
curl_socket_t socket_vector[2],