summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--action.c19
-rw-r--r--queue.c9
2 files changed, 25 insertions, 3 deletions
diff --git a/action.c b/action.c
index 872c2085..a3684796 100644
--- a/action.c
+++ b/action.c
@@ -67,6 +67,16 @@ static int iActionQtoWrkShutdown = 60000; /* timeout for worker thread shutdow
static int iActionQWrkMinMsgs = 100; /* minimum messages per worker needed to start a new one */
static int bActionQSaveOnShutdown = 1; /* save queue on shutdown (when DA enabled)? */
+/* the counter below counts actions created. It is used to obtain unique IDs for the action. They
+ * should not be relied on for any long-term activity (e.g. disk queue names!), but they are nice
+ * to have during one instance of an rsyslogd run. For example, I use them to name actions when there
+ * is no better name available. Note that I do NOT recover previous numbers on HUP - we simply keep
+ * counting. -- rgerhards, 2008-01-29
+ */
+static int iActionNbr = 0;
+
+/* ------------------------------ methods ------------------------------ */
+
/* destructs an action descriptor object
* rgerhards, 2007-08-01
*/
@@ -109,6 +119,9 @@ rsRetVal actionConstruct(action_t **ppThis)
pThis->iResumeRetryCount = glbliActionResumeRetryCount;
SYNC_OBJ_TOOL_INIT(pThis);
+ /* indicate we have a new action */
+ ++iActionNbr;
+
finalize_it:
*ppThis = pThis;
RETiRet;
@@ -121,13 +134,17 @@ rsRetVal
actionConstructFinalize(action_t *pThis)
{
DEFiRet;
+ uchar pszQName[64]; /* friendly name of our queue */
ASSERT(pThis != NULL);
+ /* find a name for our queue */
+ snprintf((char*) pszQName, sizeof(pszQName)/sizeof(uchar), "action %d queue", iActionNbr);
+
/* create queue */
RUNLOG_VAR("%d", ActionQueType);
CHKiRet(queueConstruct(&pThis->pQueue, ActionQueType, 1, 10, (rsRetVal (*)(void*,void*))actionCallDoAction));
-
+ objSetName((obj_t*) pThis->pQueue, pszQName);
/* ... set some properties ... */
# define setQPROP(func, directive, data) \
diff --git a/queue.c b/queue.c
index d3698d38..d9f5155f 100644
--- a/queue.c
+++ b/queue.c
@@ -198,6 +198,7 @@ static rsRetVal
queueStartDA(queue_t *pThis)
{
DEFiRet;
+ uchar pszDAQName[128];
ISOBJ_TYPE_assert(pThis, queue);
@@ -207,6 +208,10 @@ queueStartDA(queue_t *pThis)
/* create message queue */
CHKiRet(queueConstruct(&pThis->pqDA, QUEUETYPE_DISK , 1, 0, pThis->pConsumer));
+ /* give it a name */
+ snprintf((char*) pszDAQName, sizeof(pszDAQName)/sizeof(uchar), "%s[DA]", objGetName((obj_t*) pThis));
+ objSetName((obj_t*) pThis->pqDA, pszDAQName);
+
/* as the created queue is the same object class, we take the
* liberty to access its properties directly.
*/
@@ -286,7 +291,7 @@ queueInitDA(queue_t *pThis, int bEnqOnly, int bLockMutex)
* rgerhards, 2008-01-24
*/
if(pThis->pWtpDA == NULL) {
- lenBuf = snprintf((char*)pszBuf, sizeof(pszBuf), "Queue 0x%lx:DA", (unsigned long) pThis);
+ lenBuf = snprintf((char*)pszBuf, sizeof(pszBuf), "%s:DA", objGetName((obj_t*) pThis));
CHKiRet(wtpConstruct (&pThis->pWtpDA));
CHKiRet(wtpSetDbgHdr (pThis->pWtpDA, pszBuf, lenBuf));
CHKiRet(wtpSetpfChkStopWrkr (pThis->pWtpDA, (rsRetVal (*)(void *pUsr, int)) queueChkStopWrkrDA));
@@ -1413,7 +1418,7 @@ rsRetVal queueStart(queue_t *pThis) /* this is the ConstructionFinalizer */
/* create worker thread pools for regular operation. The DA pool is created on an as-needed
* basis, which potentially means never under most circumstances.
*/
- lenBuf = snprintf((char*)pszBuf, sizeof(pszBuf), "Queue 0x%lx:Reg", (unsigned long) pThis);
+ lenBuf = snprintf((char*)pszBuf, sizeof(pszBuf), "%s:Reg", objGetName((obj_t*) pThis));
CHKiRet(wtpConstruct (&pThis->pWtpReg));
CHKiRet(wtpSetDbgHdr (pThis->pWtpReg, pszBuf, lenBuf));
CHKiRet(wtpSetpfChkStopWrkr (pThis->pWtpReg, (rsRetVal (*)(void *pUsr, int)) queueChkStopWrkrReg));