File 1465-Initialize-workers-area.patch of Package erlang
From 4c3bc8daed472b1008f7de82ded6296820826a58 Mon Sep 17 00:00:00 2001
From: Raimo Niskanen <raimo@erlang.org>
Date: Fri, 2 Feb 2024 17:58:51 +0100
Subject: [PATCH] Initialize workers' area
---
erts/etc/common/inet_gethost.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/erts/etc/common/inet_gethost.c b/erts/etc/common/inet_gethost.c
index 05ed4188b0..96a66f62fd 100644
--- a/erts/etc/common/inet_gethost.c
+++ b/erts/etc/common/inet_gethost.c
@@ -1,7 +1,7 @@
/*
* %CopyrightBegin%
*
- * Copyright Ericsson AB 1998-2023. All Rights Reserved.
+ * Copyright Ericsson AB 1998-2024. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1046,14 +1046,23 @@ static void main_loop(void)
static void init_workers(int max)
{
+ size_t alloc_size = sizeof(Worker) * max;
+
max_workers = max;
num_busy_workers = 0;
num_free_workers = 0;
num_stalled_workers = 0;
- busy_workers = ALLOC(sizeof(Worker) * max_workers);
- free_workers = ALLOC(sizeof(Worker) * max_workers);
- stalled_workers = ALLOC(sizeof(Worker) * max_workers);
+ busy_workers = ALLOC(alloc_size);
+ free_workers = ALLOC(alloc_size);
+ stalled_workers = ALLOC(alloc_size);
+
+#ifdef DEBUG
+ memset(busy_workers, 0, alloc_size);
+ memset(free_workers, 0, alloc_size);
+ memset(stalled_workers, 0, alloc_size);;
+#endif
+
#ifndef WIN32
init_signals();
#endif
--
2.35.3