summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2009-08-19 13:04:35 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2009-08-19 13:04:35 +0200
commit7d9ad618842dc16177844746dfe83126722f0c37 (patch)
tree0639aa1d81150c17f3b20530ad2538f8d325ddae /runtime
parentdfc2b538ecdcd70a2ae091ad529a4972a91e3aa1 (diff)
parent16fb5cd701d4c12f8ad573dde8ff52c9eaecb79f (diff)
downloadrsyslog-7d9ad618842dc16177844746dfe83126722f0c37.tar.gz
rsyslog-7d9ad618842dc16177844746dfe83126722f0c37.tar.xz
rsyslog-7d9ad618842dc16177844746dfe83126722f0c37.zip
Merge branch 'beta'
Diffstat (limited to 'runtime')
-rw-r--r--runtime/stream.c10
-rw-r--r--runtime/stream.h4
2 files changed, 4 insertions, 10 deletions
diff --git a/runtime/stream.c b/runtime/stream.c
index 2abfb7fe..b1abb27e 100644
--- a/runtime/stream.c
+++ b/runtime/stream.c
@@ -628,8 +628,7 @@ static rsRetVal strmConstructFinalize(strm_t *pThis)
pthread_cond_init(&pThis->notEmpty, 0);
pthread_cond_init(&pThis->isEmpty, 0);
pThis->iCnt = pThis->iEnq = pThis->iDeq = 0;
- //for(i = 0 ; i < STREAM_ASYNC_NUMBUFS ; ++i) {
- for(i = 0 ; i < 1 ; ++i) { // HOTFIX!!!
+ for(i = 0 ; i < STREAM_ASYNC_NUMBUFS ; ++i) {
CHKmalloc(pThis->asyncBuf[i].pBuf = (uchar*) malloc(sizeof(uchar) * pThis->sIOBufSize));
}
pThis->pIOBuf = pThis->asyncBuf[0].pBuf;
@@ -844,10 +843,7 @@ doAsyncWriteInternal(strm_t *pThis, size_t lenBuf)
d_pthread_cond_wait(&pThis->notFull, &pThis->mut);
pThis->asyncBuf[pThis->iEnq % STREAM_ASYNC_NUMBUFS].lenBuf = lenBuf;
- pThis->asyncBuf[pThis->iEnq % STREAM_ASYNC_NUMBUFS].pBuf = pThis->pIOBuf;
- //pThis->pIOBuf = pThis->asyncBuf[++pThis->iEnq % STREAM_ASYNC_NUMBUFS].pBuf;
- ++pThis->iEnq;
- CHKmalloc(pThis->pIOBuf = (uchar*) malloc(sizeof(uchar) * pThis->sIOBufSize));
+ pThis->pIOBuf = pThis->asyncBuf[++pThis->iEnq % STREAM_ASYNC_NUMBUFS].pBuf;
pThis->bDoTimedWait = 0; /* everything written, no need to timeout partial buffer writes */
if(++pThis->iCnt == 1)
@@ -941,8 +937,6 @@ asyncWriterThread(void *pPtr)
iDeq = pThis->iDeq++ % STREAM_ASYNC_NUMBUFS;
doWriteInternal(pThis, pThis->asyncBuf[iDeq].pBuf, pThis->asyncBuf[iDeq].lenBuf);
// TODO: error check????? 2009-07-06
- free(pThis->asyncBuf[iDeq].pBuf);
- pThis->asyncBuf[iDeq].pBuf = NULL;
--pThis->iCnt;
if(pThis->iCnt < STREAM_ASYNC_NUMBUFS) {
diff --git a/runtime/stream.h b/runtime/stream.h
index c251e5c4..9577d704 100644
--- a/runtime/stream.h
+++ b/runtime/stream.h
@@ -131,8 +131,8 @@ typedef struct strm_s {
pthread_cond_t notFull;
pthread_cond_t notEmpty;
pthread_cond_t isEmpty;
- short iEnq;
- short iDeq;
+ unsigned short iEnq; /* this MUST be unsigned as we use module arithmetic (else invalid indexing happens!) */
+ unsigned short iDeq; /* this MUST be unsigned as we use module arithmetic (else invalid indexing happens!) */
short iCnt; /* current nbr of elements in buffer */
struct {
uchar *pBuf;