From 6a75f3258b2ed499397d0964dd205e6764d3857e Mon Sep 17 00:00:00 2001 From: Dirk Zimoch Date: Wed, 28 Feb 2018 16:53:35 +0100 Subject: [PATCH] add EPICS_ALLOW_MULTIPLE_IOCS to prevent starting more than one IOC on one machine --- src/rsrv/caservertask.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/rsrv/caservertask.c b/src/rsrv/caservertask.c index 71c35ec1b..8a9cf494e 100644 --- a/src/rsrv/caservertask.c +++ b/src/rsrv/caservertask.c @@ -34,6 +34,8 @@ #include "dbEvent.h" #include "dbCommon.h" #include "epicsStdioRedirect.h" +#include "epicsExit.h" +#include "epicsString.h" #define epicsExportSharedSymbols #include "rsrv.h" @@ -108,6 +110,15 @@ static void req_server (void *pParm) if ( status < 0 ) { if ( SOCKERRNO == SOCK_EADDRINUSE || SOCKERRNO == SOCK_EACCES ) { +#ifndef vxWorks + const char* multiple_iocs = getenv("EPICS_ALLOW_MULTIPLE_IOCS"); + if (multiple_iocs && epicsStrCaseCmp(multiple_iocs, "NO") == 0) + { + errlogPrintf ( "CAS: Default server port %d unavailable.\n" ,ca_server_port); + errlogPrintf ( "CAS: Probably already running an IOC on this computer.\n"); + epicsExit(1); + } +#endif /* * enable assignment of a default port * (so the getsockname() call below will