diff options
Diffstat (limited to 'tools/ompipe.c')
-rw-r--r-- | tools/ompipe.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/tools/ompipe.c b/tools/ompipe.c index fed1dc3..4491c82 100644 --- a/tools/ompipe.c +++ b/tools/ompipe.c @@ -12,7 +12,7 @@ * NOTE: read comments in module-template.h to understand how this pipe * works! * - * Copyright 2007-2012 Rainer Gerhards and Adiscon GmbH. + * Copyright 2007-2014 Rainer Gerhards and Adiscon GmbH. * * This file is part of rsyslog. * @@ -288,18 +288,35 @@ ENDfreeInstance BEGINtryResume + fd_set wrds; + struct timeval tv; + int ready; CODESTARTtryResume if(pData->fd == -1) { rsRetVal iRetLocal; iRetLocal = preparePipe(pData); if((iRetLocal != RS_RET_OK) || (pData->fd == -1)) - iRet = RS_RET_SUSPENDED; + ABORT_FINALIZE(RS_RET_SUSPENDED); + } else { + /* we can reach this if the pipe is full, so we need + * to check if we can write again. /dev/xconsole is the + * ugly example of why this is necessary. + */ + FD_ZERO(&wrds); + FD_SET(pData->fd, &wrds); + tv.tv_sec = 0; + tv.tv_usec = 0; + ready = select(pData->fd+1, NULL, &wrds, NULL, &tv); + DBGPRINTF("ompipe: tryResume: ready to write fd %d: %d\n", pData->fd, ready); + if(ready != 1) + ABORT_FINALIZE(RS_RET_SUSPENDED); } +finalize_it: ENDtryResume BEGINdoAction CODESTARTdoAction - DBGPRINTF(" (%s)\n", pData->pipe); + DBGPRINTF("ompipe writing to: %s\n", pData->pipe); iRet = writePipe(ppString, pData); ENDdoAction @@ -336,17 +353,8 @@ CODESTARTnewActInst } CHKiRet(OMSRsetEntry(*ppOMSR, 0, (uchar*)strdup((pData->tplName == NULL) ? - "RSYSLOG_ForwardFormat" : (char*)pData->tplName), + "RSYSLOG_FileFormat" : (char*)pData->tplName), OMSR_NO_RQD_TPL_OPTS)); - /* Old flawed template code - if(pData->tplName == NULL) { - CHKiRet(OMSRsetEntry(*ppOMSR, 0, (uchar*) "RSYSLOG_FileFormat", - OMSR_NO_RQD_TPL_OPTS)); - } else { - CHKiRet(OMSRsetEntry(*ppOMSR, 0, - (uchar*) strdup((char*) pData->tplName), - OMSR_NO_RQD_TPL_OPTS)); - }*/ CODE_STD_FINALIZERnewActInst cnfparamvalsDestruct(pvals, &actpblk); ENDnewActInst |