omfile: add module-global option "dynafile.donotsuspend"

this permits to enable SUSPENDing dynafile actions. Traditionally,
SUSPEND mode was never entered for dynafiles as it would have blocked
overall processing flow. Default is not to suspend (and thus block).

closes https://github.com/rsyslog/rsyslog/issues/2236
This commit is contained in:
Rainer Gerhards 2017-12-16 18:32:58 +01:00
parent 42228252a2
commit e1758bf32c

View File

@ -224,6 +224,7 @@ struct modConfData_s {
uid_t dirUID;
gid_t fileGID;
gid_t dirGID;
int bDynafileDoNotSuspend;
};
static modConfData_t *loadModConf = NULL;/* modConf ptr to use for the current load process */
@ -242,6 +243,7 @@ static struct cnfparamdescr modpdescr[] = {
{ "fileowner", eCmdHdlrUID, 0 },
{ "fileownernum", eCmdHdlrInt, 0 },
{ "filegroup", eCmdHdlrGID, 0 },
{ "dynafile.donotsuspend", eCmdHdlrBinary, 0 },
{ "filegroupnum", eCmdHdlrInt, 0 },
};
static struct cnfparamblk modpblk =
@ -854,6 +856,7 @@ CODESTARTbeginCnfLoad
pModConf->dirUID = -1;
pModConf->fileGID = -1;
pModConf->dirGID = -1;
pModConf->bDynafileDoNotSuspend = 1;
ENDbeginCnfLoad
BEGINsetModCnf
@ -880,9 +883,9 @@ CODESTARTsetModCnf
if(!strcmp(modpblk.descr[i].name, "template")) {
loadModConf->tplName = (uchar*)es_str2cstr(pvals[i].val.d.estr, NULL);
if(pszFileDfltTplName != NULL) {
parser_errmsg("omfile: warning: default template "
"was already set via legacy directive - may lead to inconsistent "
"results.");
parser_errmsg("omfile: warning: default template was already "
"set via legacy directive - may lead to inconsistent "
"results.");
}
} else if(!strcmp(modpblk.descr[i].name, "dircreatemode")) {
loadModConf->fDirCreateMode = (int) pvals[i].val.d.n;
@ -904,6 +907,8 @@ CODESTARTsetModCnf
loadModConf->fileGID = (int) pvals[i].val.d.n;
} else if(!strcmp(modpblk.descr[i].name, "filegroupnum")) {
loadModConf->fileGID = (int) pvals[i].val.d.n;
} else if(!strcmp(modpblk.descr[i].name, "dynafile.donotsuspend")) {
loadModConf->bDynafileDoNotSuspend = (int) pvals[i].val.d.n;
} else {
dbgprintf("omfile: program error, non-handled "
"param '%s' in beginCnfLoad\n", modpblk.descr[i].name);
@ -1065,9 +1070,11 @@ CODESTARTcommitTransaction
}
finalize_it:
if(iRet == RS_RET_FILE_OPEN_ERROR || iRet == RS_RET_FILE_NOT_FOUND)
iRet = pData->bDynamicName ? RS_RET_OK : RS_RET_SUSPENDED;
pthread_mutex_unlock(&pData->mutWrite);
if(iRet == RS_RET_FILE_OPEN_ERROR || iRet == RS_RET_FILE_NOT_FOUND) {
iRet = (pData->bDynamicName && runModConf->bDynafileDoNotSuspend) ?
RS_RET_OK : RS_RET_SUSPENDED;
}
ENDcommitTransaction
@ -1575,5 +1582,3 @@ INITLegCnfVars
CHKiRet(omsdRegCFSLineHdlr((uchar *)"resetconfigvariables", 1, eCmdHdlrCustomHandler, resetConfigVariables,
NULL, STD_LOADABLE_MODULE_ID));
ENDmodInit
/* vi:set ai:
*/