]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
ISC_QUEUE_POP is not tsan safe. Suppress warnings
authorMark Andrews <marka@isc.org>
Fri, 28 Aug 2020 02:08:03 +0000 (12:08 +1000)
committerMark Andrews <marka@isc.org>
Tue, 8 Sep 2020 07:41:33 +0000 (17:41 +1000)
ret->link.next is tested to see if it is NULL unlocked
to avoid obtaining taillock when it is not nexessary then
retested once the taillock is obtained.

bin/named/client.c
lib/isc/include/isc/util.h

index 978e4d91b8dc713808e4abc3585c0276c444fbe3..1ea33816dad01d61ad0cd019c5a443925d66a7f4 100644 (file)
@@ -3856,6 +3856,22 @@ ns_clientmgr_destroy(ns_clientmgr_t **managerp) {
        *managerp = NULL;
 }
 
+/*
+ * ISC_QUEUE_POP is deliberately not tsan safe to avoid aquiring
+ * the taillock every time ISC_QUEUE_POP is called.
+ * Isolate ISC_QUEUE_POP from tsan analysis.
+ */
+ISC_NO_SANITIZE_THREAD static ns_client_t *
+queue_pop(ns_clientmgr_t *manager)
+{
+       ns_client_t *client = NULL;
+
+       if (!ns_g_clienttest) {
+               ISC_QUEUE_POP(manager->inactive, ilink, client);
+       }
+       return (client);
+}
+
 static isc_result_t
 get_client(ns_clientmgr_t *manager, ns_interface_t *ifp,
           dns_dispatch_t *disp, bool tcp)
@@ -3875,8 +3891,9 @@ get_client(ns_clientmgr_t *manager, ns_interface_t *ifp,
         * if that fails, make a new one.
         */
        client = NULL;
-       if (!ns_g_clienttest)
-               ISC_QUEUE_POP(manager->inactive, ilink, client);
+       if (!ns_g_clienttest) {
+               client = queue_pop(manager);
+       }
 
        if (client != NULL)
                MTRACE("recycle");
@@ -3944,8 +3961,9 @@ get_worker(ns_clientmgr_t *manager, ns_interface_t *ifp, isc_socket_t *sock,
         * if that fails, make a new one.
         */
        client = NULL;
-       if (!ns_g_clienttest)
-               ISC_QUEUE_POP(manager->inactive, ilink, client);
+       if (!ns_g_clienttest) {
+               client = queue_pop(manager);
+       }
 
        if (client != NULL)
                MTRACE("recycle");
index 98101c981e0f6900df8e8e53fcea98c9155c3061..8e70bd3ec615155da0c78b14057960dca667636c 100644 (file)
 #define __SANITIZE_ADDRESS__ 1
 #endif
 
+/* GCC defines __SANITIZE_THREAD__, so reuse the macro for clang */
+#if __has_feature(thread_sanitizer)
+#define __SANITIZE_THREAD__ 1
+#endif
+
+#if __SANITIZE_THREAD__
+#define ISC_NO_SANITIZE_THREAD __attribute__((no_sanitize("thread")))
+#else /* if __SANITIZE_THREAD__ */
+#define ISC_NO_SANITIZE_THREAD
+#endif /* if __SANITIZE_THREAD__ */
+
 #ifdef UNIT_TESTING
 extern void mock_assert(const int result, const char* const expression,
                        const char * const file, const int line);