**************
Modified
**************
# source files
(18) base-3.14.9/src/rsrv/camsgtask.c
Destroy client connenctions when the IOC is SLAVE.
(19) base-3.14.9/src/rsrv/caservertask.c
Register CAS-TCP task at RMT. Stop responding the client connection
request when the IOC is SLAVE.
(20) base-3.14.9/src/rsrv/cast_server.c
Inactivate CAS-UDP task when the IOC is SLAVE.
(21) base-3.14.9/src/rsrv/online_notify.c
Inactivate CAS-beacon task when the IOC is SLAVE.
**************
Added
**************
(2) base-3.14.9/src/rsrv/rmtDrvIf.h
The head file for RMT driver interface.
Index: src/rsrv/camsgtask.c
===================================================================
RCS file: /net/phoebus/epicsmgr/cvsroot/epics/base/src/rsrv/camsgtask.c,v
retrieving revision 1.54.2.6
diff -u -b -r1.54.2.6 camsgtask.c
--- src/rsrv/camsgtask.c 26 Oct 2005 21:59:03 -0000 1.54.2.6
+++ src/rsrv/camsgtask.c 12 Nov 2007 18:22:33 -0000
@@ -14,6 +14,12 @@
* Date: 6-88
*/
+/************************************************************************
+modification history
+--------------------
+Oct.16,2007,Gongfa Liu destroy client connenctions when the IOC is SLAVE.
+************************************************************************/
+
#include <stddef.h>
#include <stdlib.h>
@@ -33,6 +39,8 @@
#include "rsrv.h"
#include "server.h"
+extern int masterFlagForCAS; /* by Gongfa Liu */
+
/*
* camsgtask()
*
@@ -155,6 +163,8 @@
epicsPrintf ("CAS: forcing disconnect from %s\n", buf);
break;
}
+ if(masterFlagForCAS == FALSE) client->disconnect = TRUE; /* by Gongfa Liu */
+
}
LOCK_CLIENTQ;
Index: src/rsrv/caservertask.c
===================================================================
RCS file: /net/phoebus/epicsmgr/cvsroot/epics/base/src/rsrv/caservertask.c,v
retrieving revision 1.105.2.15
diff -u -b -r1.105.2.15 caservertask.c
--- src/rsrv/caservertask.c 28 Nov 2006 18:51:16 -0000 1.105.2.15
+++ src/rsrv/caservertask.c 12 Nov 2007 18:22:33 -0000
@@ -16,6 +16,13 @@
* Date: 5-88
*/
+/************************************************************************
+modification history
+--------------------
+Oct.16,2007,Gongfa Liu register CAS-TCP task at RMT. stop responding the
+ client connection request when the IOC is SLAVE.
+************************************************************************/
+
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
@@ -45,6 +52,37 @@
#define GLBLSOURCE
#include "server.h"
+/* added by Gongfa Liu */
+/* --------------------------------------------------*/
+#include "epicsThread.h"
+#include "epicsFindSymbol.h"
+#include "rmtDrvIf.h"
+
+#ifndef vxWorks
+#define BOOL int
+#define LOCAL static
+#define IMPORT extern
+#define TRUE 1
+#define FALSE 0
+#endif
+
+typedef struct {
+ BOOL run; /* scan task is running */
+ BOOL activeFlag; /* flag to check if loop is running */
+ const char *instanceName;
+ epicsThreadId tid; /* task id of driver instance */
+} castcpPrivateType;
+
+int masterFlagForCAS = FALSE;
+
+static STATUS castcpStart(castcpPrivateType *ppvt);
+static STATUS castcpStop(castcpPrivateType *ppvt);
+static STATUS castcpGetStatus(castcpPrivateType *ppvt, drvStatusType *pstatus);
+static STATUS castcpGetInfo(castcpPrivateType *ppvt, char *pString, short *psize, char *prequestString);
+static STATUS castcpStartUpdate(castcpPrivateType *ppvt, updateMode mode);
+/* -------------------------------------------------------*/
+
+
#define DELETE_TASK(NAME)\
if(threadNameToId(NAME)!=0)threadDestroy(threadNameToId(NAME));
@@ -72,6 +110,46 @@
epicsThreadId tid;
int portChange;
+ /* added by Gongfa Liu */
+ /* register at RMT */
+ /* --------------------------------------------------*/
+ rmtEntryTabType castcpRegistry;
+ castcpPrivateType castcpPvt;
+
+ const rmtInfoTabType *prmtInfoTab;
+ STATUS (*prmtRegister)() = NULL;
+ long status1;
+
+ castcpRegistry.type = "cas-tcp";
+ castcpRegistry.instanceName = epicsThreadGetNameSelf();
+ castcpRegistry.testTimeTypical = 0;
+ castcpRegistry.pPrvt = (void *)&castcpPvt;
+ castcpRegistry.pStart = (RMTSUPFUN)castcpStart;
+ castcpRegistry.pStop = (RMTSUPFUN)castcpStop;
+ castcpRegistry.pTestIO = NULL;
+ castcpRegistry.pGetStatus = (RMTSUPFUN)castcpGetStatus;
+ castcpRegistry.pShutdown = NULL;
+ castcpRegistry.pGetInfo = (RMTSUPFUN)castcpGetInfo;
+ castcpRegistry.pGetUpdate = NULL;
+ castcpRegistry.pStartUpdate = (RMTSUPFUN)castcpStartUpdate;
+ castcpRegistry.pStopUpdate = NULL;
+
+ castcpPvt.instanceName = castcpRegistry.instanceName;
+ castcpPvt.tid = epicsThreadGetIdSelf();
+ castcpPvt.run = FALSE;
+ castcpPvt.activeFlag = TRUE; /* always TRUE when no testIO */
+
+ prmtRegister = (RMTSUPFUN)epicsFindSymbol("rmtRegister");
+ if(prmtRegister == NULL)
+ {
+ printf("Non redundant IOC!!!\n");
+ masterFlagForCAS = TRUE; /* let flag is TRUE */
+ }
+ else
+ status1 = (*prmtRegister)(&castcpRegistry, &prmtInfoTab);
+ /* ---------------------------------------------------*/
+
+
epicsSignalInstallSigPipeIgnore ();
taskwdInsert ( epicsThreadGetIdSelf (), NULL, NULL );
@@ -219,6 +297,7 @@
continue;
}
}
+ while (masterFlagForCAS == FALSE) epicsThreadSleep(0.1); /* sleep here when slave, by Gongfa Liu */
}
}
@@ -929,3 +1008,81 @@
}
UNLOCK_CLIENTQ;
}
+
+/* added by Gongfa Liu */
+/* some functions for RMT driver interface */
+/* -----------------------------------------------------------*/
+static STATUS castcpStart(castcpPrivateType *ppvt)
+{
+ printf("%s: castcpStart\n", ppvt->instanceName);
+
+ ppvt->run = TRUE;
+ masterFlagForCAS = TRUE;
+
+ return(OK);
+}
+
+static STATUS castcpStop(castcpPrivateType *ppvt)
+{
+ printf("%s: castcpStop\n", ppvt->instanceName);
+
+ ppvt->run = FALSE;
+ masterFlagForCAS = FALSE;
+
+ return(OK);
+}
+
+static STATUS castcpGetStatus(castcpPrivateType *ppvt, drvStatusType *pstatus)
+{
+ pstatus->mode = ppvt->run ? MODE_run : MODE_stop;
+ pstatus->testResult = TEST_undefined;
+
+ if( epicsThreadIsSuspended(ppvt->tid) )
+ pstatus->error = INVALID_ERROR;
+ else
+ pstatus->error = NO_ERROR;
+
+ pstatus->updateBusy = FALSE;
+ pstatus->inSync = TRUE;
+ pstatus->activeFlag = ppvt->activeFlag;
+ /* ppvt->activeFlag = FALSE; */ /* activeFlag shuold be kept TRUE when no TestIO */
+
+ return(OK);
+}
+
+static STATUS castcpGetInfo(castcpPrivateType *ppvt, char *pString, short *psize, char *prequestString)
+{
+ char castcpTaskInfo[100];
+
+ sprintf(castcpTaskInfo,"<XML><NAME>%s</NAME><STATUS>%s</STATUS></XML>",
+ ppvt->instanceName, ppvt->run ? "active" : "inactive");
+
+ if(prequestString && strlen(prequestString))
+ printf("%s: castcpGetInfo with request\n", ppvt->instanceName);
+ else
+ printf("%s: castcpGetInfo without request\n", ppvt->instanceName);
+
+ if (psize != NULL && pString != NULL)
+ {
+ if (*psize > sizeof(castcpTaskInfo))
+ strcpy (pString, castcpTaskInfo);
+ else
+ *psize = sizeof(castcpTaskInfo)+1;
+
+ printf("%s\n", castcpTaskInfo);
+ return(OK);
+ }
+ else
+ return(ERROR);
+}
+
+static STATUS castcpStartUpdate(castcpPrivateType *ppvt, updateMode mode)
+{
+ printf("%s: castcpStartUpdate\n", ppvt->instanceName);
+
+ masterFlagForCAS = FALSE;
+
+ if (ppvt->run) return(ERROR);
+ else return(OK);
+}
+/* --------------------------------------------------------------*/
Index: src/rsrv/cast_server.c
===================================================================
RCS file: /net/phoebus/epicsmgr/cvsroot/epics/base/src/rsrv/cast_server.c,v
retrieving revision 1.78.2.9
diff -u -b -r1.78.2.9 cast_server.c
--- src/rsrv/cast_server.c 7 Dec 2006 19:55:08 -0000 1.78.2.9
+++ src/rsrv/cast_server.c 12 Nov 2007 18:22:33 -0000
@@ -30,6 +30,11 @@
* pend which could lock up the cast server.
*/
+/************************************************************************
+modification history
+--------------------
+Oct.16,2007,Gongfa Liu inactivate CAS-UDP task when the IOC is SLAVE.
+************************************************************************/
#include <stddef.h>
#include <stdlib.h>
@@ -50,6 +55,8 @@
#include "server.h"
#include "rsrv.h"
+extern int masterFlagForCAS; /* by Gongfa Liu */
+
#define TIMEOUT 60.0 /* sec */
/*
@@ -311,5 +318,6 @@
cas_send_dg_msg (prsrv_cast_client);
clean_addrq ();
}
+ while (masterFlagForCAS == FALSE) epicsThreadSleep(0.1); /* sleep here when slave, by Gongfa Liu */
}
}
Index: src/rsrv/online_notify.c
===================================================================
RCS file: /net/phoebus/epicsmgr/cvsroot/epics/base/src/rsrv/online_notify.c,v
retrieving revision 1.57.2.12
diff -u -b -r1.57.2.12 online_notify.c
--- src/rsrv/online_notify.c 18 Nov 2006 00:29:04 -0000 1.57.2.12
+++ src/rsrv/online_notify.c 12 Nov 2007 18:22:33 -0000
@@ -19,6 +19,12 @@
*
*/
+/************************************************************************
+modification history
+--------------------
+Oct.16,2007,Gongfa Liu inactivate CAS-beacon task when the IOC is SLAVE.
+************************************************************************/
+
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
@@ -38,6 +44,8 @@
#define epicsExportSharedSymbols
#include "server.h"
+extern int masterFlagForCAS; /* Added by Gongfa Liu */
+
/*
* forcePort ()
*/
@@ -285,6 +293,9 @@
}
beaconCounter++; /* expected to overflow */
+
+ while (masterFlagForCAS == FALSE) epicsThreadSleep(0.1); /* sleep here when slave, by Gongfa Liu */
+
}
}
Index: src/rsrv/rmtDrvIf.h
===================================================================
--- /dev/null 2007-11-05 13:05:14.280278523 -0600
+++ src/rsrv/rmtDrvIf.h 2007-11-01 08:22:16.000000000 -0500
@@ -0,0 +1,63 @@
+/*****************************************************************************\
+* Copyright (c) 2006 Stiftung Deutsches Elektronen-Synchrotron,
+* Member of the Helmholtz Association, (DESY), HAMBURG, GERMANY.
+* Redundancy IOC codes are distributed subject to a Software License Agreement
+* found in file LICENSE.txt that is included with this distribution.
+\*****************************************************************************/
+
+#ifndef INCLrmtDrvIfh /* Include-file already inserted ? */
+#define INCLrmtDrvIfh /* defined macro flags insertion */
+
+#ifndef vxWorks
+#define OK 0
+#define ERROR -1
+typedef long STATUS;
+#endif
+
+typedef enum {UPDATE_full, UPDATE_data} updateMode;
+
+typedef enum {MODE_stop, MODE_run, MODE_standby, MODE_test} modeType;
+typedef enum {TEST_undefined, TEST_ok, TEST_error, TEST_timeout, TEST_aborted} testResultType;
+typedef enum {NO_ERROR, WARNING_ERROR, INVALID_ERROR} errorType;
+
+typedef struct {
+ modeType mode;
+ testResultType testResult;
+ errorType error;
+ int updateBusy; /* single update running */
+ int inSync; /* 1 == up-to-date with updates */
+ int activeFlag; /* set to TRUE by activity, cleared by getStatus() */
+} drvStatusType;
+
+/* special driver type for watchdog */
+#define WATCHDOG "WATCHDOG"
+
+typedef STATUS (*RMTSUPFUN)();
+typedef void (*RMTCALLBACK)(int, testResultType);
+
+typedef struct {
+ const char *type;
+ const char *instanceName;
+ unsigned short testTimeTypical;
+ void *pPrvt;
+ RMTSUPFUN pStart;
+ RMTSUPFUN pStop;
+ RMTSUPFUN pTestIO;
+ RMTSUPFUN pGetStatus;
+ RMTSUPFUN pShutdown;
+ RMTSUPFUN pGetInfo;
+ RMTSUPFUN pGetUpdate;
+ RMTSUPFUN pStartUpdate;
+ RMTSUPFUN pStopUpdate;
+
+} rmtEntryTabType;
+
+typedef struct {
+ const char *partnerIPPrivate;
+ short preferredMaster;
+} rmtInfoTabType;
+
+STATUS rmtRegister(rmtEntryTabType *prmtEntryTab,
+ const rmtInfoTabType **pprmtInfoTab);
+
+#endif /* end of insertions */
- Replies:
- Re: Redundancy Patch: rsrv Andrew Johnson
- Navigate by Date:
- Prev:
Redundancy Patch: iocsh Andrew Johnson
- Next:
Redundancy Patch: makeBaseApp Andrew Johnson
- Index:
2002
2003
2004
2005
2006
<2007>
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
Re: Redundancy Patch: iocsh Andrew Johnson
- Next:
Re: Redundancy Patch: rsrv Andrew Johnson
- Index:
2002
2003
2004
2005
2006
<2007>
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
|