summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2010-03-10 08:21:41 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2010-03-10 08:21:41 +0100
commit8833612e7516694e89148eb3dc1c88f5ea954d16 (patch)
treebdfa6e143a1e3c0dccdfd7088070e269610b9191
parent5996414f04118dec4f1dcc12c88ee8c68f6e89ad (diff)
downloadrsyslog-8833612e7516694e89148eb3dc1c88f5ea954d16.tar.gz
rsyslog-8833612e7516694e89148eb3dc1c88f5ea954d16.tar.xz
rsyslog-8833612e7516694e89148eb3dc1c88f5ea954d16.zip
some cosmetic changes
note that a buffer size calculation was done wrong, but this was cosmetic because our buffers currently all use byte size, so even though the formula was wrong, the result was correct.
-rw-r--r--runtime/stream.c18
-rwxr-xr-xtests/asynwr_simple.sh1
-rwxr-xr-xtests/asynwr_small.sh1
-rwxr-xr-xtests/asynwr_timeout.sh1
-rwxr-xr-xtests/asynwr_tinybuf.sh1
5 files changed, 13 insertions, 9 deletions
diff --git a/runtime/stream.c b/runtime/stream.c
index 5396bae0..bb92eeb5 100644
--- a/runtime/stream.c
+++ b/runtime/stream.c
@@ -619,11 +619,11 @@ static rsRetVal strmConstructFinalize(strm_t *pThis)
* to make sure we can write out everything with a SINGLE api call!
* We add another 128 bytes to take care of the gzip header and "all eventualities".
*/
- CHKmalloc(pThis->pZipBuf = (Bytef*) malloc(sizeof(uchar) * pThis->sIOBufSize + 128));
+ CHKmalloc(pThis->pZipBuf = (Bytef*) malloc(sizeof(uchar) * (pThis->sIOBufSize + 128)));
}
}
- /* if we are aset to sync, we must obtain a file handle to the directory for fsync() purposes */
+ /* if we are set to sync, we must obtain a file handle to the directory for fsync() purposes */
if(pThis->bSync && !pThis->bIsTTY) {
pThis->fdDir = open((char*)pThis->pszDir, O_RDONLY | O_CLOEXEC | O_NOCTTY);
if(pThis->fdDir == -1) {
@@ -913,7 +913,7 @@ asyncWriterThread(void *pPtr)
if(prctl(PR_SET_NAME, "rs:asyn strmwr", 0, 0, 0) != 0) {
DBGPRINTF("prctl failed, not setting thread name for '%s'\n", "stream writer");
}
-#endif
+# endif
while(1) { /* loop broken inside */
d_pthread_mutex_lock(&pThis->mut);
@@ -1060,10 +1060,6 @@ finalize_it:
* add a config switch so that the user can decide the risk he is ready
* to take, but so far this is not yet implemented (not even requested ;)).
* rgerhards, 2009-06-04
- * For the time being, we take a very conservative approach and do not run this
- * method multithreaded. This is done in an effort to solve a segfault condition
- * that seems to be related to the zip code. -- rgerhards, 2009-09-22
- * TODO: make multithreaded again!
*/
static rsRetVal
doZipWrite(strm_t *pThis, uchar *pBuf, size_t lenBuf)
@@ -1235,6 +1231,11 @@ finalize_it:
* caller-provided buffer is larger than our one. So instead of optimizing a case
* which normally does not exist, we expect some degradation in its case but make us
* perform better in the regular cases. -- rgerhards, 2009-07-07
+ * Note: the pThis->iBufPtr == pThis->sIOBufSize logic below looks a bit like an
+ * on-off error. In fact, it is not, because iBufPtr always points to the next
+ * *free* byte in the buffer. So if it is sIOBufSize - 1, there actually is one
+ * free byte left. This came up during a code walkthrough and was considered
+ * worth nothing. -- rgerhards, 2010-03-10
*/
static rsRetVal
strmWrite(strm_t *pThis, uchar *pBuf, size_t lenBuf)
@@ -1359,8 +1360,7 @@ strmSetDir(strm_t *pThis, uchar *pszDir, size_t iLenDir)
if(iLenDir < 1)
ABORT_FINALIZE(RS_RET_FILE_PREFIX_MISSING);
- if((pThis->pszDir = malloc(sizeof(uchar) * iLenDir + 1)) == NULL)
- ABORT_FINALIZE(RS_RET_OUT_OF_MEMORY);
+ CHKmalloc(pThis->pszDir = malloc(sizeof(uchar) * iLenDir + 1));
memcpy(pThis->pszDir, pszDir, iLenDir + 1); /* always think about the \0! */
pThis->lenDir = iLenDir;
diff --git a/tests/asynwr_simple.sh b/tests/asynwr_simple.sh
index 693eca50..2e476b8f 100755
--- a/tests/asynwr_simple.sh
+++ b/tests/asynwr_simple.sh
@@ -2,6 +2,7 @@
#
# added 2010-03-09 by Rgerhards
# This file is part of the rsyslog project, released under GPLv3
+echo ===============================================================================
echo TEST: \[asynwr_simple.sh\]: simple test for async file writing
source $srcdir/diag.sh init
# uncomment for debugging support:
diff --git a/tests/asynwr_small.sh b/tests/asynwr_small.sh
index 692d27fa..39dcd762 100755
--- a/tests/asynwr_small.sh
+++ b/tests/asynwr_small.sh
@@ -11,6 +11,7 @@
# added 2010-03-09 by Rgerhards
#
# This file is part of the rsyslog project, released under GPLv3
+echo ===============================================================================
echo TEST: \[asynwr_small.sh\]: test for async file writing for few messages
source $srcdir/diag.sh init
# uncomment for debugging support:
diff --git a/tests/asynwr_timeout.sh b/tests/asynwr_timeout.sh
index 84fbd481..746ee3f1 100755
--- a/tests/asynwr_timeout.sh
+++ b/tests/asynwr_timeout.sh
@@ -4,6 +4,7 @@
#
# added 2010-03-09 by Rgerhards
# This file is part of the rsyslog project, released under GPLv3
+echo ===============================================================================
echo TEST: \[asynwr_timeout.sh\]: test async file writing timeout writes
source $srcdir/diag.sh init
# uncomment for debugging support:
diff --git a/tests/asynwr_tinybuf.sh b/tests/asynwr_tinybuf.sh
index a7cc19ef..a0915394 100755
--- a/tests/asynwr_tinybuf.sh
+++ b/tests/asynwr_tinybuf.sh
@@ -5,6 +5,7 @@
# added 2010-03-09 by Rgerhards
#
# This file is part of the rsyslog project, released under GPLv3
+echo ===============================================================================
echo TEST: \[asynwr_tinybuf.sh\]: test async file writing with 1-byte buffer
source $srcdir/diag.sh init
# uncomment for debugging support: