gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libmicrohttpd] 04/06: Renamed 'pid' -> 'tid' when used for threads


From: gnunet
Subject: [libmicrohttpd] 04/06: Renamed 'pid' -> 'tid' when used for threads
Date: Mon, 11 Sep 2023 18:51:51 +0200

This is an automated email from the git hooks/post-receive script.

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit a9bc3198c8571bd0ceb074ceb8c94b283a6c6696
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Fri Sep 8 12:03:33 2023 +0300

    Renamed 'pid' -> 'tid' when used for threads
---
 src/microhttpd/connection.c               | 10 +++----
 src/microhttpd/daemon.c                   | 44 +++++++++++++++----------------
 src/microhttpd/internal.h                 |  4 +--
 src/microhttpd/mhd_threads.h              |  8 +++---
 src/microhttpd/response.c                 |  2 +-
 src/testcurl/perf_get_concurrent.c        |  6 ++---
 src/testcurl/test_digestauth_concurrent.c |  6 ++---
 7 files changed, 40 insertions(+), 40 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index c6682927..50a5de32 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -1151,7 +1151,7 @@ MHD_connection_close_ (struct MHD_Connection *connection,
   mhd_assert (! connection->suspended);
 #ifdef MHD_USE_THREADS
   mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
-               MHD_thread_ID_is_current_thread_ (connection->pid) );
+               MHD_thread_ID_is_current_thread_ (connection->tid) );
 #endif /* MHD_USE_THREADS */
   if ( (NULL != daemon->notify_completed) &&
        (connection->rq.client_aware) )
@@ -1195,7 +1195,7 @@ MHD_connection_finish_forward_ (struct MHD_Connection 
*connection)
 #ifdef MHD_USE_THREADS
   mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
                (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) || \
-               MHD_thread_ID_is_current_thread_ (daemon->pid) );
+               MHD_thread_ID_is_current_thread_ (daemon->tid) );
 #endif /* MHD_USE_THREADS */
 
   if (0 == (daemon->options & MHD_USE_TLS))
@@ -6248,7 +6248,7 @@ cleanup_connection (struct MHD_Connection *connection)
   struct MHD_Daemon *daemon = connection->daemon;
 #ifdef MHD_USE_THREADS
   mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
-               MHD_thread_ID_is_current_thread_ (connection->pid) );
+               MHD_thread_ID_is_current_thread_ (connection->tid) );
   mhd_assert (NULL == daemon->worker_pool);
 #endif /* MHD_USE_THREADS */
 
@@ -6455,7 +6455,7 @@ MHD_connection_handle_idle (struct MHD_Connection 
*connection)
   enum MHD_Result ret;
 #ifdef MHD_USE_THREADS
   mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
-               MHD_thread_ID_is_current_thread_ (connection->pid) );
+               MHD_thread_ID_is_current_thread_ (connection->tid) );
 #endif /* MHD_USE_THREADS */
   /* 'daemon' is not used if epoll is not available and asserts are disabled */
   (void) daemon; /* Mute compiler warning */
@@ -7139,7 +7139,7 @@ MHD_queue_response (struct MHD_Connection *connection,
 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
   if ( (! connection->suspended) &&
        (0 != (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) &&
-       (! MHD_thread_ID_is_current_thread_ (connection->pid)) )
+       (! MHD_thread_ID_is_current_thread_ (connection->tid)) )
   {
 #ifdef HAVE_MESSAGES
     MHD_DLOG (daemon,
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 9c1315e7..36c67074 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -1322,7 +1322,7 @@ process_urh (struct MHD_UpgradeResponseHandle *urh)
 
 #ifdef MHD_USE_THREADS
   mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
-               MHD_thread_ID_is_current_thread_ (connection->pid) );
+               MHD_thread_ID_is_current_thread_ (connection->tid) );
 #endif /* MHD_USE_THREADS */
   if (daemon->shutdown)
   {
@@ -1670,7 +1670,7 @@ thread_main_connection_upgrade (struct MHD_Connection 
*con)
   struct MHD_Daemon *daemon = con->daemon;
 
   mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
-               MHD_thread_ID_is_current_thread_ (con->pid) );
+               MHD_thread_ID_is_current_thread_ (con->tid) );
   /* Here, we need to bi-directionally forward
      until the application tells us that it is done
      with the socket; */
@@ -1896,7 +1896,7 @@ thread_main_handle_connection (void *data)
   const bool use_poll = 0;
 #endif /* ! HAVE_POLL */
   bool was_suspended = false;
-  MHD_thread_init_ (&(con->pid));
+  MHD_thread_init_ (&(con->tid));
 
   while ( (! daemon->shutdown) &&
           (MHD_CONNECTION_CLOSED != con->state) )
@@ -2743,7 +2743,7 @@ new_connection_process_ (struct MHD_Daemon *daemon,
   /* Function manipulate connection and timeout DL-lists,
    * must be called only within daemon thread. */
   mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
-               MHD_thread_ID_is_current_thread_ (daemon->pid) );
+               MHD_thread_ID_is_current_thread_ (daemon->tid) );
   mhd_assert (NULL == daemon->worker_pool);
 #endif /* MHD_USE_THREADS */
 
@@ -2806,7 +2806,7 @@ new_connection_process_ (struct MHD_Daemon *daemon,
       if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
       {
         mhd_assert (0 == (daemon->options & MHD_USE_EPOLL));
-        if (! MHD_create_named_thread_ (&connection->pid,
+        if (! MHD_create_named_thread_ (&connection->tid,
                                         "MHD-connection",
                                         daemon->thread_stack_size,
                                         &thread_main_handle_connection,
@@ -2836,7 +2836,7 @@ new_connection_process_ (struct MHD_Daemon *daemon,
 #endif /* ! MHD_USE_THREADS */
       { /* No 'thread-per-connection' */
 #ifdef MHD_USE_THREADS
-        connection->pid = daemon->pid;
+        connection->tid = daemon->tid;
 #endif /* MHD_USE_THREADS */
 #ifdef EPOLL_SUPPORT
         if (0 != (daemon->options & MHD_USE_EPOLL))
@@ -3102,7 +3102,7 @@ internal_suspend_connection_ (struct MHD_Connection 
*connection)
 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
   mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
                (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) || \
-               MHD_thread_ID_is_current_thread_ (daemon->pid) );
+               MHD_thread_ID_is_current_thread_ (daemon->tid) );
   MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
 #endif
   if (connection->resuming)
@@ -3199,7 +3199,7 @@ MHD_suspend_connection (struct MHD_Connection *connection)
 #ifdef MHD_USE_THREADS
   mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
                (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) || \
-               MHD_thread_ID_is_current_thread_ (daemon->pid) );
+               MHD_thread_ID_is_current_thread_ (daemon->tid) );
 #endif /* MHD_USE_THREADS */
 
   if (0 == (daemon->options & MHD_TEST_ALLOW_SUSPEND_RESUME))
@@ -3323,7 +3323,7 @@ resume_suspended_connections (struct MHD_Daemon *daemon)
 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
   mhd_assert (NULL == daemon->worker_pool);
   mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
-               MHD_thread_ID_is_current_thread_ (daemon->pid) );
+               MHD_thread_ID_is_current_thread_ (daemon->tid) );
 #endif
 
   ret = MHD_NO;
@@ -3664,7 +3664,7 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
 
 #ifdef MHD_USE_THREADS
   mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
-               MHD_thread_ID_is_current_thread_ (daemon->pid) );
+               MHD_thread_ID_is_current_thread_ (daemon->tid) );
   mhd_assert (NULL == daemon->worker_pool);
 #endif /* MHD_USE_THREADS */
 
@@ -3888,7 +3888,7 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon)
   struct MHD_Connection *pos;
 #if defined(MHD_USE_POSIX_THREADS) || defined(MHD_USE_W32_THREADS)
   mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
-               MHD_thread_ID_is_current_thread_ (daemon->pid) );
+               MHD_thread_ID_is_current_thread_ (daemon->tid) );
   mhd_assert (NULL == daemon->worker_pool);
 
   MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
@@ -3902,7 +3902,7 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon)
     MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
     if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
          (! pos->thread_joined) &&
-         (! MHD_join_thread_ (pos->pid.handle)) )
+         (! MHD_join_thread_ (pos->tid.handle)) )
       MHD_PANIC (_ ("Failed to join a thread.\n"));
 #endif
 #ifdef UPGRADE_SUPPORT
@@ -4075,7 +4075,7 @@ MHD_get_timeout64 (struct MHD_Daemon *daemon,
 
 #ifdef MHD_USE_THREADS
   mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
-               MHD_thread_ID_is_current_thread_ (daemon->pid) );
+               MHD_thread_ID_is_current_thread_ (daemon->tid) );
 #endif /* MHD_USE_THREADS */
 
   if (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
@@ -5070,7 +5070,7 @@ run_epoll_for_upgrade (struct MHD_Daemon *daemon)
 
 #ifdef MHD_USE_THREADS
   mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
-               MHD_thread_ID_is_current_thread_ (daemon->pid) );
+               MHD_thread_ID_is_current_thread_ (daemon->tid) );
 #endif /* MHD_USE_THREADS */
 
   num_events = MAX_EVENTS;
@@ -5611,7 +5611,7 @@ close_connection (struct MHD_Connection *pos)
 
 #ifdef MHD_USE_THREADS
   mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
-               MHD_thread_ID_is_current_thread_ (daemon->pid) );
+               MHD_thread_ID_is_current_thread_ (daemon->tid) );
   mhd_assert (NULL == daemon->worker_pool);
 #endif /* MHD_USE_THREADS */
 
@@ -5665,7 +5665,7 @@ MHD_polling_thread (void *cls)
   int err;
 #endif /* HAVE_PTHREAD_SIGMASK */
 
-  MHD_thread_init_ (&(daemon->pid));
+  MHD_thread_init_ (&(daemon->tid));
 #ifdef HAVE_PTHREAD_SIGMASK
   if ((0 == sigemptyset (&s_mask)) &&
       (0 == sigaddset (&s_mask, SIGPIPE)))
@@ -7863,7 +7863,7 @@ MHD_start_daemon_va (unsigned int flags,
           MHD_socket_close_chk_ (listen_fd);
         goto free_and_fail;
       }
-      if (! MHD_create_named_thread_ (&daemon->pid,
+      if (! MHD_create_named_thread_ (&daemon->tid,
                                       (*pflags
                                        & MHD_USE_THREAD_PER_CONNECTION) ?
                                       "MHD-listen" : "MHD-single",
@@ -8012,7 +8012,7 @@ MHD_start_daemon_va (unsigned int flags,
 #endif /* DAUTH_SUPPORT */
 
         /* Spawn the worker thread */
-        if (! MHD_create_named_thread_ (&d->pid,
+        if (! MHD_create_named_thread_ (&d->tid,
                                         "MHD-worker",
                                         daemon->thread_stack_size,
                                         &MHD_polling_thread,
@@ -8175,7 +8175,7 @@ close_all_connections (struct MHD_Daemon *daemon)
 #ifdef MHD_USE_THREADS
   mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
                (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) || \
-               MHD_thread_ID_is_current_thread_ (daemon->pid) );
+               MHD_thread_ID_is_current_thread_ (daemon->tid) );
   mhd_assert (NULL == daemon->worker_pool);
 #endif /* MHD_USE_THREADS */
   mhd_assert (daemon->shutdown);
@@ -8288,7 +8288,7 @@ close_all_connections (struct MHD_Daemon *daemon)
          * MHD_resume_connection() during finishing of "upgraded"
          * thread. */
         MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
-        if (! MHD_join_thread_ (pos->pid.handle))
+        if (! MHD_join_thread_ (pos->tid.handle))
           MHD_PANIC (_ ("Failed to join a thread.\n"));
         pos->thread_joined = true;
         MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
@@ -8320,7 +8320,7 @@ close_all_connections (struct MHD_Daemon *daemon)
       if (! pos->thread_joined)
       {
         MHD_mutex_unlock_chk_ (&daemon->cleanup_connection_mutex);
-        if (! MHD_join_thread_ (pos->pid.handle))
+        if (! MHD_join_thread_ (pos->tid.handle))
           MHD_PANIC (_ ("Failed to join a thread.\n"));
         MHD_mutex_lock_chk_ (&daemon->cleanup_connection_mutex);
         pos->thread_joined = true;
@@ -8458,7 +8458,7 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
         mhd_assert (false); /* Should never happen */
       }
 
-      if (! MHD_join_thread_ (daemon->pid.handle))
+      if (! MHD_join_thread_ (daemon->tid.handle))
       {
         MHD_PANIC (_ ("Failed to join a thread.\n"));
       }
diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h
index 56657e19..27e9a50f 100644
--- a/src/microhttpd/internal.h
+++ b/src/microhttpd/internal.h
@@ -1386,7 +1386,7 @@ struct MHD_Connection
    * Thread handle for this connection (if we are using
    * one thread per connection).
    */
-  MHD_thread_handle_ID_ pid;
+  MHD_thread_handle_ID_ tid;
 #endif
 
   /**
@@ -2121,7 +2121,7 @@ struct MHD_Daemon
   /**
    * The select thread handle (if we have internal select)
    */
-  MHD_thread_handle_ID_ pid;
+  MHD_thread_handle_ID_ tid;
 
   /**
    * Mutex for per-IP connection counts.
diff --git a/src/microhttpd/mhd_threads.h b/src/microhttpd/mhd_threads.h
index 4cd60974..925ac95d 100644
--- a/src/microhttpd/mhd_threads.h
+++ b/src/microhttpd/mhd_threads.h
@@ -161,16 +161,16 @@ typedef struct _MHD_thread_handle_ID_ 
MHD_thread_handle_ID_;
  * @param ID thread ID to match
  * @return nonzero on match, zero otherwise
  */
-#  define MHD_thread_ID_is_current_thread_(pid) \
-     (pthread_equal ((pid).ID, pthread_self ()))
+#  define MHD_thread_ID_is_current_thread_(tid) \
+     (pthread_equal ((tid).ID, pthread_self ()))
 #elif defined(MHD_USE_W32_THREADS)
 /**
  * Check whether provided thread ID matches current thread.
  * @param ID thread ID to match
  * @return nonzero on match, zero otherwise
  */
-#  define MHD_thread_ID_is_current_thread_(pid) \
-     (GetCurrentThreadId () == (pid).ID)
+#  define MHD_thread_ID_is_current_thread_(tid) \
+     (GetCurrentThreadId () == (tid).ID)
 #endif
 
 #if defined(MHD_USE_POSIX_THREADS)
diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c
index 12c034ca..3f278689 100644
--- a/src/microhttpd/response.c
+++ b/src/microhttpd/response.c
@@ -1939,7 +1939,7 @@ MHD_response_execute_upgrade_ (struct MHD_Response 
*response,
 
 #ifdef MHD_USE_THREADS
   mhd_assert ( (0 == (daemon->options & MHD_USE_INTERNAL_POLLING_THREAD)) || \
-               MHD_thread_ID_is_current_thread_ (connection->pid) );
+               MHD_thread_ID_is_current_thread_ (connection->tid) );
 #endif /* MHD_USE_THREADS */
 
   /* "Upgrade" responses accepted only if MHD_ALLOW_UPGRADE is enabled */
diff --git a/src/testcurl/perf_get_concurrent.c 
b/src/testcurl/perf_get_concurrent.c
index 3ba0b1b3..2cf273f4 100644
--- a/src/testcurl/perf_get_concurrent.c
+++ b/src/testcurl/perf_get_concurrent.c
@@ -404,7 +404,7 @@ static unsigned int
 testExternalGet (uint16_t port)
 {
   struct MHD_Daemon *d;
-  pthread_t pid;
+  pthread_t tid;
   fd_set rs;
   fd_set ws;
   fd_set es;
@@ -433,7 +433,7 @@ testExternalGet (uint16_t port)
     }
     port = dinfo->port;
   }
-  if (0 != pthread_create (&pid, NULL,
+  if (0 != pthread_create (&tid, NULL,
                            &do_gets, (void *) (intptr_t) port))
   {
     MHD_stop_daemon (d);
@@ -490,7 +490,7 @@ testExternalGet (uint16_t port)
 
   stop ("external select");
   MHD_stop_daemon (d);
-  if ((0 != pthread_join (pid, (void **) &ret_val)) ||
+  if ((0 != pthread_join (tid, (void **) &ret_val)) ||
       (NULL != ret_val) )
   {
     fprintf (stderr,
diff --git a/src/testcurl/test_digestauth_concurrent.c 
b/src/testcurl/test_digestauth_concurrent.c
index 664b5cb1..97ca8db7 100644
--- a/src/testcurl/test_digestauth_concurrent.c
+++ b/src/testcurl/test_digestauth_concurrent.c
@@ -450,7 +450,7 @@ struct curlWokerInfo
 {
   int workerNumber;
   struct CBC cbc;
-  pthread_t pid;
+  pthread_t tid;
   /**
    * The libcurl handle to run in thread
    */
@@ -628,7 +628,7 @@ testDigestAuth (void)
   for (i = 0; i < sizeof(workers) / sizeof(workers[0]); i++)
   {
     struct curlWokerInfo *const w = workers + i;
-    if (0 != pthread_create (&w->pid, NULL, &worker_func, w))
+    if (0 != pthread_create (&w->tid, NULL, &worker_func, w))
       externalErrorExitDesc ("pthread_create() failed");
   }
 
@@ -637,7 +637,7 @@ testDigestAuth (void)
   for (i = 0; i < sizeof(workers) / sizeof(workers[0]); i++)
   {
     struct curlWokerInfo *const w = workers + i;
-    if (0 != pthread_join (w->pid, NULL))
+    if (0 != pthread_join (w->tid, NULL))
       externalErrorExitDesc ("pthread_join() failed");
     curl_easy_cleanup (w->c);
     free (w->libcurl_errbuf);

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]