From 366194cde40d0cdea31248c8dbd2fe6dd4f81e20 Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Sun, 16 Jul 2017 17:11:04 +0200 Subject: [PATCH] Replace getdtablesize() with sysconf(_SC_OPEN_MAX) From http://man7.org/linux/man-pages/man3/getdtablesize.3.html: "It is not specified in POSIX.1; portable applications should employ sysconf(_SC_OPEN_MAX) instead of this call." Specifically this fixes a build failure on Android which does not have getdtablesize(). Signed-off-by: Fredrik Fornwall --- src/loop.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/loop.c b/src/loop.c index 3d068181..bf4876bc 100644 --- a/src/loop.c +++ b/src/loop.c @@ -21,6 +21,7 @@ Contributors: #include #ifndef WIN32 #include +#include #else #include #include @@ -126,7 +127,7 @@ int mosquitto_main_loop(struct mosquitto_db *db, mosq_sock_t *listensock, int li #ifdef WIN32 pollfd_max = _getmaxstdio(); #else - pollfd_max = getdtablesize(); + pollfd_max = sysconf(_SC_OPEN_MAX); #endif pollfds = _mosquitto_malloc(sizeof(struct pollfd)*pollfd_max);