]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
lib: drop curlx_getpid, use fake pid in SMB
authorDaniel Stenberg <daniel@haxx.se>
Fri, 9 May 2025 07:36:05 +0000 (09:36 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 9 May 2025 08:01:30 +0000 (10:01 +0200)
It was not a function properly exposed in the curlx set. SMB cannot
possibly need to send a real pid, now sends a made up number.

The only real users of this function are test servers, so move the logic
over there.

Closes #17298

lib/curl_setup.h
lib/smb.c
tests/server/dnsd.c
tests/server/rtspd.c
tests/server/sws.c
tests/server/tftpd.c
tests/server/util.c

index 29061659d2ab4316f2c38aff8d84277d447e7564..1d484c61ab40012ff14df8a042aa25e5b33d7705 100644 (file)
 #include <curl/stdcheaders.h>
 #endif
 
-#ifdef _WIN32
-#define curlx_getpid() GetCurrentProcessId()
-#else
-#define curlx_getpid() getpid()
-#endif
-
 /*
  * Large file (>2Gb) support using Win32 functions.
  */
index 133e250c0ee8ecbe26e5fb38f9ad9b609461cfbc..c8d03ddbc491324db61bacbb930675121c4db03c 100644 (file)
--- a/lib/smb.c
+++ b/lib/smb.c
@@ -596,7 +596,7 @@ static void smb_format_message(struct smb_conn *smbc,
                                struct smb_header *h,
                                unsigned char cmd, size_t len)
 {
-  unsigned int pid;
+  const unsigned int pid = 0xbad71d; /* made up */
 
   memset(h, 0, sizeof(*h));
   h->nbt_length = htons((unsigned short) (sizeof(*h) - sizeof(unsigned int) +
@@ -607,7 +607,6 @@ static void smb_format_message(struct smb_conn *smbc,
   h->flags2 = smb_swap16(SMB_FLAGS2_IS_LONG_NAME | SMB_FLAGS2_KNOWS_LONG_NAME);
   h->uid = smb_swap16(smbc->uid);
   h->tid = smb_swap16(req->tid);
-  pid = (unsigned int)curlx_getpid();
   h->pid_high = smb_swap16((unsigned short)(pid >> 16));
   h->pid = smb_swap16((unsigned short) pid);
 }
index 0c83dac8ba181844894796f5887b8ca1073ef98e..dce05c63eca0233683b206b0511e8f75d3e7c0bb 100644 (file)
@@ -668,7 +668,7 @@ dnsd_cleanup:
 
   if(got_exit_signal) {
     logmsg("========> %s dnsd (port: %d pid: %ld) exits with signal (%d)",
-           ipv_inuse, (int)port, (long)curlx_getpid(), exit_signal);
+           ipv_inuse, (int)port, (long)our_getpid(), exit_signal);
     /*
      * To properly set the return status of the process we
      * must raise the same signal SIGINT or SIGTERM that we
index 71d185299a0e64a10f797a85b64ee899f1110e61..65b8b09f0299d14224f62ac1efd6dea5c38127f6 100644 (file)
@@ -1354,7 +1354,7 @@ server_cleanup:
 
   if(got_exit_signal) {
     logmsg("========> %s rtspd (port: %d pid: %ld) exits with signal (%d)",
-           ipv_inuse, (int)port, (long)curlx_getpid(), exit_signal);
+           ipv_inuse, (int)port, (long)our_getpid(), exit_signal);
     /*
      * To properly set the return status of the process we
      * must raise the same signal SIGINT or SIGTERM that we
index d7471c61072cfc30a4bfddb9028382569932ad5c..15ae75e4c7f1c811202e824604ca06a05fa7141e 100644 (file)
@@ -2511,7 +2511,7 @@ sws_cleanup:
 
   if(got_exit_signal) {
     logmsg("========> %s sws (%s pid: %ld) exits with signal (%d)",
-           socket_type, location_str, (long)curlx_getpid(), exit_signal);
+           socket_type, location_str, (long)our_getpid(), exit_signal);
     /*
      * To properly set the return status of the process we
      * must raise the same signal SIGINT or SIGTERM that we
index 30f9be9efff80f51cd1782853585b2de7f6eb581..f969175467f9f89f4873ec2a2f93b663b4a0ae9d 100644 (file)
@@ -857,7 +857,7 @@ tftpd_cleanup:
 
   if(got_exit_signal) {
     logmsg("========> %s tftpd (port: %d pid: %ld) exits with signal (%d)",
-           ipv_inuse, (int)port, (long)curlx_getpid(), exit_signal);
+           ipv_inuse, (int)port, (long)our_getpid(), exit_signal);
     /*
      * To properly set the return status of the process we
      * must raise the same signal SIGINT or SIGTERM that we
index 25f848ed29bb5e4cc21acfef4030836da444fbe0..f884cf8f6c2863f76418f32638d027597ae2a56e 100644 (file)
@@ -295,11 +295,15 @@ int wait_ms(timediff_t timeout_ms)
   return r;
 }
 
+#ifdef _WIN32
+#define t_getpid() GetCurrentProcessId()
+#else
+#define t_getpid() getpid()
+#endif
+
 curl_off_t our_getpid(void)
 {
-  curl_off_t pid;
-
-  pid = (curl_off_t)curlx_getpid();
+  curl_off_t pid = (curl_off_t)t_getpid();
 #ifdef _WIN32
   /* store pid + MAX_PID to avoid conflict with Cygwin/msys PIDs, see also:
    * - 2019-01-31: https://cygwin.com/git/?p=newlib-cygwin.git;a=commit;