diff -rupN wrapper_3.5.25_src/src/c/logger.c wrapper_3.5.25_src_patched/src/c/logger.c --- wrapper_3.5.25_src/src/c/logger.c 2014-09-11 15:30:01.816798726 +0200 +++ wrapper_3.5.25_src_patched/src/c/logger.c 2014-09-11 15:41:12.684771272 +0200 @@ -3099,30 +3099,23 @@ void checkAndRollLogs(const TCHAR *nowDa return; } - /* Find out the current size of the file. If the file is currently open then we need to - * use ftell to make sure that the buffered data is also included. */ - if (logfileFP != NULL) { - /* File is open */ - if ((position = ftell(logfileFP)) < 0) { - _tprintf(TEXT("Unable to get the current logfile size with ftell: %s\n"), getLastErrorText()); + /* Due to a memory leak when using ftell the following code is used when the file is both opened or closed + See https://sourceware.org/git/?p=glibc.git;a=commit;h=984c0ea97f649c869130a1ff099098e2b6f70aad + As soon as this fix is in mainstream linux (Amazon linux images), this patch can be removed. + */ + if (_tstat(logFilePath, &fileStat) != 0) { + if (getLastError() == 2) { + /* File does not yet exist. */ + position = 0; + } else if (getLastError() == 3) { + /* Path does not exist. */ + position = 0; + } else { + _tprintf(TEXT("Unable to get the current logfile size with stat: %s\n"), getLastErrorText()); return; } } else { - /* File is not open */ - if (_tstat(logFilePath, &fileStat) != 0) { - if (getLastError() == 2) { - /* File does not yet exist. */ - position = 0; - } else if (getLastError() == 3) { - /* Path does not exist. */ - position = 0; - } else { - _tprintf(TEXT("Unable to get the current logfile size with stat: %s\n"), getLastErrorText()); - return; - } - } else { - position = fileStat.st_size; - } + position = fileStat.st_size; } /* Does the log file need to rotated? */