in src/main/cpp/multiprocessrollingfileappender.cpp [177:211]
bool MultiprocessRollingFileAppender::isAlreadyRolled(const LogString& fileName, size_t* pSize)
{
if( !_priv->log_file )
return false;
apr_int32_t wantedInfo = APR_FINFO_IDENT;
if (pSize)
wantedInfo |= APR_FINFO_SIZE;
apr_finfo_t finfo1;
apr_status_t st1 = apr_file_info_get(&finfo1, wantedInfo, _priv->log_file);
if (st1 != APR_SUCCESS)
LogLog::warn(LOG4CXX_STR("apr_file_info_get failed"));
else if (pSize)
*pSize = finfo1.size;
LOG4CXX_ENCODE_CHAR(fname, fileName);
apr_status_t st2;
apr_finfo_t finfo2;
int retryCount = 0;
while (APR_SUCCESS != (st2 = apr_stat(&finfo2, fname.c_str(), wantedInfo, _priv->pool.getAPRPool())))
{
if (5 == ++retryCount)
break;
using namespace std::chrono_literals;
std::this_thread::sleep_for(30ms);
}
if (st2 != APR_SUCCESS)
LogLog::warn(fileName + LOG4CXX_STR(": apr_stat failed."));
else if (pSize)
*pSize = finfo2.size;
return st2 != APR_SUCCESS ||
((st1 == APR_SUCCESS) && (st2 == APR_SUCCESS) &&
((finfo1.device != finfo2.device) || (finfo1.inode != finfo2.inode)));
}