From: Daniel Stenberg Date: Thu, 25 Dec 2025 22:21:34 +0000 (+0100) Subject: memdebug: stop tracking send and recv X-Git-Tag: rc-8_18_0-3~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a585cc35e57fc06806443207e31a244c9df029bb;p=thirdparty%2Fcurl.git memdebug: stop tracking send and recv - they rarely catch any problems - we have other ways to test different send/recv problems - the number of such calls vary much more per invoke than others, making memdebugging harder - reducing the total number of fallible functions per test is good - they were not used as intended anyway Closes #20097 --- diff --git a/lib/curl_setup.h b/lib/curl_setup.h index 9027e30dcf..05b4aff64e 100644 --- a/lib/curl_setup.h +++ b/lib/curl_setup.h @@ -1003,18 +1003,6 @@ CURL_EXTERN int curl_dbg_socketpair(int domain, int type, int protocol, int line, const char *source); #endif -/* send/receive sockets */ -CURL_EXTERN SEND_TYPE_RETV curl_dbg_send(SEND_TYPE_ARG1 sockfd, - SEND_QUAL_ARG2 SEND_TYPE_ARG2 buf, - SEND_TYPE_ARG3 len, - SEND_TYPE_ARG4 flags, int line, - const char *source); -CURL_EXTERN RECV_TYPE_RETV curl_dbg_recv(RECV_TYPE_ARG1 sockfd, - RECV_TYPE_ARG2 buf, - RECV_TYPE_ARG3 len, - RECV_TYPE_ARG4 flags, int line, - const char *source); - /* FILE functions */ CURL_EXTERN int curl_dbg_fclose(FILE *file, int line, const char *source); CURL_EXTERN ALLOC_FUNC FILE *curl_dbg_fopen(const char *file, const char *mode, @@ -1045,8 +1033,6 @@ CURL_EXTERN ALLOC_FUNC FILE *curl_dbg_fdopen(int filedes, const char *mode, #define CURL_ACCEPT4(sock, addr, len, flags) \ curl_dbg_accept4(sock, addr, len, flags, __LINE__, __FILE__) #endif -#define CURL_SEND(a, b, c, d) curl_dbg_send(a, b, c, d, __LINE__, __FILE__) -#define CURL_RECV(a, b, c, d) curl_dbg_recv(a, b, c, d, __LINE__, __FILE__) #else /* !CURLDEBUG */ @@ -1063,8 +1049,6 @@ CURL_EXTERN ALLOC_FUNC FILE *curl_dbg_fdopen(int filedes, const char *mode, #ifdef HAVE_ACCEPT4 #define CURL_ACCEPT4 accept4 #endif -#define CURL_SEND send -#define CURL_RECV recv #endif /* CURLDEBUG */ diff --git a/lib/memdebug.c b/lib/memdebug.c index b390e81dac..2dd3aa0bfa 100644 --- a/lib/memdebug.c +++ b/lib/memdebug.c @@ -402,37 +402,6 @@ curl_socket_t curl_dbg_socket(int domain, int type, int protocol, return sockfd; } -SEND_TYPE_RETV curl_dbg_send(SEND_TYPE_ARG1 sockfd, - SEND_QUAL_ARG2 SEND_TYPE_ARG2 buf, - SEND_TYPE_ARG3 len, SEND_TYPE_ARG4 flags, - int line, const char *source) -{ - SEND_TYPE_RETV rc; - if(countcheck("send", line, source)) - return -1; - /* !checksrc! disable BANNEDFUNC 1 */ - rc = send(sockfd, buf, len, flags); - if(source) - curl_dbg_log("SEND %s:%d send(%lu) = %ld\n", - source, line, (unsigned long)len, (long)rc); - return rc; -} - -RECV_TYPE_RETV curl_dbg_recv(RECV_TYPE_ARG1 sockfd, RECV_TYPE_ARG2 buf, - RECV_TYPE_ARG3 len, RECV_TYPE_ARG4 flags, - int line, const char *source) -{ - RECV_TYPE_RETV rc; - if(countcheck("recv", line, source)) - return -1; - /* !checksrc! disable BANNEDFUNC 1 */ - rc = recv(sockfd, buf, len, flags); - if(source) - curl_dbg_log("RECV %s:%d recv(%lu) = %ld\n", - source, line, (unsigned long)len, (long)rc); - return rc; -} - #ifdef HAVE_SOCKETPAIR int curl_dbg_socketpair(int domain, int type, int protocol, curl_socket_t socket_vector[2], diff --git a/lib/multi.c b/lib/multi.c index 7c03de20a2..1dd858d189 100644 --- a/lib/multi.c +++ b/lib/multi.c @@ -1332,7 +1332,7 @@ static void reset_socket_fdwrite(curl_socket_t s) int t; int l = (int)sizeof(t); if(!getsockopt(s, SOL_SOCKET, SO_TYPE, (char *)&t, &l) && t == SOCK_STREAM) - CURL_SEND(s, NULL, 0, 0); + send(s, NULL, 0, 0); } #endif diff --git a/lib/vquic/vquic.c b/lib/vquic/vquic.c index 5869e70bbc..a09b2b7193 100644 --- a/lib/vquic/vquic.c +++ b/lib/vquic/vquic.c @@ -199,8 +199,8 @@ static CURLcode do_sendmsg(struct Curl_cfilter *cf, *psent = 0; - while((rv = CURL_SEND(qctx->sockfd, (const char *)pkt, - (SEND_TYPE_ARG3)pktlen, 0)) == -1 && + while((rv = send(qctx->sockfd, (const char *)pkt, + (SEND_TYPE_ARG3)pktlen, 0)) == -1 && SOCKERRNO == SOCKEINTR) ; diff --git a/scripts/checksrc.pl b/scripts/checksrc.pl index cd5817a382..fc9fbd9209 100755 --- a/scripts/checksrc.pl +++ b/scripts/checksrc.pl @@ -100,9 +100,7 @@ my %banfunc = ( "open" => 1, "printf" => 1, "realloc" => 1, - "recv" => 1, "rename" => 1, - "send" => 1, "snprintf" => 1, "socket" => 1, "socketpair" => 1, diff --git a/src/tool_cb_rea.c b/src/tool_cb_rea.c index e896e35cda..5ad4f7e0b2 100644 --- a/src/tool_cb_rea.c +++ b/src/tool_cb_rea.c @@ -120,7 +120,7 @@ size_t tool_read_cb(char *buffer, size_t sz, size_t nmemb, void *userdata) execute */ if(per->uploadfile && !strcmp(per->uploadfile, ".") && per->infd > 0) { #if defined(_WIN32) && !defined(CURL_WINDOWS_UWP) - rc = CURL_RECV(per->infd, buffer, curlx_uztosi(sz * nmemb), 0); + rc = recv(per->infd, buffer, curlx_uztosi(sz * nmemb), 0); if(rc < 0) { if(SOCKERRNO == SOCKEWOULDBLOCK) { errno = 0; diff --git a/src/tool_doswin.c b/src/tool_doswin.c index c6cfb14c89..36145bc4b4 100644 --- a/src/tool_doswin.c +++ b/src/tool_doswin.c @@ -781,7 +781,7 @@ static DWORD WINAPI win_stdin_thread_func(void *thread_data) break; if(n == 0) break; - nwritten = CURL_SEND(socket_w, buffer, n, 0); + nwritten = send(socket_w, buffer, n, 0); if(nwritten == SOCKET_ERROR) break; if((DWORD)nwritten != n) diff --git a/tests/memanalyzer.pm b/tests/memanalyzer.pm index 8c7515e4ff..d33f56419a 100644 --- a/tests/memanalyzer.pm +++ b/tests/memanalyzer.pm @@ -63,8 +63,6 @@ sub memanalyze { my $reallocs = 0; my $strdups = 0; my $wcsdups = 0; - my $sends = 0; - my $recvs = 0; my $sockets = 0; $memsum = 0; # the total number of memory allocated over the lifetime @@ -346,14 +344,6 @@ sub memanalyze { elsif($_ =~ /^GETNAME ([^ ]*):(\d*) (.*)/) { # not much to do } - # SEND url.c:1901 send(83) = 83 - elsif($_ =~ /^SEND ([^ ]*):(\d*) (.*)/) { - $sends++; - } - # RECV url.c:1901 recv(102400) = 256 - elsif($_ =~ /^RECV ([^ ]*):(\d*) (.*)/) { - $recvs++; - } # ADDR url.c:1282 getaddrinfo() = 0x5ddd elsif($_ =~ /^ADDR ([^ ]*):(\d*) (.*)/) { @@ -445,11 +435,9 @@ sub memanalyze { "Strdups: $strdups\n", "Wcsdups: $wcsdups\n", "Frees: $frees\n", - "Sends: $sends\n", - "Recvs: $recvs\n", "Sockets: $sockets\n", "Allocations: ".($mallocs + $callocs + $reallocs + $strdups + $wcsdups)."\n", - "Operations: ".($mallocs + $callocs + $reallocs + $strdups + $wcsdups + $sends + $recvs + $sockets)."\n", + "Operations: ".($mallocs + $callocs + $reallocs + $strdups + $wcsdups + $sockets)."\n", "Maximum allocated: $maxmem\n", "Total allocated: $memsum\n"; }