From a88293bbbbb03b8664d415597730a740eaede757 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Wed, 16 Nov 1994 03:41:25 +0000 Subject: [PATCH] dont alloc channel in response to search request changes --- src/ca/Makefile.Unix | 6 +++--- src/ca/access.c | 44 +++++++++++++++++++++++++++++++----------- src/ca/acctst.c | 22 ++++++++++----------- src/ca/bsd_depen.c | 2 +- src/ca/ca_printf.c | 2 +- src/ca/conn.c | 23 +++++++++++++++++++++- src/ca/convert.c | 2 +- src/ca/flow_control.c | 2 +- src/ca/if_depen.c | 4 ++-- src/ca/iocinf.c | 31 +++++++++++++++++------------ src/ca/iocinf.h | 8 +++++--- src/ca/iocmsg.h | 14 +++++++++++--- src/ca/net_convert.h | 2 +- src/ca/netdb_depen.c | 4 ++-- src/ca/os_depen.h | 2 +- src/ca/posix_depen.c | 6 +----- src/ca/repeater.c | 2 +- src/ca/service.c | 12 +++++++++--- src/ca/syncgrp.c | 14 +++++++++++++- src/ca/test_event.c | 2 +- src/ca/vms_depen.c | 15 ++++++-------- src/ca/vxWorks_depen.c | 15 +++++++------- src/ca/windows_depen.c | 15 ++++++-------- 23 files changed, 158 insertions(+), 91 deletions(-) diff --git a/src/ca/Makefile.Unix b/src/ca/Makefile.Unix index ed5015d6e..e60913b7b 100644 --- a/src/ca/Makefile.Unix +++ b/src/ca/Makefile.Unix @@ -2,7 +2,7 @@ EPICS = ../../../.. include Target.include include $(EPICS)/config/CONFIG_BASE -USR_CFLAGS = -g -DACCESS_SECURITY -D_NO_PROTO +USR_CFLAGS = -DACCESS_SECURITY -D_NO_PROTO USR_LDLIBS = -lca -lCom USR_LDFLAGS = -L. @@ -14,14 +14,14 @@ SRCS.c = \ ../iocinf.c ../access.c ../test_event.c ../service.c \ ../flow_control.c ../repeater.c ../conn.c ../acctst.c \ ../syncgrp.c ../if_depen.c ../netdb_depen.c ../bsd_depen.c \ - ../gsd_sync_subr.c ../posix_depen.c ../caRepeater.c ../acctst.c + ../posix_depen.c ../caRepeater.c ../acctst.c OBJS = caRepeater.o LIBOBJS = \ iocinf.o access.o test_event.o service.o flow_control.o repeater.o \ conn.o syncgrp.o if_depen.o netdb_depen.o \ - gsd_sync_subr.o bsd_depen.o posix_depen.o + bsd_depen.o posix_depen.o LIBNAME = libca.a diff --git a/src/ca/access.c b/src/ca/access.c index 9a30a094d..3146e7deb 100644 --- a/src/ca/access.c +++ b/src/ca/access.c @@ -114,7 +114,7 @@ /************************************************************************/ /*_end */ -static char *sccsId = "%W% %G%"; +static char *sccsId = "@(#) $Id$"; /* * allocate error message string array @@ -1078,10 +1078,10 @@ int reply_type return status; } - mptr->m_cmmd = htons(cmd); + mptr->m_cmmd = htons (cmd); mptr->m_available = chix->cid; mptr->m_type = reply_type; - mptr->m_count = 0; + mptr->m_count = htons (CA_MINOR_VERSION); mptr->m_cid = chix->cid; /* @@ -1135,8 +1135,9 @@ void *pvalue return ECA_NORDACCESS; } - if (count > chix->count) + if (count > chix->count) { return ECA_BADCOUNT; + } #ifdef vxWorks { @@ -1319,7 +1320,7 @@ LOCAL int issue_get_callback(evid monix, unsigned cmmd) * dont send the message if the conn is down * (it will be sent once connected) */ - if(chix->state != cs_conn){ + if (chix->state != cs_conn) { return ECA_BADCHID; } @@ -1341,7 +1342,7 @@ LOCAL int issue_get_callback(evid monix, unsigned cmmd) hdr.m_postsize = 0; hdr.m_cid = chix->id.sid; - status = cac_push_msg(piiu, &hdr, 0); + status = cac_push_msg (piiu, &hdr, 0); piiu->send_needed = TRUE; @@ -2281,6 +2282,7 @@ int APIENTRY ca_clear_event (evid monix) int status; chid chix = monix->chan; struct extmsg hdr; + evid lkup; /* * is it a valid channel ? @@ -2290,9 +2292,15 @@ int APIENTRY ca_clear_event (evid monix) /* * is it a valid monitor id */ - status = ellFind(&chix->eventq, &monix->node); - if(status==ERROR){ - return ECA_BADMONID; + if (chix->piiu) { + LOCK; + lkup = (evid) bucketLookupItemUnsignedId( + pFastBucket, + &monix->id); + UNLOCK; + if (lkup != monix) { + return ECA_BADMONID; + } } /* disable any further events from this event block */ @@ -3031,6 +3039,8 @@ void issue_identify_client(struct ioc_in_use *piiu) void issue_claim_channel(struct ioc_in_use *piiu, chid pchan) { struct extmsg hdr; + unsigned size; + char *pName; if(!piiu){ return; @@ -3044,7 +3054,19 @@ void issue_claim_channel(struct ioc_in_use *piiu, chid pchan) hdr = nullmsg; hdr.m_cmmd = htons(IOC_CLAIM_CIU); - hdr.m_cid = pchan->id.sid; + + if(CA_V44(CA_PROTOCOL_VERSION, piiu->minor_version_number)){ + hdr.m_cid = pchan->cid; + pName = ca_name(pchan); + size = strlen(pName)+1; + } + else { + hdr.m_cid = pchan->id.sid; + pName = NULL; + size = 0; + } + + hdr.m_postsize = size; /* * The available field is used (abused) @@ -3053,7 +3075,7 @@ void issue_claim_channel(struct ioc_in_use *piiu, chid pchan) */ hdr.m_available = htonl(CA_MINOR_VERSION); - cac_push_msg(piiu, &hdr, NULL); + cac_push_msg(piiu, &hdr, pName); piiu->send_needed = TRUE; } diff --git a/src/ca/acctst.c b/src/ca/acctst.c index 62a33717d..4dcb2db82 100644 --- a/src/ca/acctst.c +++ b/src/ca/acctst.c @@ -3,7 +3,7 @@ * CA test/debug routine */ -static char *sccsId = "%W% %G%"; +static char *sccsId = "@(#) $Id$"; #ifdef VMS #include @@ -122,17 +122,17 @@ int doacctst(char *pname) NULL); SEVCHK(status, NULL); - assert(INVALID_DB_REQ(chix1->type) == TRUE); - assert(INVALID_DB_REQ(chix2->type) == TRUE); - assert(INVALID_DB_REQ(chix3->type) == TRUE); - assert(INVALID_DB_REQ(chix4->type) == TRUE); + if (ca_test_io() == ECA_IOINPROGRESS) { + assert(INVALID_DB_REQ(chix1->type) == TRUE); + assert(INVALID_DB_REQ(chix2->type) == TRUE); + assert(INVALID_DB_REQ(chix3->type) == TRUE); + assert(INVALID_DB_REQ(chix4->type) == TRUE); - assert(ca_state(chix1) == cs_never_conn); - assert(ca_state(chix2) == cs_never_conn); - assert(ca_state(chix3) == cs_never_conn); - assert(ca_state(chix4) == cs_never_conn); - - assert(ca_test_io() == ECA_IOINPROGRESS); + assert(ca_state(chix1) == cs_never_conn); + assert(ca_state(chix2) == cs_never_conn); + assert(ca_state(chix3) == cs_never_conn); + assert(ca_state(chix4) == cs_never_conn); + } status = ca_pend_io(1000.0); SEVCHK(status, NULL); diff --git a/src/ca/bsd_depen.c b/src/ca/bsd_depen.c index 012866b8f..2079456ef 100644 --- a/src/ca/bsd_depen.c +++ b/src/ca/bsd_depen.c @@ -1,5 +1,5 @@ /* - * %W% %G% + * $Id$ * Author: Jeffrey O. Hill * hill@luke.lanl.gov * (505) 665 1831 diff --git a/src/ca/ca_printf.c b/src/ca/ca_printf.c index 50cb03d88..ddfb98d0b 100644 --- a/src/ca/ca_printf.c +++ b/src/ca/ca_printf.c @@ -32,7 +32,7 @@ /************************************************************************/ /*_end */ -static char *sccsId = "%W% %G%"; +static char *sccsId = "@(#) $Id$"; #include #include diff --git a/src/ca/conn.c b/src/ca/conn.c index 0181b1c0b..1e828b8b3 100644 --- a/src/ca/conn.c +++ b/src/ca/conn.c @@ -41,7 +41,7 @@ /************************************************************************/ /*_end */ -static char *sccsId = "%W% %G%"; +static char *sccsId = "@(#) $Id$"; #include "iocinf.h" @@ -157,6 +157,27 @@ void manage_conn(int silent) } UNLOCK; + /* + * try to attach to the repeater if we havent yet + */ + if (!ca_static->ca_repeater_contacted) { + delay = cac_time_diff ( + ¤t, + &ca_static->ca_last_repeater_try); + if (delay > REPEATER_TRY_PERIOD) { + ca_static->ca_last_repeater_try = current; + notify_ca_repeater(); + } + } + + /* + * Stop here if there are not any disconnected channels + */ + if (piiuCast->chidlist.count == 0) { + ca_static->ca_manage_conn_active = FALSE; + return; + } + if(ca_static->ca_conn_next_retry.tv_sec == CA_CURRENT_TIME.tv_sec && ca_static->ca_conn_next_retry.tv_usec == CA_CURRENT_TIME.tv_usec){ ca_static->ca_conn_next_retry = diff --git a/src/ca/convert.c b/src/ca/convert.c index aae20a60b..226d95018 100644 --- a/src/ca/convert.c +++ b/src/ca/convert.c @@ -28,7 +28,7 @@ * */ -static char *sccsId = "%W% %G%"; +static char *sccsId = "@(#) $Id$"; #include diff --git a/src/ca/flow_control.c b/src/ca/flow_control.c index 8d1d4d37b..34270aa5c 100644 --- a/src/ca/flow_control.c +++ b/src/ca/flow_control.c @@ -33,7 +33,7 @@ /************************************************************************/ /*_end */ -static char *sccsId = "%W% %G%"; +static char *sccsId = "@(#) $Id$"; #include "iocinf.h" diff --git a/src/ca/if_depen.c b/src/ca/if_depen.c index d342db54b..6f5caf000 100644 --- a/src/ca/if_depen.c +++ b/src/ca/if_depen.c @@ -1,5 +1,5 @@ /* if_depen.c */ -/* share/src/ca/%W% %G% */ +/* share/src/ca/$Id$ */ /* * Author: Jeff Hill @@ -35,7 +35,7 @@ */ -static char *sccsId = "%W% %G%"; +static char *sccsId = "@(#) $Id$"; #include "iocinf.h" diff --git a/src/ca/iocinf.c b/src/ca/iocinf.c index 8bd286bd5..bef3cb72d 100644 --- a/src/ca/iocinf.c +++ b/src/ca/iocinf.c @@ -66,7 +66,7 @@ /************************************************************************/ /*_end */ -static char *sccsId = "%W% %G%"; +static char *sccsId = "@(#) $Id$"; /* Allocate storage for global variables in this module */ @@ -505,25 +505,32 @@ void notify_ca_repeater() int status; static int once = FALSE; - if(!piiuCast) - return; - if(!piiuCast->conn_up) - return; - - if(ca_static->ca_repeater_contacted){ + if (ca_static->ca_repeater_contacted) { return; } - if(ca_static->ca_repeater_tries>N_REPEATER_TRIES_PRIOR_TO_MSG && !once){ - ca_printf("Unable to contact CA repeater after %d tries\n", + if (!piiuCast) { + return; + } + + if (!piiuCast->conn_up) { + return; + } + + if (ca_static->ca_repeater_tries>N_REPEATER_TRIES_PRIOR_TO_MSG){ + if (!once) { + ca_printf( + "Unable to contact CA repeater after %d tries\n", N_REPEATER_TRIES_PRIOR_TO_MSG); - ca_printf("Silence this message by starting a CA repeater daemon\n"); - once = TRUE; + ca_printf( + "Silence this message by starting a CA repeater daemon\n"); + once = TRUE; + } } LOCK; /*MULTINET TCP/IP routines are not reentrant*/ status = local_addr(piiuCast->sock_chan, &saddr); - if(status == OK){ + if (status == OK) { memset((char *)&msg, 0, sizeof(msg)); msg.m_cmmd = htons(REPEATER_REGISTER); msg.m_available = saddr.sin_addr.s_addr; diff --git a/src/ca/iocinf.h b/src/ca/iocinf.h index 2a3d3d412..694266952 100644 --- a/src/ca/iocinf.h +++ b/src/ca/iocinf.h @@ -73,7 +73,7 @@ # define HDRVERSIONID(NAME,VERS) #endif /*CAC_VERSION_GLOBAL*/ -HDRVERSIONID(iocinfh, "%W% %G%") +HDRVERSIONID(iocinfh, "$Id$") /* * ANSI C includes @@ -187,8 +187,8 @@ extern const ca_time CA_CURRENT_TIME; */ #define MAXCONNTRIES 30 /* N conn retries on unchanged net */ -#define SELECT_POLL (.10) /* units sec - polls into recast */ -#define CA_RECAST_DELAY (0.005) /* initial delay to next recast (sec) */ +#define SELECT_POLL (0.1) /* units sec - polls into recast */ +#define CA_RECAST_DELAY (0.1) /* initial delay to next recast (sec) */ #define CA_RECAST_PORT_MASK 0xff /* random retry interval off port */ #define CA_RECAST_PERIOD (5.0) /* ul on retry period long term (sec) */ @@ -208,6 +208,7 @@ extern const ca_time CA_CURRENT_TIME; #define CA_RETRY_PERIOD 5 /* int sec to next keepalive */ #define N_REPEATER_TRIES_PRIOR_TO_MSG 50 +#define REPEATER_TRY_PERIOD (0.1) #ifdef vxWorks typedef struct caclient_put_notify{ @@ -382,6 +383,7 @@ struct ca_static{ ELLLIST putCvrtBuf; ca_time ca_conn_next_retry; ca_time ca_conn_retry_delay; + ca_time ca_last_repeater_try; fd_set ca_readch; fd_set ca_writech; long ca_pndrecvcnt; diff --git a/src/ca/iocmsg.h b/src/ca/iocmsg.h index 6fde64fdb..a44697158 100644 --- a/src/ca/iocmsg.h +++ b/src/ca/iocmsg.h @@ -27,21 +27,29 @@ #define __IOCMSG__ -HDRVERSIONID(iocmsgh, "%W% %G% CA version 4.3") +HDRVERSIONID(iocmsgh, "@(#) $Id$ CA version 4.4") /* TCP/UDP port number (bumped each protocol change) */ #define CA_PROTOCOL_VERSION 4 -#define CA_MINOR_VERSION 3 +#define CA_MINOR_VERSION 4 #define CA_UKN_MINOR_VERSION 0 /* unknown minor version */ #if CA_PROTOCOL_VERSION == 4 #define CA_V41(MAJOR,MINOR) ((MINOR)>=1) #define CA_V42(MAJOR,MINOR) ((MINOR)>=2) #define CA_V43(MAJOR,MINOR) ((MINOR)>=3) -#else +#define CA_V44(MAJOR,MINOR) ((MINOR)>=4) +#elif CA_PROTOCOL_VERSION > 4 #define CA_V41(MAJOR,MINOR) ( 1 ) #define CA_V42(MAJOR,MINOR) ( 1 ) #define CA_V43(MAJOR,MINOR) ( 1 ) +#define CA_V44(MAJOR,MINOR) ( 1 ) +#else +#define CA_V41(MAJOR,MINOR) ( 0 ) +#define CA_V42(MAJOR,MINOR) ( 0 ) +#define CA_V43(MAJOR,MINOR) ( 0 ) +#define CA_V44(MAJOR,MINOR) ( 0 ) #endif + #define CA_PORT_BASE IPPORT_USERRESERVED + 56 #define CA_SERVER_PORT (CA_PORT_BASE+CA_PROTOCOL_VERSION*2) #define CA_CLIENT_PORT (CA_PORT_BASE+CA_PROTOCOL_VERSION*2+1) diff --git a/src/ca/net_convert.h b/src/ca/net_convert.h index de89652fc..7b65dc79c 100644 --- a/src/ca/net_convert.h +++ b/src/ca/net_convert.h @@ -1,5 +1,5 @@ /* - * %W% %G% + * $Id$ * * N E T _ C O N V E R T . H * MACROS for rapid conversion between HOST data formats and those used diff --git a/src/ca/netdb_depen.c b/src/ca/netdb_depen.c index c7249ef6b..9195f4711 100644 --- a/src/ca/netdb_depen.c +++ b/src/ca/netdb_depen.c @@ -1,5 +1,5 @@ /* netdb_depen.c */ -/* share/src/ca/%W% %G% */ +/* share/src/ca/$Id$ */ /* * Author: Jeff Hill * Date: 04-05-94 @@ -31,7 +31,7 @@ */ -static char *sccsId = "%W% %G%"; +static char *sccsId = "@(#) $Id$"; #include diff --git a/src/ca/os_depen.h b/src/ca/os_depen.h index 77dafa406..46b876869 100644 --- a/src/ca/os_depen.h +++ b/src/ca/os_depen.h @@ -30,7 +30,7 @@ #ifndef INCos_depenh #define INCos_depenh -static char *os_depenhSccsId = "%W% %G%"; +static char *os_depenhSccsId = "$Id$"; /* * errno.h is ANSI however we diff --git a/src/ca/posix_depen.c b/src/ca/posix_depen.c index 3dc4014fe..be1a1df6c 100644 --- a/src/ca/posix_depen.c +++ b/src/ca/posix_depen.c @@ -1,5 +1,5 @@ /* - * %W% %G% + * $Id$ * Author: Jeffrey O. Hill * hill@luke.lanl.gov * (505) 665 1831 @@ -77,10 +77,6 @@ void cac_mux_io(struct timeval *ptimeout) int newInput; struct timeval timeout; - if(!ca_static->ca_repeater_contacted){ - notify_ca_repeater(); - } - cac_clean_iiu_list(); timeout = *ptimeout; diff --git a/src/ca/repeater.c b/src/ca/repeater.c index d0ca7c751..8fdd78322 100644 --- a/src/ca/repeater.c +++ b/src/ca/repeater.c @@ -60,7 +60,7 @@ * */ -static char *sccsId = "%W% %G%"; +static char *sccsId = "@(#)$Id$"; #include "iocinf.h" diff --git a/src/ca/service.c b/src/ca/service.c index c1b73ff06..53391d512 100644 --- a/src/ca/service.c +++ b/src/ca/service.c @@ -68,7 +68,7 @@ /************************************************************************/ /*_end */ -static char *sccsId = "%W% %G%"; +static char *sccsId = "@(#) $Id$"; #include "iocinf.h" #include "net_convert.h" @@ -676,7 +676,8 @@ struct in_addr *pnet_addr chid chan; LOCK; - chan = bucketLookupItemUnsignedId(pSlowBucket, &piiu->curMsg.m_cid); + chan = bucketLookupItemUnsignedId( + pSlowBucket, &piiu->curMsg.m_cid); UNLOCK; if(!chan){ /* @@ -686,6 +687,9 @@ struct in_addr *pnet_addr break; } + if (CA_V44(CA_PROTOCOL_VERSION,piiu->minor_version_number)) { + chan->id.sid = ntohl (piiu->curMsg.m_available); + } reconnect_channel(piiu, chan); break; } @@ -724,7 +728,9 @@ struct in_addr *pnet_addr * lock required around use of the sprintf buffer */ LOCK; - chan = bucketLookupItemUnsignedId(pSlowBucket, &piiu->curMsg.m_available); + chan = bucketLookupItemUnsignedId( + pSlowBucket, + &piiu->curMsg.m_available); if(!chan){ UNLOCK; return; diff --git a/src/ca/syncgrp.c b/src/ca/syncgrp.c index 2fa5e688f..e7570a8fa 100644 --- a/src/ca/syncgrp.c +++ b/src/ca/syncgrp.c @@ -1,5 +1,5 @@ /* - * %W% %G% + * $Id$ * Author: Jeffrey O. Hill * hill@luke.lanl.gov * (505) 665 1831 @@ -60,11 +60,23 @@ void ca_sg_init(void) */ void ca_sg_shutdown(struct ca_static *ca_temp) { + CASG *pcasg; + int status; + /* * free all sync group lists */ + LOCK; + pcasg = (CASG *) ellFirst (&ca_temp->activeCASG); + while (pcasg) { + status = bucketRemoveItemUnsignedId ( + ca_temp->ca_pSlowBucket, &pcasg->id); + assert (status == BUCKET_SUCCESS); + pcasg = (CASG *) ellNext(&pcasg->node); + } ellFree(&ca_temp->activeCASG); ellFree(&ca_temp->freeCASG); + UNLOCK; ellInit(&ca_temp->activeCASGOP); ellInit(&ca_temp->freeCASGOP); diff --git a/src/ca/test_event.c b/src/ca/test_event.c index 3cd103b60..5b796e813 100644 --- a/src/ca/test_event.c +++ b/src/ca/test_event.c @@ -14,7 +14,7 @@ * */ -static char *sccsId = "%W% %G%"; +static char *sccsId = "$Id$"; #include "iocinf.h" diff --git a/src/ca/vms_depen.c b/src/ca/vms_depen.c index 5134ab5e5..5fbd797cf 100644 --- a/src/ca/vms_depen.c +++ b/src/ca/vms_depen.c @@ -1,5 +1,5 @@ /* - * %W% %G% + * $Id$ * Author: Jeffrey O. Hill * hill@luke.lanl.gov * (505) 665 1831 @@ -80,10 +80,6 @@ void cac_mux_io(struct timeval *ptimeout) int newInput; struct timeval timeout; - if(!ca_static->ca_repeater_contacted){ - notify_ca_repeater(); - } - cac_clean_iiu_list(); timeout = *ptimeout; @@ -102,13 +98,14 @@ void cac_mux_io(struct timeval *ptimeout) while(count>0); ca_process_input_queue(); + + /* + * manage search timers and detect disconnects + */ + manage_conn(TRUE); } while(newInput); - /* - * manage search timers and detect disconnects - */ - manage_conn(TRUE); } diff --git a/src/ca/vxWorks_depen.c b/src/ca/vxWorks_depen.c index f5054c821..8ccb72992 100644 --- a/src/ca/vxWorks_depen.c +++ b/src/ca/vxWorks_depen.c @@ -1,5 +1,5 @@ /* - * %W% %G% + * $Id$ * Author: Jeffrey O. Hill * hill@luke.lanl.gov * (505) 665 1831 @@ -63,14 +63,16 @@ void cac_gettimeval(struct timeval *pt) * Lazy Init */ if(!rate){ + sem = semBCreate(SEM_Q_PRIORITY, SEM_EMPTY); rate = sysClkRateGet(); assert(rate); - sem = semBCreate(SEM_Q_PRIORITY, SEM_EMPTY); assert(sem!=NULL); } + else { + status = semTake(sem, WAIT_FOREVER); + assert(status==OK); + } - status = semTake(sem, WAIT_FOREVER); - assert(status==OK); current = tickGet(); if(currentca_repeater_contacted){ - notify_ca_repeater(); - } - cac_clean_iiu_list(); cac_select_io( @@ -762,6 +760,7 @@ void cac_recv_task(int tid) CA_DO_RECVS); ca_process_input_queue(); + manage_conn(TRUE); } } diff --git a/src/ca/windows_depen.c b/src/ca/windows_depen.c index 8612466c9..2c279b2a9 100644 --- a/src/ca/windows_depen.c +++ b/src/ca/windows_depen.c @@ -1,5 +1,5 @@ /* - * %W% %G% + * $Id$ * Author: Jeffrey O. Hill * hill@luke.lanl.gov * (505) 665 1831 @@ -75,10 +75,6 @@ void cac_mux_io(struct timeval *ptimeout) int newInput; struct timeval timeout; - if(!ca_static->ca_repeater_contacted){ - notify_ca_repeater(); - } - cac_clean_iiu_list(); timeout = *ptimeout; @@ -97,13 +93,14 @@ void cac_mux_io(struct timeval *ptimeout) while(count>0); ca_process_input_queue(); + + /* + * manage search timers and detect disconnects + */ + manage_conn(TRUE); } while(newInput); - /* - * manage search timers and detect disconnects - */ - manage_conn(TRUE); }