aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2018-11-12 17:00:09 +0100
committerAndreas Schneider <asn@samba.org>2018-11-13 11:59:36 +0100
commit87cc3f8e5433471e986c3b50e351ae49289b4cbe (patch)
tree8037985745776c2018165eedb5dcfde2d5ea7cdd /src
parentd788cef44dc998ce51aeb9637145bf1d1cd58a9b (diff)
downloadsocket_wrapper-87cc3f8e5433471e986c3b50e351ae49289b4cbe.tar.gz
socket_wrapper-87cc3f8e5433471e986c3b50e351ae49289b4cbe.tar.xz
socket_wrapper-87cc3f8e5433471e986c3b50e351ae49289b4cbe.zip
swrap: Rename global variable for max sockets
We also need a mutex to protect access to it. Pair-Programmed-With: Anoop C S <anoopcs@redhat.com> Signed-off-by: Andreas Schneider <asn@samba.org> Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-by: Ralph Boehme <slow@samba.org>
Diffstat (limited to 'src')
-rw-r--r--src/socket_wrapper.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index a107710..514179e 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -293,7 +293,7 @@ struct socket_info_container
static struct socket_info_container *sockets;
-static size_t max_sockets = 0;
+static size_t socket_info_max = 0;
/* Hash table to map fds to corresponding socket_info index */
static int *socket_fds_idx;
@@ -1324,11 +1324,11 @@ static size_t socket_wrapper_max_sockets(void)
unsigned long tmp;
char *endp;
- if (max_sockets != 0) {
- return max_sockets;
+ if (socket_info_max != 0) {
+ return socket_info_max;
}
- max_sockets = SOCKET_WRAPPER_MAX_SOCKETS_DEFAULT;
+ socket_info_max = SOCKET_WRAPPER_MAX_SOCKETS_DEFAULT;
s = getenv("SOCKET_WRAPPER_MAX_SOCKETS");
if (s == NULL || s[0] == '\0') {
@@ -1345,10 +1345,10 @@ static size_t socket_wrapper_max_sockets(void)
goto done;
}
- max_sockets = tmp;
+ socket_info_max = tmp;
done:
- return max_sockets;
+ return socket_info_max;
}
static void socket_wrapper_init_fds_idx(void)
@@ -1377,6 +1377,7 @@ static void socket_wrapper_init_fds_idx(void)
static void socket_wrapper_init_sockets(void)
{
+ size_t max_sockets;
size_t i;
int ret;
@@ -1389,6 +1390,7 @@ static void socket_wrapper_init_sockets(void)
socket_wrapper_init_fds_idx();
+ /* Needs to be called inside the sockets_mutex lock here. */
max_sockets = socket_wrapper_max_sockets();
sockets = (struct socket_info_container *)calloc(max_sockets,