From 17e8ec15961dc69d8874d0c07113f22cfcb0d788 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Thu, 31 Oct 2013 11:16:55 +0100 Subject: ompipe: make play well with v8 output module interface --- tools/ompipe.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tools/ompipe.c') diff --git a/tools/ompipe.c b/tools/ompipe.c index eab7f694..8d886509 100644 --- a/tools/ompipe.c +++ b/tools/ompipe.c @@ -69,6 +69,7 @@ typedef struct _instanceData { uchar *pipe; /* pipe or template name (display only) */ uchar *tplName; /* format template to use */ short fd; /* pipe descriptor for (current) pipe */ + pthread_mutex_t mutWrite; /* guard against multiple instances writing to same pipe */ sbool bHadError; /* did we already have/report an error on this pipe? */ } instanceData; @@ -280,6 +281,7 @@ CODESTARTcreateInstance pData->pipe = NULL; pData->fd = -1; pData->bHadError = 0; + pthread_mutex_init(&pData->mutWrite, NULL); ENDcreateInstance @@ -290,6 +292,7 @@ ENDcreateWrkrInstance BEGINfreeInstance CODESTARTfreeInstance + pthread_mutex_destroy(&pData->mutWrite); free(pData->pipe); if(pData->fd != -1) close(pData->fd); @@ -308,7 +311,10 @@ ENDtryResume BEGINdoAction CODESTARTdoAction DBGPRINTF(" (%s)\n", pData->pipe); + /* this module is single-threaded by nature */ + pthread_mutex_lock(&pData->mutWrite); iRet = writePipe(ppString, pData); + pthread_mutex_unlock(&pData->mutWrite); ENDdoAction -- cgit v1.2.3