summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2010-01-15 17:01:10 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2010-01-15 17:01:10 +0100
commit5b4e06fc28ef217e9ca26611e11afd974bdd1a4a (patch)
treecc42234fc9995da3974d055da054351e8b0fabb7 /runtime
parentf88291d561eb785317a39a644c53a0cf86633eaa (diff)
downloadrsyslog-5b4e06fc28ef217e9ca26611e11afd974bdd1a4a.tar.gz
rsyslog-5b4e06fc28ef217e9ca26611e11afd974bdd1a4a.tar.xz
rsyslog-5b4e06fc28ef217e9ca26611e11afd974bdd1a4a.zip
bugfix: rsyslog hangs when writing to a named pipe which nobody was reading.
Thanks to Michael Biebl for reporting this bug.
Diffstat (limited to 'runtime')
-rw-r--r--runtime/stream.c13
-rw-r--r--runtime/stream.h3
2 files changed, 12 insertions, 4 deletions
diff --git a/runtime/stream.c b/runtime/stream.c
index 2d1e9380..36f44003 100644
--- a/runtime/stream.c
+++ b/runtime/stream.c
@@ -209,13 +209,19 @@ doPhysOpen(strm_t *pThis)
default:assert(0);
break;
}
+ if(pThis->sType == STREAMTYPE_NAMED_PIPE) {
+ DBGPRINTF("Note: stream '%s' is a named pipe, open with O_NONBLOCK\n", pThis->pszCurrFName);
+ iFlags |= O_NONBLOCK;
+ }
pThis->fd = open((char*)pThis->pszCurrFName, iFlags, pThis->tOpenMode);
DBGPRINTF("file '%s' opened as #%d with mode %d\n", pThis->pszCurrFName, pThis->fd, pThis->tOpenMode);
if(pThis->fd == -1) {
- int ierrnoSave = errno;
- dbgoprint((obj_t*) pThis, "open error %d, file '%s'\n", errno, pThis->pszCurrFName);
- if(ierrnoSave == ENOENT)
+ char errStr[1024];
+ int err = errno;
+ rs_strerror_r(err, errStr, sizeof(errStr));
+ dbgoprint((obj_t*) pThis, "open error %d, file '%s': %s\n", errno, pThis->pszCurrFName, errStr);
+ if(err == ENOENT)
ABORT_FINALIZE(RS_RET_FILE_NOT_FOUND);
else
ABORT_FINALIZE(RS_RET_IO_ERROR);
@@ -429,6 +435,7 @@ strmHandleEOF(strm_t *pThis)
ISOBJ_TYPE_assert(pThis, strm);
switch(pThis->sType) {
case STREAMTYPE_FILE_SINGLE:
+ case STREAMTYPE_NAMED_PIPE:
ABORT_FINALIZE(RS_RET_EOF);
break;
case STREAMTYPE_FILE_CIRCULAR:
diff --git a/runtime/stream.h b/runtime/stream.h
index 64ffb6e1..89175b0f 100644
--- a/runtime/stream.h
+++ b/runtime/stream.h
@@ -76,7 +76,8 @@
typedef enum {
STREAMTYPE_FILE_SINGLE = 0, /**< read a single file */
STREAMTYPE_FILE_CIRCULAR = 1, /**< circular files */
- STREAMTYPE_FILE_MONITOR = 2 /**< monitor a (third-party) file */
+ STREAMTYPE_FILE_MONITOR = 2, /**< monitor a (third-party) file */
+ STREAMTYPE_NAMED_PIPE = 3 /**< file is a named pipe (so far, tested for output only) */
} strmType_t;
typedef enum { /* when extending, do NOT change existing modes! */