Commit c830c658 authored by Christian Mohrbacher's avatar Christian Mohrbacher

client: don't try to log to external helperd if network objects are not fully initialized

Fall back to syslog logging.

(cherry picked from commit 895764adfee71ee9650c5ad5adcdd2c2bc0f907f)
parent 821b4e64
......@@ -324,6 +324,13 @@ bool __App_initDataObjects(App* this, MountConfig* mountConfig)
if(strlen(interfacesFilename) &&
!Config_loadStringListFile(interfacesFilename, &this->allowedInterfaces) )
{
// if loading of file failed, we need to set LogType Syslog as fallback here, because
// helperd can't be used for error logging. helperd would need a valid NicList to connect,
// but that's initialized later.
// Of course, using printk could be another option here, but the code calling this function
// proceeds with some more log messages, that should be logged to log file if possible, but
// need to be redirected to syslog in this case here as well
Config_setLogTypeNum(this->cfg, LOGTYPE_Syslog);
Logger_logErrFormatted(this->logger, logContext,
"Unable to load configured interfaces file: %s", interfacesFilename);
return false;
......@@ -334,6 +341,13 @@ bool __App_initDataObjects(App* this, MountConfig* mountConfig)
if(strlen(preferredMetaFile) &&
!Config_loadUInt16ListFile(this->cfg, preferredMetaFile, &this->preferredMetaNodes) )
{
// if loading of file failed, we need to set LogType Syslog as fallback here, because
// helperd can't be used for error logging. helperd would need a valid NicList to connect,
// but that's initialized later.
// Of course, using printk could be another option here, but the code calling this function
// proceeds with some more log messages, that should be logged to log file if possible, but
// need to be redirected to syslog in this case here as well
Config_setLogTypeNum(this->cfg, LOGTYPE_Syslog);
Logger_logErrFormatted(this->logger, logContext,
"Unable to load configured preferred meta nodes file: %s", preferredMetaFile);
return false;
......@@ -343,6 +357,13 @@ bool __App_initDataObjects(App* this, MountConfig* mountConfig)
if(strlen(preferredStorageFile) &&
!Config_loadUInt16ListFile(this->cfg, preferredStorageFile, &this->preferredStorageTargets) )
{
// if loading of file failed, we need to set LogType Syslog as fallback here, because
// helperd can't be used for error logging. helperd would need a valid NicList to connect,
// but that's initialized later.
// Of course, using printk could be another option here, but the code calling this function
// proceeds with some more log messages, that should be logged to log file if possible, but
// need to be redirected to syslog in this case here as well
Config_setLogTypeNum(this->cfg, LOGTYPE_Syslog);
Logger_logErrFormatted(this->logger, logContext,
"Unable to load configured preferred storage nodes file: %s", preferredStorageFile);
return false;
......
......@@ -60,6 +60,7 @@ const char* Config_logTypeNumToStr(LogType logType);
static inline char* Config_getCfgFile(Config* this);
static inline int Config_getLogLevel(Config* this);
static inline LogType Config_getLogTypeNum(Config* this);
static inline void Config_setLogTypeNum(Config* this, LogType logType);
static inline bool Config_getLogClientID(Config* this);
static inline char* Config_getLogHelperdIP(Config* this);
static inline bool Config_getConnUseSDP(Config* this);
......@@ -256,6 +257,11 @@ LogType Config_getLogTypeNum(Config* this)
return this->logTypeNum;
}
void Config_setLogTypeNum(Config* this, LogType logType)
{
this->logTypeNum = logType;
}
bool Config_getLogClientID(Config* this)
{
return this->logClientID;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment