Make rsrv register itself using a DBD file

This allows the rsrv to be excluded by removing 'include rsrv.dbd'
from a local copy of the base.dbd file.
Server initialization, running and pausing are moved to new
methods of the dbServer object, and the existing registration
path is converted to just use the new rsrv.dbd file.
This commit is contained in:
Andrew Johnson
2017-06-06 23:18:55 -04:00
parent d47b1a1854
commit 2d1d14e4b4
11 changed files with 75 additions and 65 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -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)) {

View File

@@ -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();
}

View File

@@ -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

View File

@@ -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);
}

3
src/ioc/rsrv/rsrv.dbd Normal file
View File

@@ -0,0 +1,3 @@
# This DBD file links the RSRV CA server into the IOC
registrar(rsrvRegistrar)

View File

@@ -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 (

View File

@@ -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);

View File

@@ -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 */

View File

@@ -26,3 +26,5 @@ include "asSub.dbd"
# IOC Core variables
include "dbCore.dbd"
# RSRV server
include "rsrv.dbd"