summaryrefslogtreecommitdiff
path: root/tools/ompipe.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/ompipe.c')
-rw-r--r--tools/ompipe.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/tools/ompipe.c b/tools/ompipe.c
index 4491c82..c94568b 100644
--- a/tools/ompipe.c
+++ b/tools/ompipe.c
@@ -69,9 +69,14 @@ 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;
+typedef struct wrkrInstanceData {
+ instanceData *pData;
+} wrkrInstanceData_t;
+
typedef struct configSettings_s {
EMPTY_STRUCT
} configSettings_t;
@@ -276,18 +281,31 @@ CODESTARTcreateInstance
pData->pipe = NULL;
pData->fd = -1;
pData->bHadError = 0;
+ pthread_mutex_init(&pData->mutWrite, NULL);
ENDcreateInstance
+BEGINcreateWrkrInstance
+CODESTARTcreateWrkrInstance
+ENDcreateWrkrInstance
+
+
BEGINfreeInstance
CODESTARTfreeInstance
+ pthread_mutex_destroy(&pData->mutWrite);
free(pData->pipe);
if(pData->fd != -1)
close(pData->fd);
ENDfreeInstance
+BEGINfreeWrkrInstance
+CODESTARTfreeWrkrInstance
+ENDfreeWrkrInstance
+
+
BEGINtryResume
+ instanceData *__restrict__ const pData = pWrkrData->pData;
fd_set wrds;
struct timeval tv;
int ready;
@@ -315,9 +333,14 @@ finalize_it:
ENDtryResume
BEGINdoAction
+ instanceData *pData;
CODESTARTdoAction
- DBGPRINTF("ompipe writing to: %s\n", pData->pipe);
+ pData = pWrkrData->pData;
+ DBGPRINTF("ompipe: writing to %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
@@ -404,6 +427,7 @@ ENDmodExit
BEGINqueryEtryPt
CODESTARTqueryEtryPt
CODEqueryEtryPt_STD_OMOD_QUERIES
+CODEqueryEtryPt_STD_OMOD8_QUERIES
CODEqueryEtryPt_doHUP
CODEqueryEtryPt_STD_CONF2_QUERIES
CODEqueryEtryPt_STD_CONF2_CNFNAME_QUERIES