summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/rsyslog.h1
-rw-r--r--runtime/wti.h25
2 files changed, 16 insertions, 10 deletions
diff --git a/runtime/rsyslog.h b/runtime/rsyslog.h
index edf0c593..ae56f08f 100644
--- a/runtime/rsyslog.h
+++ b/runtime/rsyslog.h
@@ -49,6 +49,7 @@
#define CONF_PROGNAME_BUFSIZE 16
#define CONF_HOSTNAME_BUFSIZE 32
#define CONF_PROP_BUFSIZE 16 /* should be close to sizeof(ptr) or lighly above it */
+#define CONF_IPARAMS_BUFSIZE 16 /* initial size of iparams array in wti (is automatically extended) */
#define CONF_MIN_SIZE_FOR_COMPRESS 60 /* config param: minimum message size to try compression. The smaller
* the message, the less likely is any compression gain. We check for
* gain before we submit the message. But to do so we still need to
diff --git a/runtime/wti.h b/runtime/wti.h
index 57c2bfea..9ac61c2d 100644
--- a/runtime/wti.h
+++ b/runtime/wti.h
@@ -44,7 +44,6 @@
* as well. -- gerhards, 2013-11-04
*/
typedef struct actWrkrIParams {
- struct actWrkrIParams *next;
int msgFlags;
/* following are caches to save allocs if not absolutely necessary */
uchar *staticActStrings[CONF_OMOD_NUMSTRINGS_MAXSIZE]; /**< for strings */
@@ -62,8 +61,9 @@ typedef struct actWrkrInfo {
struct {
unsigned actState : 3;
} flags;
- actWrkrIParams_t *iparamRoot;
- actWrkrIParams_t *iparamLast;
+ actWrkrIParams_t *iparams;
+ int currIParam;
+ int maxIParams; /* current max */
void *staticActParams[CONF_OMOD_NUMSTRINGS_MAXSIZE]; /* for non-strings */
} actWrkrInfo_t;
@@ -164,18 +164,23 @@ wtiNewIParam(wti_t *pWti, action_t *pAction, actWrkrIParams_t **piparams)
{
actWrkrInfo_t *wrkrInfo;
actWrkrIParams_t *iparams;
+ int newMax;
DEFiRet;
wrkrInfo = &(pWti->actWrkrInfo[pAction->iActionNbr]);
-dbgprintf("DDDD: adding param for action %d\n", pAction->iActionNbr);
- CHKmalloc(iparams = calloc(1, sizeof(actWrkrIParams_t)));
- if(wrkrInfo->iparamLast == NULL) {
- wrkrInfo->iparamLast = wrkrInfo->iparamRoot = iparams;
- } else {
- wrkrInfo->iparamLast->next = iparams;
- wrkrInfo->iparamLast = iparams;
+ if(wrkrInfo->currIParam == wrkrInfo->maxIParams) {
+ /* we need to extend */
+ dbgprintf("DDDD: extending iparams, max %d\n", wrkrInfo->maxIParams);
+ newMax = (wrkrInfo->maxIParams == 0) ? CONF_IPARAMS_BUFSIZE : 2 * wrkrInfo->maxIParams;
+ CHKmalloc(iparams = realloc(wrkrInfo->iparams, sizeof(actWrkrIParams_t) * newMax));
+ wrkrInfo->iparams = iparams;
+ wrkrInfo->maxIParams = newMax;
}
+dbgprintf("DDDD: adding param %d for action %d\n", wrkrInfo->currIParam, pAction->iActionNbr);
+ iparams = wrkrInfo->iparams + wrkrInfo->currIParam;
+ memset(iparams, 0, sizeof(actWrkrIParams_t));
*piparams = iparams;
+ ++wrkrInfo->currIParam;
finalize_it:
RETiRet;