summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-01-11 14:48:15 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2008-01-11 14:48:15 +0000
commitf38f69b82c82ef61ff6d1da748a655e08b43cf53 (patch)
tree7bde3d6287600f4d920240428751a2eb43a694ec
parentdd575394dba4f1943a5185a5f40750a4293b7203 (diff)
downloadrsyslog-f38f69b82c82ef61ff6d1da748a655e08b43cf53.tar.gz
rsyslog-f38f69b82c82ef61ff6d1da748a655e08b43cf53.tar.xz
rsyslog-f38f69b82c82ef61ff6d1da748a655e08b43cf53.zip
queue can now persist disk queue information on immediate shutdown
-rw-r--r--obj.c2
-rw-r--r--queue.c16
-rw-r--r--stream.c5
3 files changed, 17 insertions, 6 deletions
diff --git a/obj.c b/obj.c
index c51dfbe9..5f5adc8c 100644
--- a/obj.c
+++ b/obj.c
@@ -211,7 +211,7 @@ rsRetVal objSerializeProp(strm_t *pStrm, uchar *pszPropName, propertyType_t prop
assert(pStrm != NULL);
assert(pszPropName != NULL);
- dbgprintf("objSerializeProp: strm %p, propName '%s', type %d, pUsr %p\n", pStrm, pszPropName, propType, pUsr);
+ /*dbgprintf("objSerializeProp: strm %p, propName '%s', type %d, pUsr %p\n", pStrm, pszPropName, propType, pUsr);*/
/* if we have no user pointer, there is no need to write this property.
* TODO: think if that's the righ point of view
* rgerhards, 2008-01-06
diff --git a/queue.c b/queue.c
index 91d89b06..91ffe18d 100644
--- a/queue.c
+++ b/queue.c
@@ -619,11 +619,15 @@ static rsRetVal queuePersist(queue_t *pThis)
strm_t *psQIF; /* Queue Info File */
uchar pszQIFNam[MAXFNAME];
size_t lenQIFNam;
+ int i;
assert(pThis != NULL);
if(pThis->iQueueSize == 0)
FINALIZE; /* nothing left to do, so be happy */
+ if(pThis->qType != QUEUETYPE_DISK)
+ ABORT_FINALIZE(RS_RET_NOT_IMPLEMENTED); /* TODO: later... */
+
dbgprintf("Queue 0x%lx: persisting queue to disk, %d entries...\n", queueGetID(pThis), pThis->iQueueSize);
/* Construct file name */
lenQIFNam = snprintf((char*)pszQIFNam, sizeof(pszQIFNam) / sizeof(uchar), "%s/%s.qi",
@@ -635,8 +639,18 @@ static rsRetVal queuePersist(queue_t *pThis)
CHKiRet(strmSetFName(psQIF, pszQIFNam, lenQIFNam));
CHKiRet(strmConstructFinalize(psQIF));
- /* first, write the property bag for ourselfs */
+ /* first, write the property bag for ourselfs
+ * And, surprisingly enough, we currently need to persist only the size of the
+ * queue. All the rest is re-created with then-current config parameters when the
+ * queue is re-created. Well, we'll also save the current queue type, just so that
+ * we know when somebody has changed the queue type... -- rgerhards, 2008-01-11
+ */
CHKiRet(objBeginSerializePropBag(psQIF, (obj_t*) pThis));
+ i = 2; /* we serialize the number of properties, so that we know when we read the propbag */
+ objSerializeSCALAR_VAR(psQIF, NumberPropertyBagRecrods, INT, i);
+ i = pThis->qType;
+ objSerializeSCALAR_VAR(psQIF, qType, INT, i);
+ objSerializeSCALAR(psQIF, iQueueSize, INT);
CHKiRet(objEndSerialize(psQIF));
/* this is disk specific and must be moved to a function */
diff --git a/stream.c b/stream.c
index 7fb6aa74..344c2c66 100644
--- a/stream.c
+++ b/stream.c
@@ -311,7 +311,7 @@ rsRetVal strmDestruct(strm_t *pThis)
ISOBJ_TYPE_assert(pThis, strm);
- if(pThis->tOperationsMode == STREAMMODE_WRITE && pThis->iBufPtr > 0)
+ if(pThis->tOperationsMode == STREAMMODE_WRITE)
strmFlush(pThis);
/* ... then free resources */
@@ -626,7 +626,6 @@ rsRetVal strmSerialize(strm_t *pThis, strm_t *pStrm)
CHKiRet(objBeginSerialize(pStrm, (obj_t*) pThis));
-dbgprintf("strmSerialize in %p\n", pThis);
i = pThis->sType;
objSerializeSCALAR_VAR(pStrm, sType, INT, i);
objSerializeSCALAR(pStrm, iCurrFNum, INT);
@@ -636,7 +635,6 @@ dbgprintf("strmSerialize in %p\n", pThis);
i = pThis->tOpenMode;
objSerializeSCALAR_VAR(pStrm, tOpenMode, INT, i);
l = (long) pThis->iMaxFileSize;
-dbgprintf("max file size %ld, l: %ld\n", pThis->iMaxFileSize, l);
objSerializeSCALAR_VAR(pStrm, iMaxFileSize, LONG, l);
objSerializeSCALAR(pStrm, iMaxFiles, INT);
objSerializeSCALAR(pStrm, iFileNumDigits, INT);
@@ -644,7 +642,6 @@ dbgprintf("max file size %ld, l: %ld\n", pThis->iMaxFileSize, l);
CHKiRet(objEndSerialize(pStrm));
finalize_it:
-dbgprintf("strmSerialize out, iret %d\n", iRet);
return iRet;
}