aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2018-11-13 08:31:43 +0100
committerAndreas Schneider <asn@samba.org>2018-11-13 11:59:45 +0100
commitd26ceb542342d6eef4a8df14f79ca2f81d1e550e (patch)
treec7169e5d89c5da343e6606011d6ff8e2dcc44b4d
parent74c3a9a60e5cfb8d191876c24e88e5d3aa38ca58 (diff)
downloadsocket_wrapper-d26ceb542342d6eef4a8df14f79ca2f81d1e550e.tar.gz
socket_wrapper-d26ceb542342d6eef4a8df14f79ca2f81d1e550e.tar.xz
socket_wrapper-d26ceb542342d6eef4a8df14f79ca2f81d1e550e.zip
swrap: Better handling for default values in socket_wrapper_max_sockets()
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>
-rw-r--r--src/socket_wrapper.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c
index 94a2193..165922b 100644
--- a/src/socket_wrapper.c
+++ b/src/socket_wrapper.c
@@ -230,7 +230,7 @@ enum swrap_dbglvl_e {
*/
#define SOCKET_WRAPPER_MAX_SOCKETS_DEFAULT 65535
-#define SOCKET_WRAPPER_MAX_SOCKETS_LIMIT 256000
+#define SOCKET_WRAPPER_MAX_SOCKETS_LIMIT 262140
/* This limit is to avoid broadcast sendto() needing to stat too many
* files. It may be raised (with a performance cost) to up to 254
@@ -1328,7 +1328,7 @@ done:
static size_t socket_wrapper_max_sockets(void)
{
const char *s;
- unsigned long tmp;
+ size_t tmp;
char *endp;
if (socket_info_max != 0) {
@@ -1346,10 +1346,20 @@ static size_t socket_wrapper_max_sockets(void)
if (s == endp) {
goto done;
}
- if (tmp == 0 || tmp > SOCKET_WRAPPER_MAX_SOCKETS_LIMIT) {
+ if (tmp == 0) {
+ tmp = SOCKET_WRAPPER_MAX_SOCKETS_DEFAULT;
SWRAP_LOG(SWRAP_LOG_ERROR,
- "Invalid number of sockets specified, using default.");
- goto done;
+ "Invalid number of sockets specified, "
+ "using default (%zu)",
+ tmp);
+ }
+
+ if (tmp > SOCKET_WRAPPER_MAX_SOCKETS_LIMIT) {
+ tmp = SOCKET_WRAPPER_MAX_SOCKETS_LIMIT;
+ SWRAP_LOG(SWRAP_LOG_ERROR,
+ "Invalid number of sockets specified, "
+ "using maximum (%zu).",
+ tmp);
}
socket_info_max = tmp;