]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix failures in isc netmgr_test on big endian machines
authorPetr Menšík <pemensik@redhat.com>
Tue, 24 May 2022 17:42:41 +0000 (19:42 +0200)
committerPetr Menšík <pemensik@redhat.com>
Tue, 24 May 2022 17:51:30 +0000 (19:51 +0200)
Typing from libuv structure to isc_region_t is not possible, because
their sizes differ on 64 bit architectures. Little endian machines seems
to be lucky and still result in test passed. But big endian machine such
as s390x fails the test reliably.

Fix by directly creating the buffer as isc_region_t and skipping the
type conversion. More readable and still more correct.

lib/isc/tests/netmgr_test.c

index 6388aa4270fb8da3a79cf7985f746dc53394edbb..b0b8db649bcd92a408a2b91856b9a80089ff996e 100644 (file)
@@ -63,11 +63,11 @@ static isc_tlsctx_client_session_cache_t *tcp_tlsctx_client_sess_cache = NULL;
 static uint64_t send_magic = 0;
 static uint64_t stop_magic = 0;
 
-static uv_buf_t send_msg = { .base = (char *)&send_magic,
-                            .len = sizeof(send_magic) };
+static isc_region_t send_msg = { .base = (unsigned char *)&send_magic,
+                                .length = sizeof(send_magic) };
 
-static uv_buf_t stop_msg = { .base = (char *)&stop_magic,
-                            .len = sizeof(stop_magic) };
+static isc_region_t stop_msg = { .base = (unsigned char *)&stop_magic,
+                                .length = sizeof(stop_magic) };
 
 static atomic_bool do_send = false;
 static unsigned int workers = 0;
@@ -442,11 +442,9 @@ connect_send(isc_nmhandle_t *handle) {
        isc_nmhandle_attach(handle, &sendhandle);
        isc_nmhandle_setwritetimeout(handle, T_IDLE);
        if (atomic_fetch_sub(&nsends, 1) > 1) {
-               isc_nm_send(sendhandle, (isc_region_t *)&send_msg,
-                           connect_send_cb, NULL);
+               isc_nm_send(sendhandle, &send_msg, connect_send_cb, NULL);
        } else {
-               isc_nm_send(sendhandle, (isc_region_t *)&stop_msg,
-                           connect_send_cb, NULL);
+               isc_nm_send(sendhandle, &stop_msg, connect_send_cb, NULL);
        }
 }
 
@@ -553,8 +551,8 @@ listen_read_cb(isc_nmhandle_t *handle, isc_result_t eresult,
                        isc_nmhandle_attach(handle, &sendhandle);
                        isc_refcount_increment0(&active_ssends);
                        isc_nmhandle_setwritetimeout(sendhandle, T_IDLE);
-                       isc_nm_send(sendhandle, (isc_region_t *)&send_msg,
-                                   listen_send_cb, cbarg);
+                       isc_nm_send(sendhandle, &send_msg, listen_send_cb,
+                                   cbarg);
                }
                return;
        }