summaryrefslogtreecommitdiffstats
path: root/queue.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-01-04 17:17:12 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2008-01-04 17:17:12 +0000
commit800ac1889b99057f1e6670d4ce5941bda33b6773 (patch)
tree0f4eb44b3ca1375790d006648422c9f535f4e00f /queue.c
parente41c0854dac685047dba1107b097bf674e740131 (diff)
downloadrsyslog-800ac1889b99057f1e6670d4ce5941bda33b6773.tar.gz
rsyslog-800ac1889b99057f1e6670d4ce5941bda33b6773.tar.xz
rsyslog-800ac1889b99057f1e6670d4ce5941bda33b6773.zip
changed queue object Construction/Startup interface
Diffstat (limited to 'queue.c')
-rw-r--r--queue.c31
1 files changed, 22 insertions, 9 deletions
diff --git a/queue.c b/queue.c
index 8ef20371..d324172e 100644
--- a/queue.c
+++ b/queue.c
@@ -235,7 +235,7 @@ rsRetVal qAddDisk(queue_t *pThis, void* pUsr)
assert(pThis != NULL);
dbgprintf("writing to file %d\n", pThis->tVars.disk.fd);
- CHKiRet((objSerialize(pUsr))(pBuf, &lenBuf, pUsr)); // TODO: hier weiter machen!
+ CHKiRet((objSerialize(pUsr))(pUsr, pBuf, &lenBuf)); // TODO: hier weiter machen!
i = write(pThis->tVars.disk.fd, "entry\n", 6);
dbgprintf("write wrote %d bytes, errno: %d, err %s\n", i, errno, strerror(errno));
@@ -360,12 +360,15 @@ queueWorker(void *arg)
pthread_exit(0);
}
-/* Constructor for the queue object */
+/* Constructor for the queue object
+ * This constructs the data structure, but does not yet start the queue. That
+ * is done by queueStart(). The reason is that we want to give the caller a chance
+ * to modify some parameters before the queue is actually started.
+ */
rsRetVal queueConstruct(queue_t **ppThis, queueType_t qType, int iMaxQueueSize, rsRetVal (*pConsumer)(void*))
{
DEFiRet;
queue_t *pThis;
- int i;
assert(ppThis != NULL);
assert(pConsumer != NULL);
@@ -411,12 +414,6 @@ rsRetVal queueConstruct(queue_t **ppThis, queueType_t qType, int iMaxQueueSize,
/* call type-specific constructor */
CHKiRet(pThis->qConstruct(pThis));
- /* now fire up the worker thread */
- pThis->bDoRun = 1; /* we are NOT done (else worker would immediately terminate) */
- i = pthread_create(&pThis->thrdWorker, NULL, queueWorker, (void*) pThis);
- dbgprintf("Worker thread for queue 0x%lx, type %d started with state %d.\n",
- (unsigned long) pThis, (int) qType, i);
-
finalize_it:
if(iRet == RS_RET_OK) {
*ppThis = pThis;
@@ -429,6 +426,22 @@ finalize_it:
}
+/* start up the queue - it must have been constructed and parameters defined
+ * before.
+ */
+rsRetVal queueStart(queue_t *pThis)
+{
+ int i;
+
+ /* fire up the worker thread */
+ pThis->bDoRun = 1; /* we are NOT done (else worker would immediately terminate) */
+ i = pthread_create(&pThis->thrdWorker, NULL, queueWorker, (void*) pThis);
+ dbgprintf("Worker thread for queue 0x%lx, type %d started with state %d.\n",
+ (unsigned long) pThis, (int) pThis->qType, i);
+
+ return RS_RET_OK;
+}
+
/* destructor for the queue object */
rsRetVal queueDestruct(queue_t *pThis)
{