diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2013-11-13 13:15:15 +0100 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2013-11-13 13:15:15 +0100 |
commit | dc760e8c672c2c896bc0d001fa1f7d9e02fe111c (patch) | |
tree | 89609f09d667ab7db2f60139eb59524458a57f60 /plugins/mmsequence/mmsequence.c | |
parent | 23278699e35173f46effda964fd80b8f868e8b3e (diff) | |
parent | 45a4134a8b5c9111398be3458bd27b4aa2f0e5c2 (diff) | |
download | rsyslog-dc760e8c672c2c896bc0d001fa1f7d9e02fe111c.tar.gz rsyslog-dc760e8c672c2c896bc0d001fa1f7d9e02fe111c.tar.bz2 rsyslog-dc760e8c672c2c896bc0d001fa1f7d9e02fe111c.zip |
Merge branch 'master-ruleeng' into master-ruleeng-simd
Diffstat (limited to 'plugins/mmsequence/mmsequence.c')
-rw-r--r-- | plugins/mmsequence/mmsequence.c | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/plugins/mmsequence/mmsequence.c b/plugins/mmsequence/mmsequence.c index 20a85370..609338c2 100644 --- a/plugins/mmsequence/mmsequence.c +++ b/plugins/mmsequence/mmsequence.c @@ -74,6 +74,10 @@ typedef struct _instanceData { char *pszVar; } instanceData; +typedef struct wrkrInstanceData { + instanceData *pData; +} wrkrInstanceData_t; + struct modConfData_s { rsconf_t *pConf; /* our overall config object */ }; @@ -100,6 +104,8 @@ static struct cnfparamblk actpblk = /* table for key-counter pairs */ static struct hashtable *ght; static pthread_mutex_t ght_mutex = PTHREAD_MUTEX_INITIALIZER; + +static pthread_mutex_t inst_mutex = PTHREAD_MUTEX_INITIALIZER; BEGINbeginCnfLoad CODESTARTbeginCnfLoad @@ -129,6 +135,10 @@ BEGINcreateInstance CODESTARTcreateInstance ENDcreateInstance +BEGINcreateWrkrInstance +CODESTARTcreateWrkrInstance +ENDcreateWrkrInstance + BEGINisCompatibleWithFeature CODESTARTisCompatibleWithFeature @@ -139,6 +149,10 @@ BEGINfreeInstance CODESTARTfreeInstance ENDfreeInstance +BEGINfreeWrkrInstance +CODESTARTfreeWrkrInstance +ENDfreeWrkrInstance + static inline void setInstParamDefaults(instanceData *pData) @@ -243,7 +257,7 @@ CODESTARTnewActInst ABORT_FINALIZE(RS_RET_ERR); } } - pthread_mutex_unlock(&ght_mutex); + pthread_mutex_unlock(&ght_mutex); break; default: errmsg.LogError(0, RS_RET_INVLD_MODE, @@ -303,7 +317,9 @@ BEGINdoAction struct json_object *json; int val = 0; int *pCounter; + instanceData *pData; CODESTARTdoAction + pData = pWrkrData->pData; pMsg = (msg_t*) ppString[0]; switch(pData->mode) { @@ -312,12 +328,19 @@ CODESTARTdoAction (pData->valueTo - pData->valueFrom)); break; case mmSequencePerInstance: - if (pData->value >= pData->valueTo - pData->step) { - pData->value = pData->valueFrom; + if (!pthread_mutex_lock(&inst_mutex)) { + pCounter = getCounter(ght, pData->pszKey, pData->valueTo); + if (pData->value >= pData->valueTo - pData->step) { + pData->value = pData->valueFrom; + } else { + pData->value += pData->step; + } + val = pData->value; + pthread_mutex_unlock(&inst_mutex); } else { - pData->value += pData->step; + errmsg.LogError(0, RS_RET_ERR, + "mmsequence: mutex lock has failed!"); } - val = pData->value; break; case mmSequencePerKey: if (!pthread_mutex_lock(&ght_mutex)) { @@ -381,6 +404,7 @@ ENDmodExit BEGINqueryEtryPt CODESTARTqueryEtryPt CODEqueryEtryPt_STD_OMOD_QUERIES +CODEqueryEtryPt_STD_OMOD8_QUERIES CODEqueryEtryPt_STD_CONF2_OMOD_QUERIES CODEqueryEtryPt_STD_CONF2_QUERIES ENDqueryEtryPt |