gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] branch master updated (dfbc4da6 -> 97707d77)


From: gnunet
Subject: [libmicrohttpd] branch master updated (dfbc4da6 -> 97707d77)
Date: Mon, 11 Sep 2023 18:51:47 +0200

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

karlson2k pushed a change to branch master
in repository libmicrohttpd.

    from dfbc4da6 Simplified deinit on W32.
     new e71a6a5d mhd_threads: muted compiler warning on W32
     new 3b0a9d19 mhd_threads: fixed check for error when starting a new thread 
on W32
     new e55b0418 mhd_threads: renamed one macro for clarity
     new a9bc3198 Renamed 'pid' -> 'tid' when used for threads
     new 35cfb56e mhd_threads: added new macro MHD_join_thread_tid_()
     new 97707d77 mhd_str: fixed possible compiler and run-time sanitizers 
warnings

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/microhttpd/connection.c               | 10 ++---
 src/microhttpd/daemon.c                   | 44 +++++++++----------
 src/microhttpd/internal.h                 |  4 +-
 src/microhttpd/mhd_str.c                  | 70 ++++++++++++++++++-------------
 src/microhttpd/mhd_threads.c              | 20 ++++-----
 src/microhttpd/mhd_threads.h              | 14 ++++---
 src/microhttpd/response.c                 |  2 +-
 src/testcurl/perf_get_concurrent.c        |  6 +--
 src/testcurl/test_digestauth_concurrent.c |  6 +--
 9 files changed, 96 insertions(+), 80 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 9440d112..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_match_current_ (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_match_current_ (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_match_current_ (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_match_current_ (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_match_current_ (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 4694afeb..23f06baa 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_match_current_ (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_match_current_ (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_match_current_ (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_match_current_ (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_match_current_ (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_match_current_ (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_match_current_ (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_match_current_ (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_tid_ (&pos->tid)) )
       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_match_current_ (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_match_current_ (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_match_current_ (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_match_current_ (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_tid_ (&pos->tid))
           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_tid_ (&pos->tid))
           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_tid_ (&daemon->tid))
       {
         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_str.c b/src/microhttpd/mhd_str.c
index d32efc02..2504d366 100644
--- a/src/microhttpd/mhd_str.c
+++ b/src/microhttpd/mhd_str.c
@@ -1293,8 +1293,8 @@ MHD_strx_to_uint32_ (const char *str,
   while (digit >= 0)
   {
     if ( (res < (UINT32_MAX / 16)) ||
-         ((res == (UINT32_MAX / 16)) && ( (uint32_t) digit <= (UINT32_MAX
-                                                               % 16)) ) )
+         ((res == (UINT32_MAX / 16)) &&
+          ( (uint32_t) digit <= (UINT32_MAX % 16)) ) )
     {
       res *= 16;
       res += (unsigned int) digit;
@@ -1340,8 +1340,8 @@ MHD_strx_to_uint32_n_ (const char *str,
   while (i < maxlen && (digit = toxdigitvalue (str[i])) >= 0)
   {
     if ( (res > (UINT32_MAX / 16)) ||
-         ((res == (UINT32_MAX / 16)) && ( (uint32_t) digit > (UINT32_MAX
-                                                              % 16)) ) )
+         ((res == (UINT32_MAX / 16)) &&
+          ( (uint32_t) digit > (UINT32_MAX % 16)) ) )
       return 0;
 
     res *= 16;
@@ -1380,8 +1380,8 @@ MHD_strx_to_uint64_ (const char *str,
   while (digit >= 0)
   {
     if ( (res < (UINT64_MAX / 16)) ||
-         ((res == (UINT64_MAX / 16)) && ( (uint64_t) digit <= (UINT64_MAX
-                                                               % 16)) ) )
+         ((res == (UINT64_MAX / 16)) &&
+          ( (uint64_t) digit <= (UINT64_MAX % 16)) ) )
     {
       res *= 16;
       res += (unsigned int) digit;
@@ -1427,8 +1427,8 @@ MHD_strx_to_uint64_n_ (const char *str,
   while (i < maxlen && (digit = toxdigitvalue (str[i])) >= 0)
   {
     if ( (res > (UINT64_MAX / 16)) ||
-         ((res == (UINT64_MAX / 16)) && ( (uint64_t) digit > (UINT64_MAX
-                                                              % 16)) ) )
+         ((res == (UINT64_MAX / 16)) &&
+          ( (uint64_t) digit > (UINT64_MAX % 16)) ) )
       return 0;
 
     res *= 16;
@@ -1777,8 +1777,9 @@ MHD_str_pct_decode_strict_n_ (const char *pct_encoded,
           unsigned char out;
           if ((0 > h) || (0 > l))
             return 0;
-          out = (unsigned char) ( (((uint8_t) ((unsigned int) h)) << 4)
-                                  | ((uint8_t) ((unsigned int) l)) );
+          out =
+            (unsigned char) (((uint8_t) (((uint8_t) ((unsigned int) h)) << 4))
+                             | ((uint8_t) ((unsigned int) l)));
           decoded[w] = (char) out;
         }
       }
@@ -1806,8 +1807,9 @@ MHD_str_pct_decode_strict_n_ (const char *pct_encoded,
         unsigned char out;
         if ((0 > h) || (0 > l))
           return 0;
-        out = (unsigned char) ( (((uint8_t) ((unsigned int) h)) << 4)
-                                | ((uint8_t) ((unsigned int) l)) );
+        out =
+          (unsigned char) (((uint8_t) (((uint8_t) ((unsigned int) h)) << 4))
+                           | ((uint8_t) ((unsigned int) l)));
         decoded[w] = (char) out;
       }
     }
@@ -1862,8 +1864,9 @@ MHD_str_pct_decode_lenient_n_ (const char *pct_encoded,
           }
           else
           {
-            out = (unsigned char) ( (((uint8_t) ((unsigned int) h)) << 4)
-                                    | ((uint8_t) ((unsigned int) l)) );
+            out =
+              (unsigned char) (((uint8_t) (((uint8_t) ((unsigned int) h)) << 
4))
+                               | ((uint8_t) ((unsigned int) l)));
             decoded[w] = (char) out;
           }
         }
@@ -1903,8 +1906,9 @@ MHD_str_pct_decode_lenient_n_ (const char *pct_encoded,
         else
         {
           unsigned char out;
-          out = (unsigned char) ( (((uint8_t) ((unsigned int) h)) << 4)
-                                  | ((uint8_t) ((unsigned int) l)) );
+          out =
+            (unsigned char) (((uint8_t) (((uint8_t) ((unsigned int) h)) << 4))
+                             | ((uint8_t) ((unsigned int) l)));
           decoded[w] = (char) out;
         }
       }
@@ -1958,8 +1962,9 @@ MHD_str_pct_decode_in_place_strict_ (char *str)
           unsigned char out;
           if ((0 > h) || (0 > l))
             return 0;
-          out = (unsigned char) ( (((uint8_t) ((unsigned int) h)) << 4)
-                                  | ((uint8_t) ((unsigned int) l)) );
+          out =
+            (unsigned char) (((uint8_t) (((uint8_t) ((unsigned int) h)) << 4))
+                             | ((uint8_t) ((unsigned int) l)));
           str[w++] = (char) out;
         }
       }
@@ -2033,8 +2038,9 @@ MHD_str_pct_decode_in_place_lenient_ (char *str,
             str[w++] = d2;
             continue;
           }
-          out = (unsigned char) ( (((uint8_t) ((unsigned int) h)) << 4)
-                                  | ((uint8_t) ((unsigned int) l)) );
+          out =
+            (unsigned char) (((uint8_t) (((uint8_t) ((unsigned int) h)) << 4))
+                             | ((uint8_t) ((unsigned int) l)));
           str[w++] = (char) out;
           continue;
         }
@@ -2230,11 +2236,11 @@ base64_char_to_value_ (uint8_t c)
   if ('Z' >= c)
   {
     if ('A' <= c)
-      return (MHD_base64_map_type_) (c - 'A') + 0;
+      return (MHD_base64_map_type_) ((c - 'A') + 0);
     if ('0' <= c)
     {
       if ('9' >= c)
-        return (MHD_base64_map_type_) (c - '0') + 52;
+        return (MHD_base64_map_type_) ((c - '0') + 52);
       if ('=' == c)
         return -2;
       return -1;
@@ -2246,7 +2252,7 @@ base64_char_to_value_ (uint8_t c)
     return -1;
   }
   if (('z' >= c) && ('a' <= c))
-    return (MHD_base64_map_type_) (c - 'a') + 26;
+    return (MHD_base64_map_type_) ((c - 'a') + 26);
   return -1;
 }
 
@@ -2366,9 +2372,12 @@ MHD_base64_to_bin_n (const char *base64,
       const MHD_base64_map_type_ v4 = base64_char_to_value_ (in[i + 3]);
       if ((0 > v1) || (0 > v2) || (0 > v3) || (0 > v4))
         return 0;
-      out[j + 0] = (uint8_t) ((((uint8_t) v1) << 2) | (((uint8_t) v2) >> 4));
-      out[j + 1] = (uint8_t) ((((uint8_t) v2) << 4) | (((uint8_t) v3) >> 2));
-      out[j + 2] = (uint8_t) ((((uint8_t) v3) << 6) | (((uint8_t) v4)));
+      out[j + 0] = (uint8_t) (((uint8_t) (((uint8_t) v1) << 2))
+                              | ((uint8_t) (((uint8_t) v2) >> 4)));
+      out[j + 1] = (uint8_t) (((uint8_t) (((uint8_t) v2) << 4))
+                              | ((uint8_t) (((uint8_t) v3) >> 2)));
+      out[j + 2] = (uint8_t) (((uint8_t) (((uint8_t) v3) << 6))
+                              | ((uint8_t) (((uint8_t) v4))));
     }
     j += 3;
   }
@@ -2385,7 +2394,8 @@ MHD_base64_to_bin_n (const char *base64,
     if ((0 > v1) || (0 > v2))
       return 0; /* Invalid char or padding at first two positions */
     mhd_assert (j < bin_size);
-    out[j++] = (uint8_t) ((((uint8_t) v1) << 2) | (((uint8_t) v2) >> 4));
+    out[j++] = (uint8_t) (((uint8_t) (((uint8_t) v1) << 2))
+                          | ((uint8_t) (((uint8_t) v2) >> 4)));
     if (0 > v3)
     { /* Third char is either padding or invalid */
       if ((-2 != v3) || (-2 != v4))
@@ -2396,7 +2406,8 @@ MHD_base64_to_bin_n (const char *base64,
     }
     if (j >= bin_size)
       return 0; /* Not enough space */
-    out[j++] = (uint8_t) ((((uint8_t) v2) << 4) | (((uint8_t) v3) >> 2));
+    out[j++] = (uint8_t) (((uint8_t) (((uint8_t) v2) << 4))
+                          | ((uint8_t) (((uint8_t) v3) >> 2)));
     if (0 > v4)
     { /* Fourth char is either padding or invalid */
       if (-2 != v4)
@@ -2407,7 +2418,8 @@ MHD_base64_to_bin_n (const char *base64,
     }
     if (j >= bin_size)
       return 0; /* Not enough space */
-    out[j++] = (uint8_t) ((((uint8_t) v3) << 6) | (((uint8_t) v4)));
+    out[j++] = (uint8_t) (((uint8_t) (((uint8_t) v3) << 6))
+                          | ((uint8_t) (((uint8_t) v4))));
   }
   return j;
 #if MHD_BASE64_FUNC_VERSION >= 2
diff --git a/src/microhttpd/mhd_threads.c b/src/microhttpd/mhd_threads.c
index 95fc70a6..13cccf4c 100644
--- a/src/microhttpd/mhd_threads.c
+++ b/src/microhttpd/mhd_threads.c
@@ -218,6 +218,7 @@ MHD_create_thread_ (MHD_thread_handle_ID_ *thread,
 
   return ! res;
 #elif defined(MHD_USE_W32_THREADS)
+  uintptr_t thr_handle;
 #if SIZEOF_SIZE_T != SIZEOF_UNSIGNED_INT
   if (stack_size > UINT_MAX)
   {
@@ -225,16 +226,15 @@ MHD_create_thread_ (MHD_thread_handle_ID_ *thread,
     return 0;
   }
 #endif /* SIZEOF_SIZE_T != SIZEOF_UNSIGNED_INT */
-
-  thread->handle = (MHD_thread_handle_) (uintptr_t)
-                   _beginthreadex (NULL,
-                                   (unsigned int) stack_size,
-                                   start_routine,
-                                   arg,
-                                   0,
-                                   NULL);
-
-  if ((MHD_thread_handle_) - 1 == thread->handle)
+  thr_handle = (uintptr_t) _beginthreadex (NULL,
+                                           (unsigned int) stack_size,
+                                           start_routine,
+                                           arg,
+                                           0,
+                                           NULL);
+  thread->handle = (MHD_thread_handle_) thr_handle;
+
+  if ((MHD_thread_handle_) 0 == thread->handle)
     return 0;
 
   return ! 0;
diff --git a/src/microhttpd/mhd_threads.h b/src/microhttpd/mhd_threads.h
index 0a504635..6e1dce32 100644
--- a/src/microhttpd/mhd_threads.h
+++ b/src/microhttpd/mhd_threads.h
@@ -155,21 +155,25 @@ typedef struct _MHD_thread_handle_ID_ 
MHD_thread_handle_ID_;
     (CloseHandle ( (thread)), ! 0) : 0 )
 #endif
 
+#define MHD_join_thread_tid_(thread_handle_ID_ptr) \
+  (MHD_join_thread_((thread_handle_ID_ptr)->handle))
+
 #if defined(MHD_USE_POSIX_THREADS)
 /**
- * Check whether provided thread ID match current thread.
+ * Check whether provided thread ID matches current thread.
  * @param ID thread ID to match
  * @return nonzero on match, zero otherwise
  */
-#define MHD_thread_ID_match_current_(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 match current thread.
+ * Check whether provided thread ID matches current thread.
  * @param ID thread ID to match
  * @return nonzero on match, zero otherwise
  */
-#define MHD_thread_ID_match_current_(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 277247cc..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_match_current_ (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]