omkafka/imkafka: Fixed a problem when invalid kafka configuration values are used

omkafka ended up in an endless loop and high cpu.
imkafka tried to subscribe to a not connected kafka server.

This closes https://github.com/rsyslog/rsyslog/issues/1806
This commit is contained in:
Andre Lorbach 2017-10-05 16:14:31 +02:00
parent f4c9ee9e50
commit 37500c665b
2 changed files with 13 additions and 1 deletions

View File

@ -421,6 +421,9 @@ checkInstance(instanceConf_t *inst)
inst->bIsConnected = 1;
finalize_it:
errmsg.LogError(0, RS_RET_KAFKA_NO_VALID_BROKERS,
"imkafka: no valid brokers specified: %s\n", inst->brokers);
RETiRet;
}
@ -671,7 +674,8 @@ CODESTARTrunInput
if(glbl.GetGlobalInputTermState() == 1)
break; /* terminate input! */
if(inst->bIsSubscribed == 0 ) {
// Try to add consumer only if connected! */
if(inst->bIsConnected == 1 && inst->bIsSubscribed == 0 ) {
addConsumer(runModConf, inst);
}
if(inst->bIsSubscribed == 1 ) {

View File

@ -941,6 +941,14 @@ finalize_it:
if (pData->rk != NULL) {
closeKafka(pData);
}
/* Parameter Error's cannot be resumed, so we need to disable the action */
if (iRet == RS_RET_PARAM_ERROR) {
iRet = RS_RET_DISABLE_ACTION;
errmsg.LogError(0, iRet,
"omkafka: action will be disabled due invalid kafka configuration parameters\n");
}
}
pthread_rwlock_unlock(&pData->rkLock);
RETiRet;