memdebug: trace send, recv and socket

... to allow them to be included in torture tests too.

closes #1980
This commit is contained in:
Daniel Stenberg 2017-10-10 16:56:35 +02:00
parent 4af3c777a9
commit ad164eceb3
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
5 changed files with 73 additions and 18 deletions

View file

@ -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],