diff options
Diffstat (limited to 'daemons/maap/linux/src/maap_log_linux.c')
-rw-r--r-- | daemons/maap/linux/src/maap_log_linux.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/daemons/maap/linux/src/maap_log_linux.c b/daemons/maap/linux/src/maap_log_linux.c index 2d6f02b3..35dcfcbc 100644 --- a/daemons/maap/linux/src/maap_log_linux.c +++ b/daemons/maap/linux/src/maap_log_linux.c @@ -27,6 +27,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <stdarg.h> #include <string.h> #include <inttypes.h> +#include <limits.h> #include "platform.h" #include "maap_log_queue.h" @@ -74,7 +75,14 @@ extern void *loggingThreadFn(void *pv); THREAD_TYPE(loggingThread); THREAD_DEFINITON(loggingThread); -#define THREAD_STACK_SIZE 65536 +#if !defined(PTHREAD_STACK_MIN) +#error "PTHREAD_STACK_MIN variable not defined" +#elif (PTHREAD_STACK_MIN > 65536) +#define THREAD_STACK_SIZE PTHREAD_STACK_MIN +#else +#define THREAD_STACK_SIZE 65536 +#endif + #define loggingThread_THREAD_STK_SIZE THREAD_STACK_SIZE static MUTEX_HANDLE_ALT(gLogMutex); @@ -211,13 +219,16 @@ void maapLogInit(void) loggingThreadRunning = TRUE; THREAD_CREATE(loggingThread, loggingThread, NULL, loggingThreadFn, NULL); THREAD_CHECK_ERROR(loggingThread, "Thread / task creation failed", errResult); - if (errResult); // Already reported + if (errResult) { + loggingThreadRunning = FALSE; + MAAP_LOG_ERROR("Could not log data: loggingThread create failure"); + } } } void maapLogExit() { - if (MAAP_LOG_FROM_THREAD) { + if (MAAP_LOG_FROM_THREAD && loggingThreadRunning ) { loggingThreadRunning = FALSE; THREAD_JOIN(loggingThread, NULL); } |