bb9452
From 1feb389f80f7595d2f873c3ff8678b52cd2db828 Mon Sep 17 00:00:00 2001
bb9452
From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= <pemensik@redhat.com>
bb9452
Date: Tue, 24 May 2022 19:42:41 +0200
bb9452
Subject: [PATCH] Fix failures in isc netmgr_test on big endian machines
bb9452
bb9452
Typing from libuv structure to isc_region_t is not possible, because
bb9452
their sizes differ on 64 bit architectures. Little endian machines seems
bb9452
to be lucky and still result in test passed. But big endian machine such
bb9452
as s390x fails the test reliably.
bb9452
bb9452
Fix by directly creating the buffer as isc_region_t and skipping the
bb9452
type conversion. More readable and still more correct.
bb9452
bb9452
(cherry picked from commit 057438cb45f2f02615dc309e3822f23c0ca70a0a)
bb9452
---
bb9452
 lib/isc/tests/netmgr_test.c | 18 ++++++++----------
bb9452
 1 file changed, 8 insertions(+), 10 deletions(-)
bb9452
bb9452
diff --git a/lib/isc/tests/netmgr_test.c b/lib/isc/tests/netmgr_test.c
bb9452
index c2d7fffb32..9fa0d47e5b 100644
bb9452
--- a/lib/isc/tests/netmgr_test.c
bb9452
+++ b/lib/isc/tests/netmgr_test.c
bb9452
@@ -62,11 +62,11 @@ static isc_sockaddr_t tcp_connect_addr;
bb9452
 static uint64_t send_magic = 0;
bb9452
 static uint64_t stop_magic = 0;
bb9452
 
bb9452
-static uv_buf_t send_msg = { .base = (char *)&send_magic,
bb9452
-			     .len = sizeof(send_magic) };
bb9452
+static isc_region_t send_msg = { .base = (unsigned char *)&send_magic,
bb9452
+				 .length = sizeof(send_magic) };
bb9452
 
bb9452
-static uv_buf_t stop_msg = { .base = (char *)&stop_magic,
bb9452
-			     .len = sizeof(stop_magic) };
bb9452
+static isc_region_t stop_msg = { .base = (unsigned char *)&stop_magic,
bb9452
+				 .length = sizeof(stop_magic) };
bb9452
 
bb9452
 static atomic_bool do_send = false;
bb9452
 static unsigned int workers = 0;
bb9452
@@ -420,11 +420,9 @@ connect_send(isc_nmhandle_t *handle) {
bb9452
 	isc_nmhandle_attach(handle, &sendhandle);
bb9452
 	isc_nmhandle_setwritetimeout(handle, T_IDLE);
bb9452
 	if (atomic_fetch_sub(&nsends, 1) > 1) {
bb9452
-		isc_nm_send(sendhandle, (isc_region_t *)&send_msg,
bb9452
-			    connect_send_cb, NULL);
bb9452
+		isc_nm_send(sendhandle, &send_msg, connect_send_cb, NULL);
bb9452
 	} else {
bb9452
-		isc_nm_send(sendhandle, (isc_region_t *)&stop_msg,
bb9452
-			    connect_send_cb, NULL);
bb9452
+		isc_nm_send(sendhandle, &stop_msg, connect_send_cb, NULL);
bb9452
 	}
bb9452
 }
bb9452
 
bb9452
@@ -531,8 +529,8 @@ listen_read_cb(isc_nmhandle_t *handle, isc_result_t eresult,
bb9452
 			isc_nmhandle_attach(handle, &sendhandle);
bb9452
 			isc_refcount_increment0(&active_ssends);
bb9452
 			isc_nmhandle_setwritetimeout(sendhandle, T_IDLE);
bb9452
-			isc_nm_send(sendhandle, (isc_region_t *)&send_msg,
bb9452
-				    listen_send_cb, cbarg);
bb9452
+			isc_nm_send(sendhandle, &send_msg, listen_send_cb,
bb9452
+				    cbarg);
bb9452
 		}
bb9452
 		return;
bb9452
 	}
bb9452
-- 
bb9452
2.34.3
bb9452