diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2009-08-18 08:51:02 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2009-08-18 08:51:02 +0200 |
commit | 224e87be0e57532baa658ec6b9656a879ccc2fa4 (patch) | |
tree | c5d85743988e739a54609d0256244db947541189 /runtime/stream.c | |
parent | 56b781e5bb1ea08b76d5dcc1d5e5eab10a40a4c6 (diff) | |
download | rsyslog-224e87be0e57532baa658ec6b9656a879ccc2fa4.tar.gz rsyslog-224e87be0e57532baa658ec6b9656a879ccc2fa4.tar.xz rsyslog-224e87be0e57532baa658ec6b9656a879ccc2fa4.zip |
bugfix? (unconfirmed, testing): segfault when writing asynchronously
I have undone a very small optimization with using pre-malloced memory,
which seems to have some issues. Now I am doing mallocs and at least in
test environment this seems to solve the issue. The code now needs more
review. If it runs flawlessly for some time, I may try to re-enable to
pre-malloc, but not necessarily: its performance benefit is very mild
(aka: I don't think it justifies introducing bigger complexities).
Diffstat (limited to 'runtime/stream.c')
-rw-r--r-- | runtime/stream.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/runtime/stream.c b/runtime/stream.c index 605a9771..1b9beb5b 100644 --- a/runtime/stream.c +++ b/runtime/stream.c @@ -628,7 +628,8 @@ 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 < STREAM_ASYNC_NUMBUFS ; ++i) { + for(i = 0 ; i < 1 ; ++i) { // HOTFIX!!! CHKmalloc(pThis->asyncBuf[i].pBuf = (uchar*) malloc(sizeof(uchar) * pThis->sIOBufSize)); } pThis->pIOBuf = pThis->asyncBuf[0].pBuf; @@ -844,7 +845,10 @@ dbgprintf("XXX: doAsyncWriteInternal: strm %p, len %ld\n", pThis, (long) lenBuf) d_pthread_cond_wait(&pThis->notFull, &pThis->mut); pThis->asyncBuf[pThis->iEnq % STREAM_ASYNC_NUMBUFS].lenBuf = lenBuf; - pThis->pIOBuf = pThis->asyncBuf[++pThis->iEnq % STREAM_ASYNC_NUMBUFS].pBuf; + 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->bDoTimedWait = 0; /* everything written, no need to timeout partial buffer writes */ if(++pThis->iCnt == 1) @@ -938,6 +942,8 @@ 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) { |