]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
memdebug: stop tracking send and recv
authorDaniel Stenberg <daniel@haxx.se>
Thu, 25 Dec 2025 22:21:34 +0000 (23:21 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 26 Dec 2025 09:27:27 +0000 (10:27 +0100)
- 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

lib/curl_setup.h
lib/memdebug.c
lib/multi.c
lib/vquic/vquic.c
scripts/checksrc.pl
src/tool_cb_rea.c
src/tool_doswin.c
tests/memanalyzer.pm

index 9027e30dcf83618d8dd3fa8c0b8d51ea574ffb46..05b4aff64e7ecdf6c32c8a2d65bc0fe16e9be4de 100644 (file)
@@ -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 */
 
index b390e81dac0aa7ff90bafff87f1e34eb94b4ef0b..2dd3aa0bfa61321ec43e30fc1ff7c778ea47e8a1 100644 (file)
@@ -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],
index 7c03de20a2a2d646721b5a660ea313723726f57b..1dd858d1898f34d791eb598c3fff73095cd83eeb 100644 (file)
@@ -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
 
index 5869e70bbc697c024c76bd687299c774f575418f..a09b2b719318b603d8c2d55eeab4b9041da5cd73 100644 (file)
@@ -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)
     ;
 
index cd5817a3828f6b0ac7f3f0e1c22d78254cb06d67..fc9fbd920904b887bb0039020e4c20cfeafe3722 100755 (executable)
@@ -100,9 +100,7 @@ my %banfunc = (
     "open" => 1,
     "printf" => 1,
     "realloc" => 1,
-    "recv" => 1,
     "rename" => 1,
-    "send" => 1,
     "snprintf" => 1,
     "socket" => 1,
     "socketpair" => 1,
index e896e35cdad19b74fcee7ce4e9973fb3f0a49753..5ad4f7e0b21248c2c8210d5cb16be4b5b628aa2e 100644 (file)
@@ -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;
index c6cfb14c89da4a69ee54d65ed0d69de4b203c3b1..36145bc4b4a4a1616bbee38961afc7640d7d36f4 100644 (file)
@@ -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)
index 8c7515e4ff047198ada4405f28ba224ea618272b..d33f56419a20d5353cb1a08ff4485c232b7406f9 100644 (file)
@@ -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";
     }