changes for iocCore port

This commit is contained in:
Marty Kraimer
1999-11-18 16:15:43 +00:00
parent 0194c36106
commit bfe8599200
12 changed files with 545 additions and 467 deletions
+156 -170
View File
@@ -35,7 +35,7 @@ static char *sccsId = "@(#) $Id$";
#include "freeList.h"
#ifdef vxWorks
#ifdef iocCore
#include "dbEvent.h"
#endif
@@ -86,7 +86,7 @@ LOCAL int issue_get_callback(
evid monix,
ca_uint16_t cmmd
);
#ifdef vxWorks
#ifdef iocCore
LOCAL void ca_event_handler(
void *usrArg,
struct dbAddr *paddr,
@@ -127,7 +127,7 @@ LOCAL void *malloc_put_convert(unsigned long size);
LOCAL void free_put_convert(void *pBuf);
#endif
LOCAL miu caIOBlockCreate(void);
LOCAL miu caIOBlockCreate(CA_STATIC *ca_static);
LOCAL int check_a_dbr_string(const char *pStr, const unsigned count);
@@ -142,6 +142,7 @@ caHdr *pmsg,
const void *pext
)
{
CA_STATIC *ca_static = piiu->pcas;
int contig = piiu->sock_proto != IPPROTO_TCP;
caHdr msg;
unsigned bytesAvailable;
@@ -220,8 +221,8 @@ const void *pext
UNLOCK;
LD_CA_TIME (cac_fetch_poll_period(), &itimeout);
cac_mux_io (&itimeout, FALSE);
LD_CA_TIME (cac_fetch_poll_period(ca_static), &itimeout);
cac_mux_io (ca_static,&itimeout, FALSE);
LOCK;
@@ -298,6 +299,7 @@ struct ioc_in_use *piiu,
caHdr *pmsg,
const void *pext)
{
CA_STATIC *ca_static = piiu->pcas;
int contig = piiu->sock_proto != IPPROTO_TCP;
caHdr msg;
unsigned bytesAvailable;
@@ -458,7 +460,7 @@ LOCAL void cac_add_msg (IIU *piiu)
/*
* ca_os_independent_init ()
*/
int ca_os_independent_init (void)
int ca_os_independent_init (CA_STATIC *ca_static)
{
long status;
@@ -467,7 +469,7 @@ int ca_os_independent_init (void)
ca_static->ca_exception_func = ca_default_exception_handler;
ca_static->ca_exception_arg = NULL;
caSetDefaultPrintfHandler();
caSetDefaultPrintfHandler(ca_static);
/* record a default user name */
ca_static->ca_pUserName = localUserName();
@@ -486,7 +488,7 @@ int ca_os_independent_init (void)
ca_static->programBeginTime = ca_static->currentTime;
/* init sync group facility */
ca_sg_init();
ca_sg_init(ca_static);
/*
* init broadcasted search counters
@@ -499,7 +501,7 @@ int ca_os_independent_init (void)
ca_static->ca_seq_no_at_list_begin = 0u;
ca_static->ca_frames_per_try = INITIALTRIESPERFRAME;
ca_static->ca_conn_next_retry = ca_static->currentTime;
cacSetRetryInterval (0u);
cacSetRetryInterval (ca_static,0u);
ellInit(&ca_static->ca_iiuList);
ellInit(&ca_static->ca_ioeventlist);
@@ -541,7 +543,7 @@ int ca_os_independent_init (void)
ca_static->ca_server_port =
caFetchPortConfig(&EPICS_CA_SERVER_PORT, CA_SERVER_PORT);
if (repeater_installed()==FALSE) {
if (repeater_installed(ca_static)==FALSE) {
ca_spawn_repeater();
}
@@ -555,7 +557,7 @@ int ca_os_independent_init (void)
/*
* create_udp_fd
*/
void cac_create_udp_fd()
void cac_create_udp_fd(CA_STATIC *ca_static)
{
int status;
@@ -564,6 +566,7 @@ void cac_create_udp_fd()
}
status = create_net_chan(
ca_static,
&ca_static->ca_piiuCast,
NULL,
IPPROTO_UDP);
@@ -572,43 +575,33 @@ void cac_create_udp_fd()
return;
}
#ifdef vxWorks
#ifdef iocCore
{
int pri;
threadId tid;
char name[64];
cac_recv_taskArgs *pcac_recv_taskArgs;
status = taskPriorityGet(VXTASKIDSELF, &pri);
if(status<0)
genLocalExcep (ECA_INTERNAL,NULL);
strcpy(name,"RD ");
pri = threadGetPriority(threadGetIdSelf());
strcpy(name,"RD");
strncat(
name,
taskName(VXTHISTASKID),
threadGetName(threadGetIdSelf()),
sizeof(name)-strlen(name)-1);
status = taskSpawn(
name,
pri+1,
VX_FP_TASK,
4096,
(FUNCPTR)cac_recv_task,
(int)taskIdCurrent,
0,
0,
0,
0,
0,
0,
0,
0,
0);
if (status==ERROR) {
/*the new thread MUST free cac_recv_taskArgs */
pcac_recv_taskArgs = calloc(1,sizeof(cac_recv_taskArgs));
pcac_recv_taskArgs->pcas = ca_static;
pcac_recv_taskArgs->tcas = threadGetIdSelf();
tid = threadCreate(name,
pri-1,
threadGetStackSize(threadStackMedium),
(THREADFUNC)cac_recv_task,
(void *)pcac_recv_taskArgs);
if (tid==0) {
genLocalExcep (ECA_INTERNAL,NULL);
}
ca_static->recv_tid = status;
ca_static->recv_tid = tid;
}
#endif
}
@@ -649,7 +642,7 @@ int epicsShareAPI ca_modify_user_name(const char *pClientName)
* before calling this routine.
*
*/
void ca_process_exit()
void ca_process_exit(CA_STATIC *ca_static)
{
chid chix;
chid chixNext;
@@ -690,7 +683,7 @@ void ca_process_exit()
chix = (chid) ellFirst(&piiu->chidlist);
while (chix) {
chixNext = (chid) ellNext (&chix->node);
clearChannelResources (chix->cid);
clearChannelResources (ca_static,chix->cid);
chix = chixNext;
}
@@ -712,10 +705,12 @@ void ca_process_exit()
}
/* remove any pending read blocks */
caIOBlockListFree (&ca_static->ca_pend_read_list, NULL, FALSE, ECA_INTERNAL);
caIOBlockListFree (ca_static, &ca_static->ca_pend_read_list,
NULL, FALSE, ECA_INTERNAL);
/* remove any pending write blocks */
caIOBlockListFree (&ca_static->ca_pend_write_list, NULL, FALSE, ECA_INTERNAL);
caIOBlockListFree (ca_static, &ca_static->ca_pend_write_list,
NULL, FALSE, ECA_INTERNAL);
/* remove any pending io event blocks */
ellFree(&ca_static->ca_ioeventlist);
@@ -806,6 +801,7 @@ int epicsShareAPI ca_search_and_connect
long status;
ciu chix;
int strcnt;
CA_OSD_GET_CA_STATIC
/*
* make sure that chix is NULL on fail
@@ -824,7 +820,7 @@ int epicsShareAPI ca_search_and_connect
/*
* only for IOCs
*/
#ifdef vxWorks
#ifdef iocCore
{
struct dbAddr tmp_paddr;
@@ -884,7 +880,7 @@ int epicsShareAPI ca_search_and_connect
#endif
if (!ca_static->ca_piiuCast) {
cac_create_udp_fd();
cac_create_udp_fd(ca_static);
if(!ca_static->ca_piiuCast){
return ECA_NOCAST;
}
@@ -934,7 +930,7 @@ int epicsShareAPI ca_search_and_connect
* reset broadcasted search counters
*/
ca_static->ca_conn_next_retry = ca_static->currentTime;
cacSetRetryInterval (0u);
cacSetRetryInterval (ca_static,0u);
/*
* Connection Management takes care
@@ -959,9 +955,11 @@ int reply_type
int status;
int size;
caHdr *mptr;
struct ioc_in_use *piiu;
IIU *piiu;
CA_STATIC *ca_static;
piiu = chix->piiu;
ca_static = piiu->pcas;
if (piiu!=piiuCast) {
return ECA_INTERNAL;
@@ -1029,6 +1027,7 @@ void *pvalue
{
int status;
miu monix;
CA_STATIC *ca_static;
CHIXCHK(chix);
@@ -1043,7 +1042,7 @@ void *pvalue
return ECA_BADCOUNT;
}
#ifdef vxWorks
#ifdef iocCore
{
int status;
@@ -1067,8 +1066,9 @@ void *pvalue
* so that we are not deleted without
* reclaiming the resource
*/
ca_static = ((IIU *)chix->piiu)->pcas;
LOCK;
monix = caIOBlockCreate();
monix = caIOBlockCreate(ca_static);
if (monix) {
monix->chan = chix;
@@ -1087,7 +1087,7 @@ void *pvalue
else {
if (ca_state(chix)==cs_conn) {
ellDelete (&pend_read_list, &monix->node);
caIOBlockFree (monix);
caIOBlockFree (ca_static,monix);
}
}
}
@@ -1112,6 +1112,7 @@ const void *arg
{
int status;
miu monix;
CA_STATIC *ca_static;
CHIXCHK(chix);
@@ -1129,7 +1130,7 @@ const void *arg
return ECA_NORDACCESS;
}
#ifdef vxWorks
#ifdef iocCore
if (!chix->piiu) {
struct pending_event ev;
@@ -1148,8 +1149,9 @@ const void *arg
* so that we are not deleted without
* reclaiming the resource
*/
ca_static = ((IIU *)chix->piiu)->pcas;
LOCK;
monix = caIOBlockCreate();
monix = caIOBlockCreate(ca_static);
if (monix) {
monix->chan = chix;
@@ -1162,11 +1164,11 @@ const void *arg
}
if (monix) {
status = issue_get_callback (monix, CA_PROTO_READ_NOTIFY);
status = issue_get_callback(monix, CA_PROTO_READ_NOTIFY);
if (status != ECA_NORMAL) {
if (ca_state(chix)==cs_conn) {
ellDelete (&pend_read_list, &monix->node);
caIOBlockFree (monix);
caIOBlockFree (ca_static,monix);
}
}
}
@@ -1179,9 +1181,9 @@ const void *arg
}
/*
* caIOBlockCreate()
* caIOBlockCreate(ca_static)
*/
LOCAL miu caIOBlockCreate(void)
LOCAL miu caIOBlockCreate(CA_STATIC *ca_static)
{
int status;
miu pIOBlock;
@@ -1213,7 +1215,7 @@ LOCAL miu caIOBlockCreate(void)
/*
* caIOBlockFree()
*/
void caIOBlockFree(miu pIOBlock)
void caIOBlockFree(CA_STATIC *ca_static,miu pIOBlock)
{
int status;
@@ -1231,6 +1233,7 @@ void caIOBlockFree(miu pIOBlock)
* Free all io blocks on the list attached to the specified channel
*/
void caIOBlockListFree(
CA_STATIC *ca_static,
ELLLIST *pList,
chid chan,
int cbRequired,
@@ -1257,7 +1260,7 @@ int status)
args.status = status;
args.dbr = NULL;
caIOBlockFree (monix);
caIOBlockFree (ca_static, monix);
if (cbRequired && monix->usr_func) {
(*monix->usr_func) (args);
@@ -1271,7 +1274,9 @@ int status)
* ISSUE_GET_CALLBACK()
* (lock must be on)
*/
LOCAL int issue_get_callback(evid monix, ca_uint16_t cmmd)
LOCAL int issue_get_callback(
evid monix,
ca_uint16_t cmmd)
{
int status;
chid chix = monix->chan;
@@ -1329,6 +1334,7 @@ const void *usrarg
IIU *piiu;
int status;
miu monix;
CA_OSD_GET_CA_STATIC
/*
* valid channel id test
@@ -1372,7 +1378,7 @@ const void *usrarg
}
}
#ifdef vxWorks
#ifdef iocCore
if (!piiu) {
/* cast removes const */
ciu pChan = (ciu) chix;
@@ -1389,10 +1395,10 @@ const void *usrarg
*/
if(ppn->busy){
UNLOCK;
status = semTake(
status = semBinaryTakeTimeout(
ca_static->ca_blockSem,
sysClkRateGet()*60);
if(status != OK){
60.0);
if(status != semTakeOK){
return ECA_PUTCBINPROG;
}
LOCK;
@@ -1445,7 +1451,7 @@ const void *usrarg
}
return ECA_NORMAL;
}
#endif /*vxWorks*/
#endif /*iocCore*/
/*
* lock around io block create and list add
@@ -1453,7 +1459,7 @@ const void *usrarg
* reclaiming the resource
*/
LOCK;
monix = caIOBlockCreate();
monix = caIOBlockCreate(ca_static);
if (!monix) {
UNLOCK;
return ECA_ALLOCMEM;
@@ -1478,7 +1484,7 @@ const void *usrarg
LOCK;
if (ca_state(chix)==cs_conn) {
ellDelete (&pend_write_list, &monix->node);
caIOBlockFree(monix);
caIOBlockFree(ca_static, monix);
}
UNLOCK;
return status;
@@ -1491,7 +1497,7 @@ const void *usrarg
/*
* CA_PUT_NOTIFY_ACTION
*/
#ifdef vxWorks
#ifdef iocCore
LOCAL void ca_put_notify_action(PUTNOTIFY *ppn)
{
CACLIENTPUTNOTIFY *pcapn;
@@ -1505,10 +1511,10 @@ LOCAL void ca_put_notify_action(PUTNOTIFY *ppn)
*/
chix = (chid) ppn->usrPvt;
if(!chix){
taskSuspend(0);
threadSuspend(threadGetIdSelf());
}
if(!chix->ppn){
taskSuspend(0);
threadSuspend(threadGetIdSelf());
}
piiu = chix->piiu;
@@ -1521,9 +1527,9 @@ LOCAL void ca_put_notify_action(PUTNOTIFY *ppn)
* the database (or indirectly blocking
* one client on another client).
*/
semTake(pcas->ca_putNotifyLock, WAIT_FOREVER);
semMutexTakeAssert(pcas->ca_putNotifyLock);
ellAdd(&pcas->ca_putNotifyQue, &pcapn->node);
semGive(pcas->ca_putNotifyLock);
semMutexGive(pcas->ca_putNotifyLock);
/*
* offload the labor for this to the
@@ -1533,7 +1539,7 @@ LOCAL void ca_put_notify_action(PUTNOTIFY *ppn)
db_post_extra_labor(pcas->ca_evuser);
}
#endif /*vxWorks*/
#endif /*iocCore*/
/*
* CA_ARRAY_PUT()
@@ -1577,7 +1583,7 @@ int epicsShareAPI ca_array_put (
}
}
#ifdef vxWorks
#ifdef iocCore
/*
* If channel is on this client's host then
* call the database directly
@@ -1594,7 +1600,7 @@ int epicsShareAPI ca_array_put (
else
return ECA_PUTFAIL;
}
#endif /*vxWorks*/
#endif /*iocCore*/
return issue_ca_array_put(CA_PROTO_WRITE, ~0U, type, count, chix, pvalue);
}
@@ -1745,6 +1751,7 @@ const void *pvalue
LOCAL void *malloc_put_convert(unsigned long size)
{
struct putCvrtBuf *pBuf;
CA_OSD_GET_CA_STATIC
LOCK;
pBuf = (struct putCvrtBuf *) ellFirst(&ca_static->putCvrtBuf);
@@ -1780,6 +1787,7 @@ LOCAL void *malloc_put_convert(unsigned long size)
LOCAL void free_put_convert(void *pBuf)
{
struct putCvrtBuf *pBufHdr;
CA_OSD_GET_CA_STATIC
pBufHdr = (struct putCvrtBuf *)pBuf;
pBufHdr -= 1;
@@ -1804,6 +1812,7 @@ void (*pfunc)(struct connection_handler_args)
)
{
ciu pChan = (ciu) chix; /* remove const */
CA_OSD_GET_CA_STATIC
INITCHK;
LOOSECHIXCHK(pChan);
@@ -1835,6 +1844,7 @@ void (*pfunc)(struct access_rights_handler_args))
{
ciu pChan = (ciu) chan; /* remove const */
struct access_rights_handler_args args;
CA_OSD_GET_CA_STATIC
INITCHK;
LOOSECHIXCHK(pChan);
@@ -1863,6 +1873,7 @@ int epicsShareAPI ca_add_exception_event
const void *arg
)
{
CA_OSD_GET_CA_STATIC
INITCHK;
LOCK;
@@ -1901,6 +1912,7 @@ long mask
ciu pChan = (ciu) chix; /* remove const */
miu monix;
int status;
CA_OSD_GET_CA_STATIC
INITCHK;
LOOSECHIXCHK(pChan);
@@ -1937,14 +1949,14 @@ long mask
LOCK;
if (!pChan->piiu) {
# ifdef vxWorks
# ifdef iocCore
monix = freeListMalloc (ca_static->ca_dbMonixFreeList);
# else
return ECA_INTERNAL;
# endif
}
else {
monix = caIOBlockCreate();
monix = caIOBlockCreate(ca_static);
}
if(!monix){
@@ -1967,7 +1979,7 @@ long mask
monix->timeout = timeout;
monix->mask = (unsigned short) mask;
# ifdef vxWorks
# ifdef iocCore
if(!pChan->piiu){
status = db_add_event(
evuser,
@@ -2017,7 +2029,7 @@ long mask
LOCK;
if (ca_state(pChan)==cs_conn) {
ellDelete (&pChan->eventq, &monix->node);
caIOBlockFree(monix);
caIOBlockFree(ca_static, monix);
}
UNLOCK
}
@@ -2089,10 +2101,10 @@ int ca_request_event(evid monix)
/*
*
* CA_EVENT_HANDLER()
* (only for local (for now vxWorks) clients)
* (only for local (for now iocCore) clients)
*
*/
#ifdef vxWorks
#ifdef iocCore
LOCAL void ca_event_handler(
void *usrArg,
struct dbAddr *paddr,
@@ -2111,6 +2123,7 @@ db_field_log *pfl
unsigned size;
};
struct tmp_buff *pbuf = NULL;
CA_OSD_GET_CA_STATIC
/*
* clip to the native count
@@ -2250,6 +2263,7 @@ int epicsShareAPI ca_clear_event (evid monix)
int status;
caHdr hdr;
evid lkup;
CA_OSD_GET_CA_STATIC
/*
* is it a valid channel ?
@@ -2273,7 +2287,7 @@ int epicsShareAPI ca_clear_event (evid monix)
/* disable any further events from this event block */
pMon->usr_func = NULL;
#ifdef vxWorks
#ifdef iocCore
if (!chix->piiu) {
register int status;
@@ -2288,7 +2302,7 @@ int epicsShareAPI ca_clear_event (evid monix)
return ECA_NORMAL;
}
#endif /*vxWorks*/
#endif /*iocCore*/
/*
* dont send the message if the conn is down (just delete from the
@@ -2319,7 +2333,7 @@ int epicsShareAPI ca_clear_event (evid monix)
else{
LOCK;
ellDelete(&chix->eventq, &pMon->node);
caIOBlockFree(pMon);
caIOBlockFree(ca_static, pMon);
UNLOCK;
status = ECA_NORMAL;
}
@@ -2350,6 +2364,7 @@ int epicsShareAPI ca_clear_channel (chid pChan)
caHdr hdr;
caCh *pold_ch;
enum channel_state old_chan_state;
CA_OSD_GET_CA_STATIC
if (pChan->piiu) {
pChan = bucketLookupItemUnsignedId
@@ -2390,7 +2405,7 @@ int epicsShareAPI ca_clear_channel (chid pChan)
if (monix->chan == pChan)
monix->usr_func = NULL;
#ifdef vxWorks
#ifdef iocCore
if (!pChan->piiu) {
CACLIENTPUTNOTIFY *ppn;
int status;
@@ -2443,7 +2458,7 @@ int epicsShareAPI ca_clear_channel (chid pChan)
*/
if (old_chan_state != cs_conn) {
UNLOCK;
clearChannelResources (pChan->cid);
clearChannelResources (ca_static,pChan->cid);
return ECA_NORMAL;
}
@@ -2472,18 +2487,10 @@ int epicsShareAPI ca_clear_channel (chid pChan)
return status;
}
/*
* ca_cidToChid()
*/
chid epicsShareAPI ca_cidToChid(unsigned id)
{
return (chid) bucketLookupItemUnsignedId(ca_static->ca_pSlowBucket, &id);
}
/*
* clearChannelResources()
*/
void clearChannelResources(unsigned id)
void clearChannelResources(CA_STATIC *ca_static,unsigned id)
{
struct ioc_in_use *piiu;
ciu chix;
@@ -2503,17 +2510,19 @@ void clearChannelResources(unsigned id)
/*
* remove any orphaned get callbacks for this channel
*/
caIOBlockListFree (&ca_static->ca_pend_read_list, chix, FALSE, ECA_INTERNAL);
caIOBlockListFree (ca_static, &ca_static->ca_pend_read_list, chix,
FALSE, ECA_INTERNAL);
/*
* remove any orphaned put callbacks for this channel
*/
caIOBlockListFree (&ca_static->ca_pend_write_list, chix, FALSE, ECA_INTERNAL);
caIOBlockListFree (ca_static, &ca_static->ca_pend_write_list, chix,
FALSE, ECA_INTERNAL);
/*
* remove any monitors still attached to this channel
*/
caIOBlockListFree (&chix->eventq, NULL, FALSE, ECA_INTERNAL);
caIOBlockListFree (ca_static, &chix->eventq, NULL, FALSE, ECA_INTERNAL);
status = bucketRemoveItemUnsignedId (
ca_static->ca_pSlowBucket, &chix->cid);
@@ -2538,6 +2547,7 @@ int epicsShareAPI ca_pend (ca_real timeout, int early)
struct timeval beg_time;
ca_real delay;
struct timeval tmo;
CA_OSD_GET_CA_STATIC
INITCHK;
@@ -2559,7 +2569,7 @@ int epicsShareAPI ca_pend (ca_real timeout, int early)
* force the flush
*/
CLR_CA_TIME (&tmo);
cac_mux_io(&tmo, TRUE);
cac_mux_io(ca_static,&tmo, TRUE);
return ECA_NORMAL;
}
@@ -2568,7 +2578,7 @@ int epicsShareAPI ca_pend (ca_real timeout, int early)
* force the flush
*/
CLR_CA_TIME (&tmo);
cac_mux_io(&tmo, TRUE);
cac_mux_io(ca_static,&tmo, TRUE);
return ECA_TIMEOUT;
}
@@ -2582,18 +2592,18 @@ int epicsShareAPI ca_pend (ca_real timeout, int early)
* force the flush
*/
CLR_CA_TIME (&tmo);
cac_mux_io(&tmo, TRUE);
cac_mux_io(ca_static,&tmo, TRUE);
return ECA_NORMAL;
}
if(timeout == 0.0){
remaining = cac_fetch_poll_period();
remaining = cac_fetch_poll_period(ca_static);
}
else{
remaining = timeout-delay;
/*
* Allow for CA background labor
*/
remaining = min(cac_fetch_poll_period(), remaining);
remaining = min(cac_fetch_poll_period(ca_static), remaining);
}
@@ -2631,12 +2641,12 @@ int epicsShareAPI ca_pend (ca_real timeout, int early)
* for ECA_TIMEOUT to be returned when the IO completed
* during the pend io timeout clean up phase.
*/
cac_block_for_io_completion (&tmo);
cac_block_for_io_completion (ca_static,&tmo);
return ECA_TIMEOUT;
}
tmo.tv_sec = (long) remaining;
tmo.tv_usec = (long) ((remaining-tmo.tv_sec)*USEC_PER_SEC);
cac_block_for_io_completion (&tmo);
cac_block_for_io_completion (ca_static,&tmo);
if (timeout != 0.0) {
delay = cac_time_diff (&ca_static->currentTime,
@@ -2648,7 +2658,7 @@ int epicsShareAPI ca_pend (ca_real timeout, int early)
/*
* cac_fetch_poll_period()
*/
double cac_fetch_poll_period(void)
double cac_fetch_poll_period(CA_STATIC *ca_static)
{
if (!piiuCast) {
return SELECT_POLL_NO_SEARCH;
@@ -2661,6 +2671,19 @@ double cac_fetch_poll_period(void)
}
}
void cac_gettimeval(struct timeval *pt)
{
TS_STAMP ts;
int status;
status = clockGetCurrentTime(&ts);
assert(status==0);
pt->tv_sec = ts.secPastEpoch;
pt->tv_usec = ts.nsec/1000;
}
/*
* cac_time_diff()
*/
@@ -2747,6 +2770,7 @@ LOCAL void ca_pend_io_cleanup()
{
struct ioc_in_use *piiu;
ciu pchan;
CA_OSD_GET_CA_STATIC
LOCK;
pchan = (ciu) ellFirst (&piiuCast->chidlist);
@@ -2784,6 +2808,7 @@ LOCAL void ca_pend_io_cleanup()
int epicsShareAPI ca_flush_io()
{
struct timeval timeout;
CA_OSD_GET_CA_STATIC
INITCHK;
@@ -2793,7 +2818,7 @@ int epicsShareAPI ca_flush_io()
*/
ca_static->ca_flush_pending = TRUE;
CLR_CA_TIME (&timeout);
cac_mux_io (&timeout, TRUE);
cac_mux_io (ca_static,&timeout, TRUE);
return ECA_NORMAL;
}
@@ -2804,6 +2829,7 @@ int epicsShareAPI ca_flush_io()
*/
int epicsShareAPI ca_test_io()
{
CA_OSD_GET_CA_STATIC
if(pndrecvcnt==0u){
return ECA_IODONE;
}
@@ -2816,9 +2842,11 @@ int epicsShareAPI ca_test_io()
* genLocalExcepWFL ()
* (generate local exception with file and line number)
*/
void genLocalExcepWFL (long stat, char *ctx, char *pFile, unsigned lineNo)
void genLocalExcepWFL (long stat, const char *ctx,
const char *pFile, unsigned lineNo)
{
struct exception_handler_args args;
CA_OSD_GET_CA_STATIC
args.usr = (void *) ca_static->ca_exception_arg;
args.chid = NULL;
@@ -2953,6 +2981,7 @@ int ca_busy_message(struct ioc_in_use *piiu)
{
caHdr hdr;
int status;
CA_OSD_GET_CA_STATIC
if(!piiu){
return ECA_INTERNAL;
@@ -2983,10 +3012,12 @@ int ca_ready_message(struct ioc_in_use *piiu)
{
caHdr hdr;
int status;
CA_STATIC *ca_static;
if(!piiu){
return ECA_INTERNAL;
}
ca_static = piiu->pcas;
/*
* dont broadcast
@@ -3010,7 +3041,9 @@ int ca_ready_message(struct ioc_in_use *piiu)
* echo_request (lock must be on)
*
*/
int echo_request(struct ioc_in_use *piiu, ca_time *pCurrentTime)
int echo_request(
struct ioc_in_use *piiu,
ca_time *pCurrentTime)
{
caHdr hdr;
int status;
@@ -3047,7 +3080,9 @@ void noop_msg(struct ioc_in_use *piiu)
{
caHdr hdr;
int status;
CA_STATIC *ca_static;
ca_static = piiu->pcas;
hdr.m_cmmd = htons(CA_PROTO_NOOP);
hdr.m_dataType = htons(0);
hdr.m_count = htons(0);
@@ -3066,15 +3101,17 @@ void noop_msg(struct ioc_in_use *piiu)
* (lock must be on)
*
*/
void issue_client_host_name(struct ioc_in_use *piiu)
void issue_client_host_name( struct ioc_in_use *piiu)
{
unsigned size;
caHdr hdr;
char *pName;
CA_STATIC *ca_static;
if(!piiu){
return;
}
ca_static = piiu->pcas;
/*
* dont broadcast client identification protocol
@@ -3115,10 +3152,12 @@ void issue_identify_client(struct ioc_in_use *piiu)
unsigned size;
caHdr hdr;
char *pName;
CA_STATIC *ca_static;
if(!piiu){
return;
}
ca_static = piiu->pcas;
/*
* dont broadcast client identification protocol
@@ -3160,15 +3199,16 @@ int issue_claim_channel (chid pchan)
unsigned size;
const char *pStr;
int status;
CA_STATIC *ca_static;
LOCK;
if (!piiu) {
ca_printf("CAC: nill piiu claim attempted?\n");
UNLOCK;
return ECA_INTERNAL;
}
ca_static = piiu->pcas;
LOCK;
/*
* dont broadcast
*/
@@ -3231,7 +3271,7 @@ int issue_claim_channel (chid pchan)
ellAdd (&piiu->chidlist, &pchan->node);
if (!CA_V42(CA_PROTOCOL_VERSION, piiu->minor_version_number)) {
cac_reconnect_channel(pchan->cid, TYPENOTCONN, 0);
cac_reconnect_channel(ca_static, pchan->cid, TYPENOTCONN, 0);
}
}
else {
@@ -3281,6 +3321,7 @@ LOCAL void ca_default_exception_handler (struct exception_handler_args args)
*/
int epicsShareAPI ca_add_fd_registration(CAFDHANDLER *func, const void *arg)
{
CA_OSD_GET_CA_STATIC
INITCHK;
fd_register_func = func;
@@ -3347,64 +3388,6 @@ READONLY char * epicsShareAPI ca_version()
return CA_VERSION_STRING;
}
/*
*
* CA_CHANNEL_STATUS
*
*/
#ifdef vxWorks
int ca_channel_status(int tid)
{
chid chix;
IIU *piiu;
struct CA_STATIC *pcas;
pcas = (struct CA_STATIC *)
taskVarGet(tid, (int *)&ca_static);
if (pcas == (struct CA_STATIC *) ERROR)
return ECA_NOCACTX;
# define ca_static pcas
LOCK
# undef ca_static
piiu = (struct ioc_in_use *) pcas->ca_iiuList.node.next;
while(piiu){
chix = (chid) &piiu->chidlist.node;
while ( (chix = (chid) chix->node.next) ){
printf( "%s native type=%d ",
ca_name(chix),
ca_field_type(chix));
printf( "N elements=%d IOC=%s state=",
ca_element_count(chix),
piiu->host_name_str);
switch(ca_state(chix)){
case cs_never_conn:
printf("never connected to an IOC");
break;
case cs_prev_conn:
printf("disconnected from IOC");
break;
case cs_conn:
printf("connected to an IOC");
break;
case cs_closed:
printf("invalid channel");
break;
default:
break;
}
printf("\n");
}
piiu = (struct ioc_in_use *)piiu->node.next;
}
# define ca_static pcas
UNLOCK
# undef ca_static
return ECA_NORMAL;
}
#endif /*vxWorks*/
/*
* ca_replace_printf_handler ()
*/
@@ -3412,6 +3395,7 @@ int epicsShareAPI ca_replace_printf_handler (
int (*ca_printf_func)(const char *pformat, va_list args)
)
{
CA_OSD_GET_CA_STATIC
INITCHK;
if (ca_printf_func) {
@@ -3421,7 +3405,7 @@ int (*ca_printf_func)(const char *pformat, va_list args)
/*
* os dependent
*/
caSetDefaultPrintfHandler();
caSetDefaultPrintfHandler(ca_static);
}
return ECA_NORMAL;
@@ -3450,6 +3434,7 @@ int epicsShareAPI ca_printf (const char *pformat, ...)
int epicsShareAPI ca_vPrintf (const char *pformat, va_list args)
{
int (*ca_printf_func)(const char *pformat, va_list args);
CA_OSD_GET_CA_STATIC
if (ca_static) {
if (ca_static->ca_printf_func) {
@@ -3502,6 +3487,7 @@ unsigned short epicsShareAPI ca_get_element_count (chid chan)
unsigned epicsShareAPI ca_get_ioc_connection_count ()
{
unsigned count;
CA_OSD_GET_CA_STATIC
INITCHK;
+13 -37
View File
@@ -75,44 +75,7 @@ void performGrEnumTest (chid chan);
void performCtrlDoubleTest (chid chan);
#ifdef vxWorks
#include <vxWorks.h>
#include <taskLib.h>
int acctst(char *pname)
{
return taskSpawn(
"acctst",
200,
VX_FP_TASK,
20000,
doacctst,
(int)pname,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL);
}
#else /* not vxWorks */
int main(int argc, char **argv)
{
if(argc == 2){
doacctst(argv[1]);
}
else{
printf("usage: %s <chan name>\n", argv[0]);
}
return 0;
}
#endif /*vxWorks*/
int doacctst(char *pname)
{
chid chix1;
chid chix2;
@@ -1010,6 +973,19 @@ int doacctst(char *pname)
return(0);
}
#ifndef iocCore
int main(int argc, char **argv)
{
if(argc == 2){
acctst(argv[1]);
}
else{
printf("usage: %s <chan name>\n", argv[0]);
}
return 0;
}
#endif /*iocCore */
/*
* pend_event_delay_test()
*/
+1 -1
View File
@@ -39,7 +39,7 @@
* NOTE: on multithreaded systems this assumes that the
* local implementation of select is reentrant
*/
int cac_select_io (struct timeval *ptimeout, int flags)
int cac_select_io (CA_STATIC *ca_static, struct timeval *ptimeout, int flags)
{
/*
* Use auto timeout so there is no chance of
+1 -3
View File
@@ -87,8 +87,7 @@ void timeIt(
ti *pItem,
unsigned iterations
);
#ifndef vxWorks
#ifndef iocCore
int main(int argc, char **argv)
{
char *pname;
@@ -110,7 +109,6 @@ printf("usage: %s <channel name> [<if 2nd arg present append number to pv name>]
return 0;
}
#endif
/*
* catime ()
+42 -24
View File
@@ -31,6 +31,11 @@
/* */
/*
* $Log$
* Revision 1.45 1999/09/02 21:44:48 jhill
* improved the way that socket error numbers are converted to strings,
* changed () to (void) in func proto, and fixed missing parameter to
* checkConnWatchdogs() bug resulting from this
*
* Revision 1.44 1999/07/16 16:38:59 jhill
* added congestion thresh parm to search alg
*
@@ -92,14 +97,14 @@ LOCAL void logRetryInterval(char *pFN, unsigned lineno);
#define LOGRETRYINTERVAL
#endif
LOCAL void retrySearchRequest();
LOCAL unsigned bhtHashIP(const struct sockaddr_in *pina);
LOCAL int updateBeaconPeriod (bhe *pBHE);
LOCAL void retrySearchRequest(CA_STATIC *ca_static);
LOCAL unsigned bhtHashIP(CA_STATIC *ca_static, const struct sockaddr_in *pina);
LOCAL int updateBeaconPeriod (CA_STATIC *ca_static, bhe *pBHE);
/*
* checkConnWatchdogs()
*/
void checkConnWatchdogs(unsigned closeAllowed)
void checkConnWatchdogs(CA_STATIC *ca_static, unsigned closeAllowed)
{
IIU *piiu;
ca_real delay;
@@ -159,7 +164,7 @@ void checkConnWatchdogs(unsigned closeAllowed)
*
*
*/
void manage_conn()
void manage_conn(CA_STATIC *ca_static)
{
IIU *piiu;
ca_real delay;
@@ -228,7 +233,7 @@ void manage_conn()
&ca_static->ca_last_repeater_try);
if (delay > REPEATER_TRY_PERIOD) {
ca_static->ca_last_repeater_try = ca_static->currentTime;
notify_ca_repeater();
notify_ca_repeater(ca_static);
}
}
@@ -256,7 +261,7 @@ void manage_conn()
* number of tries)
*/
if (delay <= 0.0 && ca_static->ca_search_retry < MAXCONNTRIES) {
retrySearchRequest ();
retrySearchRequest (ca_static);
}
ca_static->ca_manage_conn_active = FALSE;
@@ -265,7 +270,7 @@ void manage_conn()
/*
* retrySearchRequest ()
*/
LOCAL void retrySearchRequest ()
LOCAL void retrySearchRequest (CA_STATIC *ca_static)
{
ciu chan;
ciu firstChan;
@@ -385,7 +390,7 @@ LOCAL void retrySearchRequest ()
#if 0
printf ("increasing search try interval\n");
#endif
cacSetRetryInterval(ca_static->ca_min_retry+1u);
cacSetRetryInterval(ca_static, ca_static->ca_min_retry+1u);
}
ca_static->ca_min_retry = UINT_MAX;
@@ -496,7 +501,7 @@ LOCAL void retrySearchRequest ()
* cacSetRetryInterval()
* (sets the interval between search tries)
*/
void cacSetRetryInterval(unsigned retryNo)
void cacSetRetryInterval(CA_STATIC *ca_static, unsigned retryNo)
{
unsigned idelay;
ca_real delay;
@@ -536,6 +541,7 @@ LOCAL void logRetryInterval(char *pFN, unsigned lineno)
{
ca_time currentTime;
ca_real delay;
CA_OSD_GET_CA_STATIC
assert(ca_static->ca_conn_next_retry.tv_usec<USEC_PER_SEC);
cac_gettimeval(&currentTime);
@@ -561,7 +567,9 @@ LOCAL void logRetryInterval(char *pFN, unsigned lineno)
/*
* MARK_SERVER_AVAILABLE
*/
void mark_server_available (const struct sockaddr_in *pnet_addr)
void mark_server_available (
CA_STATIC *ca_static,
const struct sockaddr_in *pnet_addr)
{
ciu chan;
bhe *pBHE;
@@ -576,10 +584,10 @@ void mark_server_available (const struct sockaddr_in *pnet_addr)
/*
* look for it in the hash table
*/
pBHE = lookupBeaconInetAddr(pnet_addr);
pBHE = lookupBeaconInetAddr(ca_static, pnet_addr);
if (pBHE) {
netChange = updateBeaconPeriod (pBHE);
netChange = updateBeaconPeriod (ca_static, pBHE);
/*
* update state of health for active virtual circuits
@@ -601,7 +609,7 @@ void mark_server_available (const struct sockaddr_in *pnet_addr)
* shortly after the program started up)
*/
netChange = FALSE;
createBeaconHashEntry (pnet_addr, TRUE);
createBeaconHashEntry (ca_static,pnet_addr, TRUE);
}
if(!netChange){
@@ -662,7 +670,7 @@ void mark_server_available (const struct sockaddr_in *pnet_addr)
* set retry count of all disconnected channels
* to zero
*/
cacSetRetryInterval(0u);
cacSetRetryInterval(ca_static, 0u);
chan = (ciu) ellFirst(&piiuCast->chidlist);
while (chan) {
chan->retry = 0u;
@@ -686,7 +694,7 @@ void mark_server_available (const struct sockaddr_in *pnet_addr)
*
* updates beacon period, and looks for beacon anomalies
*/
LOCAL int updateBeaconPeriod (bhe *pBHE)
LOCAL int updateBeaconPeriod (CA_STATIC *ca_static, bhe *pBHE)
{
ca_real currentPeriod;
int netChange = FALSE;
@@ -853,17 +861,20 @@ LOCAL int updateBeaconPeriod (bhe *pBHE)
*
* LOCK must be applied
*/
bhe *createBeaconHashEntry(const struct sockaddr_in *pina, unsigned sawBeacon)
bhe *createBeaconHashEntry(
CA_STATIC *ca_static,
const struct sockaddr_in *pina,
unsigned sawBeacon)
{
bhe *pBHE;
unsigned index;
pBHE = lookupBeaconInetAddr(pina);
pBHE = lookupBeaconInetAddr(ca_static, pina);
if(pBHE){
return pBHE;
}
index = bhtHashIP(pina);
index = bhtHashIP(ca_static,pina);
pBHE = (bhe *)calloc(1,sizeof(*pBHE));
if(!pBHE){
@@ -924,12 +935,14 @@ bhe *createBeaconHashEntry(const struct sockaddr_in *pina, unsigned sawBeacon)
*
* LOCK must be applied
*/
bhe *lookupBeaconInetAddr (const struct sockaddr_in *pina)
bhe *lookupBeaconInetAddr (
CA_STATIC *ca_static,
const struct sockaddr_in *pina)
{
bhe *pBHE;
unsigned index;
index = bhtHashIP(pina);
index = bhtHashIP(ca_static,pina);
pBHE = ca_static->ca_beaconHash[index];
while (pBHE) {
@@ -949,13 +962,15 @@ bhe *lookupBeaconInetAddr (const struct sockaddr_in *pina)
*
* LOCK must be applied
*/
void removeBeaconInetAddr (const struct sockaddr_in *pina)
void removeBeaconInetAddr (
CA_STATIC *ca_static,
const struct sockaddr_in *pina)
{
bhe *pBHE;
bhe **ppBHE;
unsigned index;
index = bhtHashIP(pina);
index = bhtHashIP(ca_static,pina);
ppBHE = &ca_static->ca_beaconHash[index];
pBHE = *ppBHE;
@@ -975,7 +990,7 @@ void removeBeaconInetAddr (const struct sockaddr_in *pina)
/*
* bhtHashIP()
*/
LOCAL unsigned bhtHashIP(const struct sockaddr_in *pina)
LOCAL unsigned bhtHashIP(CA_STATIC *ca_static, const struct sockaddr_in *pina)
{
unsigned index;
@@ -1035,6 +1050,7 @@ void retryPendingClaims(IIU *piiu)
{
chid chan;
int status;
CA_STATIC *ca_static = piiu->pcas;
LOCK;
while ( (chan= (ciu) ellFirst (&piiu->chidlist)) ) {
@@ -1057,6 +1073,7 @@ void retryPendingClaims(IIU *piiu)
*/
void addToChanList(ciu chan, IIU *piiu)
{
CA_STATIC *ca_static = piiu->pcas;
if (piiu==piiuCast) {
/*
* add to the beginning of the list so that search requests for
@@ -1092,6 +1109,7 @@ void addToChanList(ciu chan, IIU *piiu)
void removeFromChanList (ciu chan)
{
IIU *piiu = (IIU *) chan->piiu;
CA_STATIC *ca_static = piiu->pcas;
if (piiu==piiuCast) {
if (ca_static->ca_pEndOfBCastList == chan) {
+7 -8
View File
@@ -1,17 +1,18 @@
#include <stdio.h>
#include "cadef.h"
#include "dbDefs.h"
#include "osiClock.h"
void event_handler(struct event_handler_args args);
int main(int argc, char **argv);
int evtime(char *pname);
static unsigned iteration_count;
static unsigned last_time;
static double rate;
#ifndef vxWorks
main(int argc, char **argv)
#ifndef iocCore
int main(int argc, char **argv)
{
char *pname;
@@ -22,11 +23,9 @@ main(int argc, char **argv)
else{
printf("usage: %s <channel name>", argv[0]);
}
return(0);
}
#endif
/*
* evtime()
@@ -45,7 +44,7 @@ int evtime(char *pname)
return OK;
}
rate = sysClkRateGet();
rate = clockGetRate();
status = ca_add_event(
DBR_FLOAT,
@@ -72,7 +71,7 @@ void event_handler(struct event_handler_args args)
double delay;
if(iteration_count%COUNT == 0){
current_time = tickGet();
current_time = clockGetCurrentTick();
if(last_time != 0){
interval = current_time - last_time;
delay = interval/(rate*COUNT);
+4
View File
@@ -50,7 +50,9 @@ static char *sccsId = "@(#) $Id$";
void flow_control_on(struct ioc_in_use *piiu)
{
int status;
CA_STATIC *ca_static;
ca_static = piiu->pcas;
LOCK;
/*
@@ -81,7 +83,9 @@ void flow_control_on(struct ioc_in_use *piiu)
void flow_control_off(struct ioc_in_use *piiu)
{
int status;
CA_STATIC *ca_static;
ca_static = piiu->pcas;
LOCK;
piiu->contiguous_msg_count = 0;
+91 -43
View File
@@ -1,5 +1,4 @@
/*
* $Id$
/* * $Id$
*
* L O S A L A M O S
* Los Alamos National Laboratory
@@ -16,18 +15,20 @@ static char *sccsId = "@# $Id$";
#include "net_convert.h"
#include "bsdSocketResource.h"
LOCAL void cac_set_iiu_non_blocking (struct ioc_in_use *piiu);
LOCAL unsigned long tcp_recv_msg(struct ioc_in_use *piiu);
LOCAL unsigned long tcp_recv_msg( struct ioc_in_use *piiu);
LOCAL unsigned long cac_connect_iiu(struct ioc_in_use *piiu);
LOCAL unsigned long cac_tcp_send_msg_piiu(struct ioc_in_use *piiu);
LOCAL unsigned long cac_udp_send_msg_piiu(struct ioc_in_use *piiu);
LOCAL unsigned long udp_recv_msg(struct ioc_in_use *piiu);
LOCAL unsigned long cac_tcp_send_msg_piiu( struct ioc_in_use *piiu);
LOCAL unsigned long cac_udp_send_msg_piiu( struct ioc_in_use *piiu);
LOCAL unsigned long udp_recv_msg( struct ioc_in_use *piiu);
LOCAL void ca_process_tcp(struct ioc_in_use *piiu);
LOCAL void ca_process_udp(struct ioc_in_use *piiu);
LOCAL void cacRingBufferInit(struct ca_buffer *pBuf,
unsigned long size);
LOCAL char *getToken(const char **ppString, char *pBuf,
unsigned bufSize);
LOCAL void cacRingBufferInit(struct ca_buffer *pBuf, unsigned long size);
LOCAL char *getToken(const char **ppString, char *pBuf, unsigned bufSize);
/*
@@ -37,6 +38,7 @@ LOCAL char *getToken(const char **ppString, char *pBuf,
*
*/
int alloc_ioc(
CA_STATIC *ca_static,
const struct sockaddr_in *pina,
struct ioc_in_use **ppiiu
)
@@ -48,9 +50,9 @@ struct ioc_in_use **ppiiu
* look for an existing connection
*/
LOCK;
pBHE = lookupBeaconInetAddr(pina);
pBHE = lookupBeaconInetAddr(ca_static,pina);
if(!pBHE){
pBHE = createBeaconHashEntry(pina, FALSE);
pBHE = createBeaconHashEntry(ca_static, pina, FALSE);
if(!pBHE){
UNLOCK;
return ECA_ALLOCMEM;
@@ -68,6 +70,7 @@ struct ioc_in_use **ppiiu
}
else{
status = create_net_chan(
ca_static,
ppiiu,
pina,
IPPROTO_TCP);
@@ -86,6 +89,7 @@ struct ioc_in_use **ppiiu
*
*/
int create_net_chan(
CA_STATIC *ca_static,
struct ioc_in_use **ppiiu,
const struct sockaddr_in *pina, /* only used by TCP connections */
int net_proto
@@ -375,7 +379,7 @@ int net_proto
sizeof(saddr));
if(status<0){
ca_printf("CAC: bind (err=%s)\n",SOCKERRSTR(SOCKERRNO));
genLocalExcep (ECA_INTERNAL,"bind failed");
genLocalExcep ( ECA_INTERNAL,"bind failed");
}
#endif
@@ -461,8 +465,10 @@ LOCAL void cac_set_iiu_non_blocking (struct ioc_in_use *piiu)
/*
* cac_connect_iiu()
*/
LOCAL unsigned long cac_connect_iiu (struct ioc_in_use *piiu)
LOCAL unsigned long cac_connect_iiu (
struct ioc_in_use *piiu)
{
CA_STATIC *ca_static = piiu->pcas;
caAddrNode *pNode;
int status;
@@ -573,7 +579,7 @@ LOCAL unsigned long cac_connect_iiu (struct ioc_in_use *piiu)
/*
* caSetupBCastAddrList()
*/
void caSetupBCastAddrList (ELLLIST *pList, SOCKET sock, unsigned short port)
void caSetupBCastAddrList ( ELLLIST *pList, SOCKET sock, unsigned short port)
{
char *pstr;
char yesno[32u];
@@ -621,7 +627,7 @@ void caSetupBCastAddrList (ELLLIST *pList, SOCKET sock, unsigned short port)
port);
if (ellCount(pList)==0) {
genLocalExcep (ECA_NOSEARCHADDR, NULL);
genLocalExcep ( ECA_NOSEARCHADDR, NULL);
}
}
@@ -634,7 +640,7 @@ void caSetupBCastAddrList (ELLLIST *pList, SOCKET sock, unsigned short port)
* 1) local communication only (no LAN traffic)
*
*/
void notify_ca_repeater()
void notify_ca_repeater(CA_STATIC *ca_static)
{
caHdr msg;
struct sockaddr_in saddr;
@@ -757,8 +763,9 @@ void notify_ca_repeater()
/*
* CAC_UDP_SEND_MSG_PIIU()
*/
LOCAL unsigned long cac_udp_send_msg_piiu(struct ioc_in_use *piiu)
LOCAL unsigned long cac_udp_send_msg_piiu( struct ioc_in_use *piiu)
{
CA_STATIC *ca_static = piiu->pcas;
caAddrNode *pNode;
unsigned long sendCnt;
unsigned long totalBytes = 0ul;
@@ -836,8 +843,9 @@ LOCAL unsigned long cac_udp_send_msg_piiu(struct ioc_in_use *piiu)
/*
* CAC_TCP_SEND_MSG_PIIU()
*/
LOCAL unsigned long cac_tcp_send_msg_piiu(struct ioc_in_use *piiu)
LOCAL unsigned long cac_tcp_send_msg_piiu( struct ioc_in_use *piiu)
{
CA_STATIC *ca_static = piiu->pcas;
unsigned long sendCnt;
unsigned long totalBytes = 0ul;
int status;
@@ -922,11 +930,11 @@ LOCAL unsigned long cac_tcp_send_msg_piiu(struct ioc_in_use *piiu)
UNLOCK;
return totalBytes;
}
/*
* ca_process_input_queue()
*/
void ca_process_input_queue()
void ca_process_input_queue(CA_STATIC *ca_static)
{
struct ioc_in_use *piiu;
@@ -947,18 +955,48 @@ void ca_process_input_queue()
continue;
}
(*piiu->procInput)(piiu);
(*piiu->procInput)( piiu);
}
UNLOCK;
}
/*
* cac_block_for_io_completion()
*/
void cac_block_for_io_completion(CA_STATIC *ca_static,struct timeval *pTV)
{
struct timeval itimeout;
double waitTime;
#ifndef iocCore
cac_mux_io(ca_static,pTV, TRUE);
#else
/*flush outputs */
/*recv occurs in another thread*/
itimeout.tv_usec = 0;
itimeout.tv_sec = 0;
cac_mux_io (ca_static, &itimeout, TRUE);
waitTime = pTV->tv_sec + pTV->tv_usec/1000.0;
if(waitTime>POLLDELAY) waitTime = POLLDELAY;
semBinaryTakeTimeout(ca_static->ca_io_done_sem,waitTime);
/*
*force a time update because we are not
*going to get one with a nill timeout in
* ca_mux_io()
*/
cac_gettimeval (&ca_static->currentTime);
#endif
}
/*
* TCP_RECV_MSG()
*
*/
LOCAL unsigned long tcp_recv_msg(struct ioc_in_use *piiu)
{
CA_STATIC *ca_static = piiu->pcas;
unsigned long writeSpace;
unsigned long totalBytes = 0;
int status;
@@ -1031,8 +1069,9 @@ LOCAL unsigned long tcp_recv_msg(struct ioc_in_use *piiu)
* ca_process_tcp()
*
*/
LOCAL void ca_process_tcp(struct ioc_in_use *piiu)
LOCAL void ca_process_tcp( struct ioc_in_use *piiu)
{
CA_STATIC *ca_static = piiu->pcas;
caAddrNode *pNode;
int status;
long bytesToProcess;
@@ -1098,8 +1137,9 @@ LOCAL void ca_process_tcp(struct ioc_in_use *piiu)
* UDP_RECV_MSG()
*
*/
LOCAL unsigned long udp_recv_msg(struct ioc_in_use *piiu)
LOCAL unsigned long udp_recv_msg( struct ioc_in_use *piiu)
{
CA_STATIC *ca_static = piiu->pcas;
int status;
int reply_size;
struct udpmsglog *pmsglog;
@@ -1184,8 +1224,9 @@ LOCAL unsigned long udp_recv_msg(struct ioc_in_use *piiu)
* CA_PROCESS_UDP()
*
*/
LOCAL void ca_process_udp(struct ioc_in_use *piiu)
LOCAL void ca_process_udp( struct ioc_in_use *piiu)
{
CA_STATIC *ca_static = piiu->pcas;
int status;
struct udpmsglog *pmsglog;
char *pBuf;
@@ -1265,6 +1306,7 @@ LOCAL void ca_process_udp(struct ioc_in_use *piiu)
*/
void cac_close_ioc (IIU *piiu)
{
CA_STATIC *ca_static;
caAddrNode *pNode;
ciu chix;
int status;
@@ -1274,6 +1316,7 @@ void cac_close_ioc (IIU *piiu)
* dont close twice
*/
assert (piiu->sock_chan!=INVALID_SOCKET);
ca_static = piiu->pcas;
LOCK;
@@ -1299,7 +1342,7 @@ void cac_close_ioc (IIU *piiu)
*/
pNode = (caAddrNode *) piiu->destAddr.node.next;
assert (pNode);
removeBeaconInetAddr (&pNode->destAddr.in);
removeBeaconInetAddr (ca_static, &pNode->destAddr.in);
chix = (ciu) ellFirst(&piiu->chidlist);
while (chix) {
@@ -1330,7 +1373,7 @@ void cac_close_ioc (IIU *piiu)
ellFree (&piiu->destAddr);
if (chanDisconnectCount) {
genLocalExcep (ECA_DISCONN, piiu->host_name_str);
genLocalExcep ( ECA_DISCONN, piiu->host_name_str);
}
free (piiu);
@@ -1343,6 +1386,8 @@ void cac_close_ioc (IIU *piiu)
*/
void cacDisconnectChannel(ciu chix)
{
IIU *piiu = (IIU *)chix->piiu;
CA_STATIC *ca_static = piiu->pcas;
LOCK;
/*
@@ -1351,7 +1396,7 @@ void cacDisconnectChannel(ciu chix)
* need to take care of freeing the remaing channel resources here
*/
if (chix->state == cs_closed) {
clearChannelResources (chix->cid);
clearChannelResources (ca_static, chix->cid);
UNLOCK;
return;
}
@@ -1373,13 +1418,13 @@ void cacDisconnectChannel(ciu chix)
/*
* clear outstanding get call backs
*/
caIOBlockListFree (&pend_read_list, chix,
caIOBlockListFree (ca_static, &pend_read_list, chix,
TRUE, ECA_DISCONN);
/*
* clear outstanding put call backs
*/
caIOBlockListFree (&pend_write_list, chix,
caIOBlockListFree (ca_static, &pend_write_list, chix,
TRUE, ECA_DISCONN);
/*
@@ -1397,7 +1442,7 @@ void cacDisconnectChannel(ciu chix)
*/
if (monix->usr_func == NULL) {
ellDelete (&chix->eventq, &monix->node);
caIOBlockFree (monix);
caIOBlockFree (ca_static, monix);
}
}
@@ -1422,7 +1467,7 @@ void cacDisconnectChannel(ciu chix)
*/
assert (piiuCast);
addToChanList(chix, piiuCast);
cacSetRetryInterval(0u);
cacSetRetryInterval(ca_static, 0u);
UNLOCK;
}
@@ -1450,7 +1495,7 @@ void cacDisconnectChannel(ciu chix)
*
* 072392 - problem solved by using SO_REUSEADDR
*/
int repeater_installed()
int repeater_installed(CA_STATIC *ca_static)
{
int status;
SOCKET sock;
@@ -1824,7 +1869,10 @@ unsigned short epicsShareAPI caFetchPortConfig
/*
* CAC_MUX_IO()
*/
void cac_mux_io(struct timeval *ptimeout, unsigned iocCloseAllowed)
void cac_mux_io(
CA_STATIC *ca_static,
struct timeval *ptimeout,
unsigned iocCloseAllowed)
{
int count;
struct timeval timeout;
@@ -1848,17 +1896,17 @@ void cac_mux_io(struct timeval *ptimeout, unsigned iocCloseAllowed)
* of what is requested here if piiu->pushPending
* is set
*/
count = cac_select_io(&timeout, CA_DO_RECVS);
count = cac_select_io(ca_static, &timeout, CA_DO_RECVS);
if (count<=0) {
break;
}
ca_process_input_queue();
ca_process_input_queue(ca_static);
}
/*
* manage search timers and detect disconnects
*/
manage_conn();
manage_conn(ca_static);
/*
* next check for pending writes's with the specified time out
@@ -1869,7 +1917,7 @@ void cac_mux_io(struct timeval *ptimeout, unsigned iocCloseAllowed)
countDown = 512u;
timeout = *ptimeout;
while (TRUE) {
count = cac_select_io(&timeout, CA_DO_RECVS|CA_DO_SENDS);
count = cac_select_io(ca_static, &timeout, CA_DO_RECVS|CA_DO_SENDS);
countDown--;
if (count<=0 || countDown==0u) {
/*
@@ -1885,9 +1933,9 @@ void cac_mux_io(struct timeval *ptimeout, unsigned iocCloseAllowed)
break;
}
else {
if (caSendMsgPending()) {
if (caSendMsgPending(ca_static)) {
countDown = 512u;
LD_CA_TIME (cac_fetch_poll_period(), &timeout);
LD_CA_TIME (cac_fetch_poll_period(ca_static), &timeout);
}
else {
ca_static->ca_flush_pending = FALSE;
@@ -1902,17 +1950,17 @@ void cac_mux_io(struct timeval *ptimeout, unsigned iocCloseAllowed)
else {
CLR_CA_TIME (&timeout);
}
ca_process_input_queue();
ca_process_input_queue(ca_static);
}
checkConnWatchdogs(iocCloseAllowed);
checkConnWatchdogs(ca_static, iocCloseAllowed);
}
/*
* caSendMsgPending()
*/
int caSendMsgPending()
int caSendMsgPending(CA_STATIC *ca_static)
{
int pending = FALSE;
unsigned long bytesPending;
+85 -71
View File
@@ -33,6 +33,9 @@
/*
* $Log$
* Revision 1.80 1999/11/08 17:14:43 jhill
* added prenthesis around arguments to VALID_MSG macro
*
* Revision 1.79 1999/11/08 17:01:43 jhill
* fixed problem with VALID_MSG(PIIU) macro
*
@@ -200,6 +203,7 @@ HDRVERSIONID(iocinfh, "$Id$")
* OS dependent includes
*/
#include "osiSock.h"
#include "osiClock.h"
#include "os_depen.h"
/*
@@ -351,7 +355,7 @@ typedef struct timeval ca_time;
* and FD_ZERO (&writeMask)
* 4 uS required to call cac_gettimeval()
*/
#ifdef vxWorks
#ifdef iocCore
#define SELECT_POLL_SEARCH (0.075) /* units sec - polls for search request (4 ticks)*/
#else
#define SELECT_POLL_SEARCH (0.025) /* units sec - polls for search request */
@@ -382,7 +386,7 @@ typedef struct timeval ca_time;
#define N_REPEATER_TRIES_PRIOR_TO_MSG 50
#define REPEATER_TRY_PERIOD (1.0)
#ifdef vxWorks
#ifdef iocCore
typedef struct caclient_put_notify{
ELLNODE node;
PUTNOTIFY dbPutNotify;
@@ -392,7 +396,7 @@ typedef struct caclient_put_notify{
struct CA_STATIC *pcas;
int busy;
}CACLIENTPUTNOTIFY;
#endif /*vxWorks*/
#endif /*iocCore*/
/*
* this determines the number of messages received
@@ -434,7 +438,8 @@ typedef struct caclient_put_notify{
#define nextSlowBucketId (ca_static->ca_nextSlowBucketId)
#define nextFastBucketId (ca_static->ca_nextFastBucketId)
#if defined(vxWorks)
#if defined(iocCore)
#define POLLDELAY .05
# define io_done_sem (ca_static->ca_io_done_sem)
# define evuser (ca_static->ca_evuser)
# define client_lock (ca_static->ca_client_lock)
@@ -444,15 +449,6 @@ typedef struct caclient_put_notify{
# define lock_count (ca_static->ca_lock_count)
#endif
/*
* one for each task that does a ca import
*/
typedef struct task_var_list{
ELLNODE node;
int tid;
}TVIU;
/*
* Ring buffering for both sends and recvs
*/
@@ -512,7 +508,7 @@ typedef struct ioc_in_use{
void *pCurData;
unsigned long (*sendBytes)(struct ioc_in_use *);
unsigned long (*recvBytes)(struct ioc_in_use *);
void (*procInput)(struct ioc_in_use *);
void (*procInput)(struct ioc_in_use *);
SOCKET sock_chan;
int sock_proto;
unsigned minor_version_number;
@@ -558,7 +554,7 @@ typedef struct {
fd_set writeMask;
}caFDInfo;
struct CA_STATIC {
typedef struct CA_STATIC {
ELLLIST ca_iiuList;
ELLLIST ca_ioeventlist;
ELLLIST ca_pend_read_list;
@@ -612,23 +608,23 @@ struct CA_STATIC {
unsigned ca_manage_conn_active:1;
unsigned ca_repeater_contacted:1;
unsigned ca_flush_pending:1;
#if defined(vxWorks)
SEM_ID ca_io_done_sem;
SEM_ID ca_blockSem;
SEM_ID ca_client_lock;
SEM_ID ca_putNotifyLock;
#if defined(iocCore)
semId ca_io_done_sem;
semId ca_blockSem;
semId ca_client_lock;
semId ca_putNotifyLock;
ELLLIST ca_local_chidlist;
ELLLIST ca_lcl_buff_list;
ELLLIST ca_putNotifyQue;
ELLLIST ca_taskVarList;
void *ca_evuser;
void *ca_dbMonixFreeList;
int ca_lock_tid;
threadId ca_lock_tid;
unsigned ca_lock_count;
int ca_tid;
int recv_tid;
threadId ca_tid;
threadId recv_tid;
#endif
};
}CA_STATIC;
@@ -658,9 +654,9 @@ typedef struct{
/*
* Asynch Notification
*/
# ifdef vxWorks
SEM_ID sem;
# endif /*vxWorks*/
# ifdef iocCore
semId sem;
# endif /*iocCore*/
}CASG;
@@ -669,40 +665,51 @@ typedef struct{
* There should only be one - add others to ca_static above -joh
*/
GLBLTYPE
struct CA_STATIC *ca_static;
#include "caOsDependent.h"
CA_OSD_CA_STATIC
/*
* CA internal functions
*
*/
void cac_send_msg(void);
void cac_mux_io(struct timeval *ptimeout, unsigned iocCloseAllowed);
int repeater_installed(void);
int search_msg(ciu chix, int reply_type);
int ca_request_event(evid monix);
void cac_mux_io(
CA_STATIC *ca_static,
struct timeval *ptimeout,
unsigned iocCloseAllowed);
int repeater_installed(CA_STATIC *ca_static);
int search_msg( ciu chix, int reply_type);
int ca_request_event( evid monix);
int ca_busy_message(struct ioc_in_use *piiu);
int ca_ready_message(struct ioc_in_use *piiu);
void noop_msg(struct ioc_in_use *piiu);
int echo_request(struct ioc_in_use *piiu, ca_time *pCurrentTime);
int echo_request( struct ioc_in_use *piiu, ca_time *pCurrentTime);
int issue_claim_channel(chid pchan);
void issue_identify_client(struct ioc_in_use *piiu);
void issue_client_host_name(struct ioc_in_use *piiu);
int ca_defunct(void);
epicsShareFunc int epicsShareAPI ca_printf (const char *pformat, ...);
epicsShareFunc int epicsShareAPI ca_vPrintf (const char *pformat, va_list args);
void manage_conn(void);
void checkConnWatchdogs(unsigned closeAllowed);
void mark_server_available(const struct sockaddr_in *pnet_addr);
void manage_conn(CA_STATIC *ca_static);
void checkConnWatchdogs(CA_STATIC *ca_static, unsigned closeAllowed);
void mark_server_available(
CA_STATIC *ca_static,
const struct sockaddr_in *pnet_addr);
void flow_control_on(struct ioc_in_use *piiu);
void flow_control_off(struct ioc_in_use *piiu);
int broadcast_addr(struct in_addr *pcastaddr);
epicsShareFunc void epicsShareAPI ca_repeater(void);
void cac_recv_task(int tid);
void ca_sg_init(void);
void ca_sg_shutdown(struct CA_STATIC *ca_temp);
int cac_select_io(struct timeval *ptimeout, int flags);
#ifdef iocCore
typedef struct cac_recv_taskArgs {
CA_STATIC *pcas;
threadId tcas;
}cac_recv_taskArgs;
void cac_recv_task(cac_recv_taskArgs *args);
#endif
void ca_sg_init(CA_STATIC *ca_static);
void ca_sg_shutdown(CA_STATIC *ca_static);
int cac_select_io(CA_STATIC *ca_static, struct timeval *ptimeout, int flags);
int post_msg(
struct ioc_in_use *piiu,
const struct sockaddr_in *pnet_addr,
@@ -710,6 +717,7 @@ int post_msg(
unsigned long blockSize
);
int alloc_ioc(
CA_STATIC *ca_static,
const struct sockaddr_in *pina,
struct ioc_in_use **ppiiu
);
@@ -732,6 +740,7 @@ unsigned long cacRingBufferReadSize(
int contiguous);
void caIOBlockListFree(
CA_STATIC *ca_static,
ELLLIST *pList,
chid chan,
int cbRequired,
@@ -742,53 +751,58 @@ char *localUserName(void);
char *localHostName(void);
int create_net_chan(
CA_STATIC *ca_static,
struct ioc_in_use **ppiiu,
const struct sockaddr_in *pina, /* only used by TCP connections */
int net_proto
);
void caSetupBCastAddrList (ELLLIST *pList, SOCKET sock, unsigned short port);
void caSetupBCastAddrList ( ELLLIST *pList, SOCKET sock, unsigned short port);
int ca_os_independent_init (void);
int ca_os_independent_init (CA_STATIC *ca_static);
void freeBeaconHash(struct CA_STATIC *ca_temp);
void removeBeaconInetAddr(const struct sockaddr_in *pnet_addr);
bhe *lookupBeaconInetAddr(const struct sockaddr_in *pnet_addr);
bhe *createBeaconHashEntry(const struct sockaddr_in *pnet_addr, unsigned sawBeacon);
void notify_ca_repeater(void);
void cac_clean_iiu_list(void);
void removeBeaconInetAddr(
CA_STATIC *ca_static,
const struct sockaddr_in *pnet_addr);
void ca_process_input_queue(void);
void cac_block_for_io_completion(struct timeval *pTV);
void cac_block_for_sg_completion(CASG *pcasg, struct timeval *pTV);
void os_specific_sg_create(CASG *pcasg);
void os_specific_sg_delete(CASG *pcasg);
void os_specific_sg_io_complete(CASG *pcasg);
void ca_process_exit(void);
bhe *lookupBeaconInetAddr(
CA_STATIC *ca_static,
const struct sockaddr_in *pnet_addr);
bhe *createBeaconHashEntry(
CA_STATIC *ca_static,
const struct sockaddr_in *pnet_addr,
unsigned sawBeacon);
void notify_ca_repeater(CA_STATIC *ca_static);
void ca_process_input_queue(CA_STATIC *ca_static);
void cac_block_for_io_completion(CA_STATIC *ca_static,struct timeval *pTV);
void ca_process_exit(CA_STATIC *ca_static);
void ca_spawn_repeater(void);
void cac_gettimeval(struct timeval *pt);
/* returns A - B in floating secs */
ca_real cac_time_diff(ca_time *pTVA, ca_time *pTVB);
/* returns A + B in integer secs & integer usec */
ca_time cac_time_sum(ca_time *pTVA, ca_time *pTVB);
void caIOBlockFree(miu pIOBlock);
void clearChannelResources(unsigned id);
void caSetDefaultPrintfHandler (void);
void cacDisconnectChannel(ciu chix);
int caSendMsgPending(void);
void genLocalExcepWFL(long stat, char *ctx,
char *pFile, unsigned line);
void caIOBlockFree(CA_STATIC *ca_static,miu pIOBlock);
void clearChannelResources(CA_STATIC *ca_static,unsigned id);
void caSetDefaultPrintfHandler (CA_STATIC *ca_static);
void cacDisconnectChannel( ciu chix);
int caSendMsgPending(CA_STATIC *ca_static);
void genLocalExcepWFL(long stat, const char *ctx,
const char *pFile, unsigned line);
#define genLocalExcep(STAT, PCTX) \
genLocalExcepWFL (STAT, PCTX, __FILE__, __LINE__)
void cac_reconnect_channel(caResId id, short type, unsigned short count);
void retryPendingClaims(IIU *piiu);
void cacSetRetryInterval(unsigned retryNo);
void cac_reconnect_channel(CA_STATIC *ca_static, caResId id, short type, unsigned short count);
void retryPendingClaims( IIU *piiu);
void cacSetRetryInterval(CA_STATIC *ca_static, unsigned retryNo);
void addToChanList(ciu chan, IIU *piiu);
void removeFromChanList(ciu chan);
void cac_create_udp_fd(void);
double cac_fetch_poll_period(void);
int caSockAddrFromHost(const char *pName, struct sockaddr *paddr);
void cac_close_ioc (IIU *piiu);
void cac_create_udp_fd(CA_STATIC *ca_static);
double cac_fetch_poll_period(CA_STATIC *ca_static);
void cac_close_ioc ( IIU *piiu);
/*
* !!KLUDGE!!
+13 -44
View File
@@ -39,24 +39,9 @@ static char *os_depenhSccsId = "$Id$";
# define CA_OS_CONFIGURED
#endif
#ifdef vxWorks
# include <vxWorks.h>
# include <ioLib.h>
# include <tickLib.h>
# include <taskHookLib.h>
# include <selectLib.h>
# include <errnoLib.h>
# include <sysLib.h>
# include <taskVarLib.h>
# include <hostLib.h>
# include <logLib.h>
# include <usrLib.h>
# include <dbgLib.h>
# include <inetLib.h>
# include <taskLib.h>
# include <vxLib.h>
# include "task_params.h"
#ifdef iocCore
# include "osiSem.h"
# include "osiThread.h"
# include "taskwd.h"
# define CA_OS_CONFIGURED
@@ -71,39 +56,23 @@ static char *os_depenhSccsId = "$Id$";
#endif /*_WIN32*/
#ifndef CA_OS_CONFIGURED
#error Please define one of vxWorks, UNIX, VMS, or _WIN32
#error Please define one of iocCore, UNIX, VMS, or _WIN32
#endif
#if defined(vxWorks)
# define POST_IO_EV semGive(io_done_sem)
#if defined(iocCore)
# define POST_IO_EV semBinaryGive(io_done_sem)
# define VXTASKIDNONE 0
# define LOCK {assert(semTake(client_lock, WAIT_FOREVER)==OK); lock_count++; lock_tid=(int)taskIdCurrent;}
# define UNLOCK {if(--lock_count==0u) lock_tid=VXTASKIDNONE; assert(semGive(client_lock)==OK);}
# define EVENTLOCKTEST (lock_tid==(int)taskIdCurrent)
# define VXTHISTASKID taskIdSelf()
# define abort() taskSuspend(VXTHISTASKID)
#endif
#if defined(UNIX)
# define LOCK semMutexTakeAssert(client_lock);
# define UNLOCK semMutexGive(client_lock);
# define EVENTLOCKTEST (lock_tid==threadGetIdSelf())
# define VXTHISTASKID threadGetIdSelf();
# define abort() threadSuspend(threadGetIdSelf())
#else
# define POST_IO_EV
# define LOCK
# define UNLOCK
# define EVENTLOCKTEST (post_msg_active)
#endif
#if defined(VMS)
# define POST_IO_EV
# define LOCK
# define UNLOCK
# define EVENTLOCKTEST (post_msg_active)
#endif
#ifdef _WIN32
# define POST_IO_EV
# define LOCK
# define UNLOCK
# define EVENTLOCKTEST (post_msg_active)
#endif /*_WIN32*/
#endif /*defined(iocCore) */
#endif /* INCos_depenh */
+81 -50
View File
@@ -20,14 +20,14 @@
extern CACVRTFUNC *cac_dbr_cvrt[];
#endif /*CONVERSION_REQUIRED*/
typedef void (*pProtoStub) (IIU *piiu,
const struct sockaddr_in *pnet_addr);
typedef void (*pProtoStub) ( IIU *piiu, const struct sockaddr_in *pnet_addr);
/*
* noop_action ()
*/
LOCAL void noop_action (IIU *piiu,
const struct sockaddr_in *pnet_addr)
LOCAL void noop_action (
IIU *piiu,
const struct sockaddr_in *pnet_addr)
{
return;
}
@@ -35,8 +35,9 @@ LOCAL void noop_action (IIU *piiu,
/*
* echo_resp_action ()
*/
LOCAL void echo_resp_action (IIU *piiu,
const struct sockaddr_in *pnet_addr)
LOCAL void echo_resp_action (
IIU *piiu,
const struct sockaddr_in *pnet_addr)
{
piiu->echoPending = FALSE;
piiu->beaconAnomaly = FALSE;
@@ -46,9 +47,11 @@ LOCAL void echo_resp_action (IIU *piiu,
/*
* write_notify_resp_action ()
*/
LOCAL void write_notify_resp_action (IIU *piiu,
const struct sockaddr_in *pnet_addr)
LOCAL void write_notify_resp_action (
IIU *piiu,
const struct sockaddr_in *pnet_addr)
{
CA_STATIC *ca_static = piiu->pcas;
struct event_handler_args args;
miu monix;
@@ -85,7 +88,7 @@ LOCAL void write_notify_resp_action (IIU *piiu,
(*monix->usr_func) (args);
}
ellDelete (&pend_write_list, &monix->node);
caIOBlockFree (monix);
caIOBlockFree (ca_static, monix);
UNLOCK;
return;
@@ -94,9 +97,11 @@ LOCAL void write_notify_resp_action (IIU *piiu,
/*
* read_notify_resp_action ()
*/
LOCAL void read_notify_resp_action (IIU *piiu,
const struct sockaddr_in *pnet_addr)
LOCAL void read_notify_resp_action (
IIU *piiu,
const struct sockaddr_in *pnet_addr)
{
CA_STATIC *ca_static = piiu->pcas;
miu monix;
struct event_handler_args args;
@@ -159,7 +164,7 @@ LOCAL void read_notify_resp_action (IIU *piiu,
(*monix->usr_func) (args);
}
ellDelete (&pend_read_list, &monix->node);
caIOBlockFree (monix);
caIOBlockFree (ca_static, monix);
UNLOCK;
return;
@@ -168,9 +173,11 @@ LOCAL void read_notify_resp_action (IIU *piiu,
/*
* event_resp_action ()
*/
LOCAL void event_resp_action (IIU *piiu,
const struct sockaddr_in *pnet_addr)
LOCAL void event_resp_action (
IIU *piiu,
const struct sockaddr_in *pnet_addr)
{
CA_STATIC *ca_static = piiu->pcas;
struct event_handler_args args;
miu monix;
int v41;
@@ -193,7 +200,7 @@ LOCAL void event_resp_action (IIU *piiu,
*/
if (!piiu->curMsg.m_postsize) {
ellDelete(&monix->chan->eventq, &monix->node);
caIOBlockFree(monix);
caIOBlockFree(ca_static, monix);
UNLOCK;
return;
}
@@ -257,9 +264,11 @@ LOCAL void event_resp_action (IIU *piiu,
/*
* read_resp_action ()
*/
LOCAL void read_resp_action (IIU *piiu,
const struct sockaddr_in *pnet_addr)
LOCAL void read_resp_action (
IIU *piiu,
const struct sockaddr_in *pnet_addr)
{
CA_STATIC *ca_static = piiu->pcas;
miu pIOBlock;
/*
@@ -313,7 +322,7 @@ LOCAL void read_resp_action (IIU *piiu,
}
}
ellDelete (&pend_read_list, &pIOBlock->node);
caIOBlockFree (pIOBlock);
caIOBlockFree (ca_static, pIOBlock);
UNLOCK;
return;
@@ -322,9 +331,11 @@ LOCAL void read_resp_action (IIU *piiu,
/*
* search_resp_action ()
*/
LOCAL void search_resp_action (IIU *piiu,
const struct sockaddr_in *pnet_addr)
LOCAL void search_resp_action (
IIU *piiu,
const struct sockaddr_in *pnet_addr)
{
CA_STATIC *ca_static = piiu->pcas;
struct sockaddr_in ina;
char rej[64];
ciu chan;
@@ -425,7 +436,7 @@ LOCAL void search_resp_action (IIU *piiu,
return;
}
status = alloc_ioc (&ina, &allocpiiu);
status = alloc_ioc (ca_static, &ina, &allocpiiu);
switch (status) {
case ECA_NORMAL:
@@ -461,7 +472,7 @@ LOCAL void search_resp_action (IIU *piiu,
*/
if (ellCount(&allocpiiu->chidlist)==0) {
issue_identify_client(allocpiiu);
issue_client_host_name(allocpiiu);
issue_client_host_name( allocpiiu);
}
/*
@@ -490,7 +501,7 @@ LOCAL void search_resp_action (IIU *piiu,
*
* claim pending flag is set here
*/
addToChanList(chan, allocpiiu);
addToChanList( chan, allocpiiu);
/*
* Assume that we have access once connected briefly
@@ -537,8 +548,9 @@ LOCAL void search_resp_action (IIU *piiu,
/*
* read_sync_resp_action ()
*/
LOCAL void read_sync_resp_action (IIU *piiu,
const struct sockaddr_in *pnet_addr)
LOCAL void read_sync_resp_action (
IIU *piiu,
const struct sockaddr_in *pnet_addr)
{
piiu->read_seq++;
return;
@@ -547,9 +559,11 @@ LOCAL void read_sync_resp_action (IIU *piiu,
/*
* beacon_action ()
*/
LOCAL void beacon_action (IIU *piiu,
const struct sockaddr_in *pnet_addr)
LOCAL void beacon_action (
IIU *piiu,
const struct sockaddr_in *pnet_addr)
{
CA_STATIC *ca_static = piiu->pcas;
struct sockaddr_in ina;
LOCK;
@@ -585,7 +599,7 @@ LOCAL void beacon_action (IIU *piiu,
*/
ina.sin_port = htons (ca_static->ca_server_port);
}
mark_server_available(&ina);
mark_server_available(ca_static, &ina);
UNLOCK;
@@ -595,9 +609,11 @@ LOCAL void beacon_action (IIU *piiu,
/*
* repeater_ack_action ()
*/
LOCAL void repeater_ack_action (IIU *piiu,
const struct sockaddr_in *pnet_addr)
LOCAL void repeater_ack_action (
IIU *piiu,
const struct sockaddr_in *pnet_addr)
{
CA_STATIC *ca_static = piiu->pcas;
ca_static->ca_repeater_contacted = TRUE;
# ifdef DEBUG
ca_printf ("CAC: repeater confirmation recv\n");
@@ -608,8 +624,9 @@ LOCAL void repeater_ack_action (IIU *piiu,
/*
* not_here_resp_action ()
*/
LOCAL void not_here_resp_action (IIU *piiu,
const struct sockaddr_in *pnet_addr)
LOCAL void not_here_resp_action (
IIU *piiu,
const struct sockaddr_in *pnet_addr)
{
return;
}
@@ -617,19 +634,23 @@ LOCAL void not_here_resp_action (IIU *piiu,
/*
* clear_channel_resp_action ()
*/
LOCAL void clear_channel_resp_action (IIU *piiu,
const struct sockaddr_in *pnet_addr)
LOCAL void clear_channel_resp_action (
IIU *piiu,
const struct sockaddr_in *pnet_addr)
{
clearChannelResources (piiu->curMsg.m_available);
CA_STATIC *ca_static = piiu->pcas;
clearChannelResources (ca_static, piiu->curMsg.m_available);
return;
}
/*
* exception_resp_action ()
*/
LOCAL void exception_resp_action (IIU *piiu,
const struct sockaddr_in *pnet_addr)
LOCAL void exception_resp_action (
IIU *piiu,
const struct sockaddr_in *pnet_addr)
{
CA_STATIC *ca_static = piiu->pcas;
ELLLIST *pList = NULL;
miu monix;
char nameBuf[64];
@@ -724,7 +745,7 @@ LOCAL void exception_resp_action (IIU *piiu,
if (pList) {
ellDelete(pList, &monix->node);
}
caIOBlockFree(monix);
caIOBlockFree(ca_static, monix);
}
args.chid = bucketLookupItemUnsignedId
@@ -746,9 +767,11 @@ LOCAL void exception_resp_action (IIU *piiu,
/*
* access_rights_resp_action ()
*/
LOCAL void access_rights_resp_action (IIU *piiu,
const struct sockaddr_in *pnet_addr)
LOCAL void access_rights_resp_action (
IIU *piiu,
const struct sockaddr_in *pnet_addr)
{
CA_STATIC *ca_static = piiu->pcas;
int ar;
ciu chan;
@@ -782,10 +805,12 @@ LOCAL void access_rights_resp_action (IIU *piiu,
/*
* claim_ciu_resp_action ()
*/
LOCAL void claim_ciu_resp_action (IIU *piiu,
const struct sockaddr_in *pnet_addr)
LOCAL void claim_ciu_resp_action (
IIU *piiu,
const struct sockaddr_in *pnet_addr)
{
cac_reconnect_channel (piiu->curMsg.m_cid,
CA_STATIC *ca_static = piiu->pcas;
cac_reconnect_channel (ca_static, piiu->curMsg.m_cid,
piiu->curMsg.m_dataType, piiu->curMsg.m_count);
return;
}
@@ -793,9 +818,11 @@ LOCAL void claim_ciu_resp_action (IIU *piiu,
/*
* verifyAndDisconnectChan ()
*/
LOCAL void verifyAndDisconnectChan (IIU *piiu,
const struct sockaddr_in *pnet_addr)
LOCAL void verifyAndDisconnectChan (
IIU *piiu,
const struct sockaddr_in *pnet_addr)
{
CA_STATIC *ca_static = piiu->pcas;
ciu chan;
LOCK;
@@ -825,8 +852,9 @@ LOCAL void verifyAndDisconnectChan (IIU *piiu,
/*
* bad_tcp_resp_action ()
*/
LOCAL void bad_tcp_resp_action (IIU *piiu,
const struct sockaddr_in *pnet_addr)
LOCAL void bad_tcp_resp_action (
IIU *piiu,
const struct sockaddr_in *pnet_addr)
{
ca_printf ("CAC: Bad response code in TCP message = %u\n",
piiu->curMsg.m_cmmd);
@@ -835,8 +863,9 @@ LOCAL void bad_tcp_resp_action (IIU *piiu,
/*
* bad_udp_resp_action ()
*/
LOCAL void bad_udp_resp_action (IIU *piiu,
const struct sockaddr_in *pnet_addr)
LOCAL void bad_udp_resp_action (
IIU *piiu,
const struct sockaddr_in *pnet_addr)
{
ca_printf ("CAC: Bad response code in UDP message = %u\n",
piiu->curMsg.m_cmmd);
@@ -845,7 +874,8 @@ LOCAL void bad_udp_resp_action (IIU *piiu,
/*
* cac_reconnect_channel()
*/
void cac_reconnect_channel(caResId cid, short type, unsigned short count)
void cac_reconnect_channel(CA_STATIC *ca_static, caResId cid,
short type, unsigned short count)
{
IIU *piiu;
evid pevent;
@@ -1039,6 +1069,7 @@ unsigned long blockSize
{
unsigned long size;
pProtoStub pStub;
CA_STATIC *ca_static = piiu->pcas;
while (blockSize) {
+51 -16
View File
@@ -29,6 +29,10 @@
* Modification Log:
* -----------------
* $Log$
* Revision 1.27 1999/07/16 17:08:05 jhill
* fixed bug occurring when connection dropped while waiting to send, and
* initialize new search gongestion thresh parm
*
* Revision 1.26.6.1 1999/07/15 21:02:25 jhill
* fixed bug where client disconnects while waiting to send TCP
*
@@ -78,7 +82,7 @@ LOCAL void io_complete(struct event_handler_args args);
/*
* ca_sg_init()
*/
void ca_sg_init(void)
void ca_sg_init(CA_STATIC *ca_static)
{
/*
* init all sync group lists
@@ -93,7 +97,7 @@ void ca_sg_init(void)
/*
* ca_sg_shutdown()
*/
void ca_sg_shutdown(struct CA_STATIC *ca_temp)
void ca_sg_shutdown(CA_STATIC *ca_static)
{
CASG *pcasg;
CASG *pnextcasg;
@@ -103,25 +107,25 @@ void ca_sg_shutdown(struct CA_STATIC *ca_temp)
* free all sync group lists
*/
LOCK;
pcasg = (CASG *) ellFirst (&ca_temp->activeCASG);
pcasg = (CASG *) ellFirst (&ca_static->activeCASG);
while (pcasg) {
pnextcasg = (CASG *) ellNext (&pcasg->node);
status = ca_sg_delete (pcasg->id);
assert (status==ECA_NORMAL);
pcasg = pnextcasg;
}
assert (ellCount(&ca_temp->activeCASG)==0);
assert (ellCount(&ca_static->activeCASG)==0);
/*
* per sync group
*/
freeListCleanup(ca_temp->ca_sgFreeListPVT);
freeListCleanup(ca_static->ca_sgFreeListPVT);
/*
* per sync group op
*/
ellFree (&ca_temp->activeCASGOP);
freeListCleanup(ca_temp->ca_sgopFreeListPVT);
ellFree (&ca_static->activeCASGOP);
freeListCleanup(ca_static->ca_sgopFreeListPVT);
UNLOCK;
@@ -136,6 +140,7 @@ int epicsShareAPI ca_sg_create(CA_SYNC_GID *pgid)
{
int status;
CASG *pcasg;
CA_OSD_GET_CA_STATIC
/*
* Force the CA client id bucket to
@@ -166,7 +171,10 @@ int epicsShareAPI ca_sg_create(CA_SYNC_GID *pgid)
pcasg->opPendCount = 0;
pcasg->seqNo = 0;
os_specific_sg_create(pcasg);
#ifdef iocCore
pcasg->sem = semBinaryCreate(semEmpty);
assert(pcasg->sem );
#endif
do {
pcasg->id = CLIENT_SLOW_ID_ALLOC;
@@ -208,6 +216,7 @@ int epicsShareAPI ca_sg_delete(const CA_SYNC_GID gid)
{
int status;
CASG *pcasg;
CA_OSD_GET_CA_STATIC
/*
* Force the CA client id bucket to
@@ -227,8 +236,9 @@ int epicsShareAPI ca_sg_delete(const CA_SYNC_GID gid)
status = bucketRemoveItemUnsignedId(pSlowBucket, &gid);
assert (status == S_bucket_success);
os_specific_sg_delete(pcasg);
#ifdef iocCore
semBinaryDestroy(pcasg->sem);
#endif
pcasg->magic = 0;
ellDelete(&ca_static->activeCASG, &pcasg->node);
UNLOCK;
@@ -248,6 +258,7 @@ int epicsShareAPI ca_sg_block(const CA_SYNC_GID gid, ca_real timeout)
ca_real delay;
int status;
CASG *pcasg;
CA_OSD_GET_CA_STATIC
/*
* Force the CA client id bucket to
@@ -310,7 +321,7 @@ int epicsShareAPI ca_sg_block(const CA_SYNC_GID gid, ca_real timeout)
*/
tmo.tv_sec = 0L;
tmo.tv_usec = 0L;
cac_mux_io (&tmo, TRUE);
cac_mux_io (ca_static, &tmo, TRUE);
status = ECA_TIMEOUT;
break;
}
@@ -318,15 +329,32 @@ int epicsShareAPI ca_sg_block(const CA_SYNC_GID gid, ca_real timeout)
/*
* Allow for CA background labor
*/
remaining = min(cac_fetch_poll_period(), remaining);
remaining = min(cac_fetch_poll_period(ca_static), remaining);
/*
* wait for asynch notification
*/
tmo.tv_sec = (long) remaining;
tmo.tv_usec = (long) ((remaining-tmo.tv_sec)*USEC_PER_SEC);
cac_block_for_sg_completion (pcasg, &tmo);
#ifndef iocCore
cac_mux_io(ca_static,&tmo, TRUE);
#else
{
struct timeval itimeout;
double waitTime;
itimeout.tv_usec = 0;
itimeout.tv_sec = 0;
cac_mux_io(ca_static,&itimeout, TRUE);
waitTime = tmo.tv_sec + tmo.tv_usec/1000.0;
if(waitTime>POLLDELAY) waitTime = POLLDELAY;
semBinaryTakeTimeout(ca_static->ca_io_done_sem,waitTime);
/*
*force a time update because we are not
*going to get one with a nill timeout in ca_mux_io()
*/
cac_gettimeval (&ca_static->currentTime);
}
#endif
delay = cac_time_diff (&ca_static->currentTime, &beg_time);
}
pcasg->opPendCount = 0;
@@ -341,6 +369,7 @@ int epicsShareAPI ca_sg_block(const CA_SYNC_GID gid, ca_real timeout)
int epicsShareAPI ca_sg_reset(const CA_SYNC_GID gid)
{
CASG *pcasg;
CA_OSD_GET_CA_STATIC
LOCK;
pcasg = bucketLookupItemUnsignedId(pSlowBucket, &gid);
@@ -364,6 +393,7 @@ int epicsShareAPI ca_sg_stat(const CA_SYNC_GID gid)
{
CASG *pcasg;
CASGOP *pcasgop;
CA_OSD_GET_CA_STATIC
LOCK;
pcasg = bucketLookupItemUnsignedId(pSlowBucket, &gid);
@@ -399,6 +429,7 @@ int epicsShareAPI ca_sg_stat(const CA_SYNC_GID gid)
int epicsShareAPI ca_sg_test(const CA_SYNC_GID gid)
{
CASG *pcasg;
CA_OSD_GET_CA_STATIC
LOCK;
pcasg = bucketLookupItemUnsignedId(pSlowBucket, &gid);
@@ -430,6 +461,7 @@ const void *pvalue)
int status;
CASGOP *pcasgop;
CASG *pcasg;
CA_OSD_GET_CA_STATIC
/*
* first look on a free list. If not there
@@ -493,6 +525,7 @@ void *pvalue)
int status;
CASGOP *pcasgop;
CASG *pcasg;
CA_OSD_GET_CA_STATIC
/*
* first look on a free list. If not there
@@ -548,6 +581,7 @@ LOCAL void io_complete(struct event_handler_args args)
unsigned long size;
CASGOP *pcasgop;
CASG *pcasg;
CA_OSD_GET_CA_STATIC
pcasgop = args.usr;
assert(pcasgop->magic == CASG_MAGIC);
@@ -602,9 +636,10 @@ LOCAL void io_complete(struct event_handler_args args)
*
* occurs through select on UNIX
*/
#ifdef iocCore
if(pcasg->opPendCount == 0){
os_specific_sg_io_complete(pcasg);
semBinaryGive(pcasg->sem);
}
#endif
return;
}