diff --git a/src/ioc/db/dbServer.c b/src/ioc/db/dbServer.c index bc1094ce7..cb3830230 100644 --- a/src/ioc/db/dbServer.c +++ b/src/ioc/db/dbServer.c @@ -56,3 +56,19 @@ int dbServerClient(char *pBuf, size_t bufSize) return -1; } +#define STARTSTOP(routine, method) \ +void routine(void) \ +{ \ + dbServer *psrv = (dbServer *)ellFirst(&serverList); \ +\ + while (psrv) { \ + if (psrv->method) \ + psrv->method(); \ + psrv = (dbServer *)ellNext(&psrv->node); \ + } \ +} + +STARTSTOP(dbInitServers, init) +STARTSTOP(dbRunServers, run) +STARTSTOP(dbPauseServers, pause) +STARTSTOP(dbStopServers, stop) diff --git a/src/ioc/db/dbServer.h b/src/ioc/db/dbServer.h index 345468676..0ed7d3799 100644 --- a/src/ioc/db/dbServer.h +++ b/src/ioc/db/dbServer.h @@ -36,6 +36,12 @@ typedef struct dbServer { /* Get identity of client initiating the calling thread */ /* Must return 0 (OK), or -1 (ERROR) from unknown threads */ int (* client) (char *pBuf, size_t bufSize); + + /* Start/stop methods */ + void (* init) (void); + void (* run) (void); + void (* pause) (void); + void (* stop) (void); } dbServer; @@ -51,6 +57,11 @@ epicsShareFunc void dbsr(unsigned level); epicsShareFunc int dbServerClient(char *pBuf, size_t bufSize); +epicsShareFunc void dbInitServers(void); +epicsShareFunc void dbRunServers(void); +epicsShareFunc void dbPauseServers(void); +epicsShareFunc void dbStopServers(void); + #ifdef __cplusplus } #endif diff --git a/src/ioc/misc/iocInit.c b/src/ioc/misc/iocInit.c index 98f7dae11..738d9b472 100644 --- a/src/ioc/misc/iocInit.c +++ b/src/ioc/misc/iocInit.c @@ -6,7 +6,7 @@ * Copyright (c) 2013 Helmholtz-Zentrum Berlin * für Materialien und Energie GmbH. * EPICS BASE is distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. +* in file LICENSE that is included with this distribution. \*************************************************************************/ /* * Original Author: Marty Kraimer @@ -53,6 +53,7 @@ #include "dbLock.h" #include "dbNotify.h" #include "dbScan.h" +#include "dbServer.h" #include "dbStaticLib.h" #include "dbStaticPvt.h" #include "devSup.h" @@ -69,7 +70,6 @@ #include "registryDriverSupport.h" #include "registryJLinks.h" #include "registryRecordType.h" -#include "rsrv.h" static enum { iocVirgin, iocBuilding, iocBuilt, iocRunning, iocPaused, iocStopped @@ -203,8 +203,7 @@ int iocBuild(void) status = iocBuild_2(); if (status) return status; - /* Start CA server threads */ - rsrv_init(); + dbInitServers(); status = iocBuild_3(); @@ -247,7 +246,8 @@ int iocRun(void) if (iocState == iocBuilt) initHookAnnounce(initHookAfterInterruptAccept); - rsrv_run(); + dbRunServers(); + initHookAnnounce(initHookAfterCaServerRunning); if (iocState == iocBuilt) initHookAnnounce(initHookAtEnd); @@ -268,7 +268,7 @@ int iocPause(void) } initHookAnnounce(initHookAtIocPause); - rsrv_pause(); + dbPauseServers(); initHookAnnounce(initHookAfterCaServerPaused); dbCaPause(); @@ -421,7 +421,7 @@ static void initRecSup(void) static void initDevSup(void) { dbRecordType *pdbRecordType; - + for (pdbRecordType = (dbRecordType *)ellFirst(&pdbbase->recordTypeList); pdbRecordType; pdbRecordType = (dbRecordType *)ellNext(&pdbRecordType->node)) { diff --git a/src/ioc/misc/iocshRegisterCommon.c b/src/ioc/misc/iocshRegisterCommon.c index fefa716b9..4f8ce6646 100644 --- a/src/ioc/misc/iocshRegisterCommon.c +++ b/src/ioc/misc/iocshRegisterCommon.c @@ -4,7 +4,7 @@ * Copyright (c) 2002 The Regents of the University of California, as * Operator of Los Alamos National Laboratory. * EPICS BASE is distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. +* in file LICENSE that is included with this distribution. \*************************************************************************/ #include "envDefs.h" @@ -21,7 +21,6 @@ #include "iocshRegisterCommon.h" #include "miscIocRegister.h" #include "registryIocRegister.h" -#include "rsrvIocRegister.h" #define quote(v) #v #define str(v) quote(v) @@ -51,7 +50,6 @@ void iocshRegisterCommon(void) dbIocRegister(); dbtoolsIocRegister(); asIocRegister(); - rsrvIocRegister(); miscIocRegister(); libComRegister(); } diff --git a/src/ioc/rsrv/Makefile b/src/ioc/rsrv/Makefile index ba6ed6bd6..8ad7d01c4 100644 --- a/src/ioc/rsrv/Makefile +++ b/src/ioc/rsrv/Makefile @@ -4,7 +4,7 @@ # Copyright (c) 2002 The Regents of the University of California, as # Operator of Los Alamos National Laboratory. # EPICS BASE is distributed subject to a Software License Agreement found -# in file LICENSE that is included with this distribution. +# in file LICENSE that is included with this distribution. #************************************************************************* # This is a Makefile fragment, see src/ioc/Makefile. @@ -16,7 +16,8 @@ caserverio_INCLUDES = -I$(SRC)/ca/client camessage_INCLUDES = -I$(SRC)/ca/client INC += rsrv.h -INC += rsrvIocRegister.h + +DBD += rsrv.dbd dbCore_SRCS += caserverio.c dbCore_SRCS += caservertask.c @@ -25,4 +26,3 @@ dbCore_SRCS += camessage.c dbCore_SRCS += cast_server.c dbCore_SRCS += online_notify.c dbCore_SRCS += rsrvIocRegister.c - diff --git a/src/ioc/rsrv/caservertask.c b/src/ioc/rsrv/caservertask.c index 37c721f8a..eb18b0d40 100644 --- a/src/ioc/rsrv/caservertask.c +++ b/src/ioc/rsrv/caservertask.c @@ -469,18 +469,11 @@ void rsrv_build_addr_lists(void) } } -static dbServer rsrv_server = { - ELLNODE_INIT, - "rsrv", - casr, - casStatsFetch, - casClientInitiatingCurrentThread -}; - /* * rsrv_init () */ -int rsrv_init (void) +static +void rsrv_init (void) { long maxBytesAsALong; long status; @@ -499,8 +492,6 @@ int rsrv_init (void) rsrvCurrentClient = epicsThreadPrivateCreate (); - dbRegisterServer(&rsrv_server); - if ( envGetConfigParamPtr ( &EPICS_CAS_SERVER_PORT ) ) { ca_server_port = envGetInetPortConfigParam ( &EPICS_CAS_SERVER_PORT, (unsigned short) CA_SERVER_PORT ); @@ -768,26 +759,22 @@ int rsrv_init (void) &rsrv_online_notify_task, NULL); epicsEventMustWait(beacon_startStopEvent); - - return RSRV_OK; } -int rsrv_run (void) +static +void rsrv_run (void) { castcp_ctl = ctlRun; casudp_ctl = ctlRun; beacon_ctl = ctlRun; - - return RSRV_OK; } -int rsrv_pause (void) +static +void rsrv_pause (void) { beacon_ctl = ctlPause; casudp_ctl = ctlPause; castcp_ctl = ctlPause; - - return RSRV_OK; } static unsigned countChanListBytes ( @@ -1551,3 +1538,20 @@ void casStatsFetch ( unsigned *pChanCount, unsigned *pCircuitCount ) } UNLOCK_CLIENTQ; } + + +static dbServer rsrv_server = { + ELLNODE_INIT, + "rsrv", + casr, + casStatsFetch, + casClientInitiatingCurrentThread, + rsrv_init, + rsrv_run, + rsrv_pause +}; + +void rsrv_register_server(void) +{ + dbRegisterServer(&rsrv_server); +} diff --git a/src/ioc/rsrv/rsrv.dbd b/src/ioc/rsrv/rsrv.dbd new file mode 100644 index 000000000..0c3118f82 --- /dev/null +++ b/src/ioc/rsrv/rsrv.dbd @@ -0,0 +1,3 @@ +# This DBD file links the RSRV CA server into the IOC + +registrar(rsrvRegistrar) diff --git a/src/ioc/rsrv/rsrv.h b/src/ioc/rsrv/rsrv.h index 10947cdf0..cb966df2f 100644 --- a/src/ioc/rsrv/rsrv.h +++ b/src/ioc/rsrv/rsrv.h @@ -4,7 +4,7 @@ * Copyright (c) 2002 The Regents of the University of California, as * Operator of Los Alamos National Laboratory. * EPICS BASE is distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. +* in file LICENSE that is included with this distribution. \*************************************************************************/ /* @@ -27,9 +27,7 @@ extern "C" { #endif -epicsShareFunc int rsrv_init(void); -epicsShareFunc int rsrv_run(void); -epicsShareFunc int rsrv_pause(void); +epicsShareFunc void rsrv_register_server(void); epicsShareFunc void casr (unsigned level); epicsShareFunc int casClientInitiatingCurrentThread ( diff --git a/src/ioc/rsrv/rsrvIocRegister.c b/src/ioc/rsrv/rsrvIocRegister.c index 7a01fc9f6..74336817d 100644 --- a/src/ioc/rsrv/rsrvIocRegister.c +++ b/src/ioc/rsrv/rsrvIocRegister.c @@ -4,14 +4,14 @@ * Copyright (c) 2002 The Regents of the University of California, as * Operator of Los Alamos National Laboratory. * EPICS BASE is distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. +* in file LICENSE that is included with this distribution. \*************************************************************************/ #include "iocsh.h" +#include "epicsExport.h" #define epicsExportSharedSymbols #include "rsrv.h" -#include "rsrvIocRegister.h" /* casr */ static const iocshArg casrArg0 = { "level",iocshArgInt}; @@ -22,8 +22,11 @@ static void casrCallFunc(const iocshArgBuf *args) casr(args[0].ival); } - -void rsrvIocRegister(void) +static +void rsrvRegistrar(void) { + rsrv_register_server(); iocshRegister(&casrFuncDef,casrCallFunc); } + +epicsExportRegistrar(rsrvRegistrar); diff --git a/src/ioc/rsrv/rsrvIocRegister.h b/src/ioc/rsrv/rsrvIocRegister.h deleted file mode 100644 index f4c7e31f1..000000000 --- a/src/ioc/rsrv/rsrvIocRegister.h +++ /dev/null @@ -1,25 +0,0 @@ -/*************************************************************************\ -* Copyright (c) 2007 The University of Chicago, as Operator of Argonne -* National Laboratory. -* Copyright (c) 2002 The Regents of the University of California, as -* Operator of Los Alamos National Laboratory. -* EPICS BASE is distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. -\*************************************************************************/ - -#ifndef INC_rsrvIocRegister_H -#define INC_rsrvIocRegister_H - -#include "shareLib.h" - -#ifdef __cplusplus -extern "C" { -#endif - -epicsShareFunc void rsrvIocRegister(void); - -#ifdef __cplusplus -} -#endif - -#endif /* INC_rsrvIocRegister_H */ diff --git a/src/std/softIoc/base.dbd b/src/std/softIoc/base.dbd index 58f4884ea..564a83845 100644 --- a/src/std/softIoc/base.dbd +++ b/src/std/softIoc/base.dbd @@ -26,3 +26,5 @@ include "asSub.dbd" # IOC Core variables include "dbCore.dbd" +# RSRV server +include "rsrv.dbd"