summaryrefslogtreecommitdiffstats
path: root/stream.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-02-27 17:27:26 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2008-02-27 17:27:26 +0000
commitb87d6629d0eeb6b48ed2e1be25d15fb06b78fc22 (patch)
tree0f037c71615479997492e2e5fd6c1d311b9e813e /stream.c
parent5dd9a6792b4266006cb8b283e6e5996bbd5026a7 (diff)
downloadrsyslog-b87d6629d0eeb6b48ed2e1be25d15fb06b78fc22.tar.gz
rsyslog-b87d6629d0eeb6b48ed2e1be25d15fb06b78fc22.tar.xz
rsyslog-b87d6629d0eeb6b48ed2e1be25d15fb06b78fc22.zip
- bugfix: queue aborted when it was shut down, DA-enabled, DA mode was just
initiated but not fully initialized (a race condition) - bugfix: queue properties sizeOnDisk, bytesRead were persisted to disk with wrong data type (long instead of int64) - could cause problems on 32 bit machines - fixed a problem introduced today, on-disk queue size was now wrongly calculated (but not in any released version)
Diffstat (limited to 'stream.c')
-rw-r--r--stream.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/stream.c b/stream.c
index 0f05c97c..9f2f06c6 100644
--- a/stream.c
+++ b/stream.c
@@ -464,7 +464,7 @@ static rsRetVal strmWriteInternal(strm_t *pThis, uchar *pBuf, size_t lenBuf)
CHKiRet(strmOpenFile(pThis));
iWritten = write(pThis->fd, pBuf, lenBuf);
- dbgoprint((obj_t*) pThis, "file %d write wrote %d bytes, errno: %d\n", pThis->fd, iWritten, errno);
+ dbgoprint((obj_t*) pThis, "file %d write wrote %d bytes\n", pThis->fd, iWritten);
/* TODO: handle error case -- rgerhards, 2008-01-07 */
/* Now indicate buffer empty again. We do this in any case, because there
@@ -477,6 +477,9 @@ static rsRetVal strmWriteInternal(strm_t *pThis, uchar *pBuf, size_t lenBuf)
*/
pThis->iBufPtr = 0;
pThis->iCurrOffs += iWritten;
+ /* update user counter, if provided */
+ if(pThis->pUsrWCntr != NULL)
+ *pThis->pUsrWCntr += iWritten;
if(pThis->sType == STREAMTYPE_FILE_CIRCULAR)
CHKiRet(strmCheckNextOutputFile(pThis));
@@ -797,6 +800,31 @@ finalize_it:
}
+
+/* set a user write-counter. This counter is initialized to zero and
+ * receives the number of bytes written. It is accurate only after a
+ * flush(). This hook is provided as a means to control disk size usage.
+ * The pointer must be valid at all times (so if it is on the stack, be sure
+ * to remove it when you exit the function). Pointers are removed by
+ * calling strmSetWCntr() with a NULL param. Only one pointer is settable,
+ * any new set overwrites the previous one.
+ * rgerhards, 2008-02-27
+ */
+rsRetVal
+strmSetWCntr(strm_t *pThis, number_t *pWCnt)
+{
+ DEFiRet;
+
+ ISOBJ_TYPE_assert(pThis, strm);
+
+ if(pWCnt != NULL)
+ *pWCnt = 0;
+ pThis->pUsrWCntr = pWCnt;
+
+ RETiRet;
+}
+
+
#include "stringbuf.h"
/* This function can be used as a generic way to set properties.