From ccb8a554abef65c7d401bbd1abba79e2ca240d04 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Fri, 13 Jun 1997 09:14:29 +0000 Subject: [PATCH] connect/search proto changes --- src/ca/access.c | 24 ++++--- src/ca/acctst.c | 52 ++++++++------ src/ca/bsd_depen.c | 15 ++--- src/ca/caProto.h | 13 +++- src/ca/cadef.h | 27 ++++---- src/ca/catime.c | 4 +- src/ca/conn.c | 149 +++++++++++++++++++++++++---------------- src/ca/convert.c | 2 +- src/ca/iocinf.c | 61 ++++++----------- src/ca/iocinf.h | 50 +++++++------- src/ca/net_convert.h | 31 ++++++--- src/ca/posix_depen.c | 9 ++- src/ca/service.c | 126 +++++++++++++++++++++------------- src/ca/syncgrp.c | 5 +- src/ca/vms_depen.c | 7 +- src/ca/vxWorks_depen.c | 39 ++++++----- src/ca/windows_depen.c | 7 +- src/include/cadef.h | 27 ++++---- 18 files changed, 377 insertions(+), 271 deletions(-) diff --git a/src/ca/access.c b/src/ca/access.c index 85a17af16..6ebef35f4 100644 --- a/src/ca/access.c +++ b/src/ca/access.c @@ -99,6 +99,9 @@ /************************************************************************/ /* * $Log$ + * Revision 1.94 1997/05/05 04:40:29 jhill + * send_needed replaced by pushPending flag + * * Revision 1.93 1997/04/29 06:05:57 jhill * use free list * @@ -636,10 +639,10 @@ LOCAL void cac_add_msg (IIU *piiu) int epicsShareAPI ca_task_initialize(void) { int status; - struct ca_static *ca_temp; + struct CA_STATIC *ca_temp; if (!ca_static) { - ca_temp = (struct ca_static *) + ca_temp = (struct CA_STATIC *) calloc(1, sizeof(*ca_temp)); if (!ca_temp) { return ECA_ALLOCMEM; @@ -691,7 +694,13 @@ int ca_os_independent_init (void) * init broadcasted search counters * (current time must be initialized before calling this) */ - cacClrSearchCounters(); + ca_static->ca_search_responses = 0u; + ca_static->ca_search_tries = 0u; + ca_static->ca_search_retry_seq_no = 0u; + ca_static->ca_seq_no_at_list_begin = 0u; + ca_static->ca_frames_per_try = TRIESPERFRAME; + ca_static->ca_conn_next_retry = ca_static->currentTime; + cacSetRetryInterval (0u); ellInit(&ca_static->ca_iiuList); ellInit(&ca_static->ca_ioeventlist); @@ -759,7 +768,6 @@ LOCAL void create_udp_fd() status = create_net_chan( &ca_static->ca_piiuCast, NULL, - ca_static->ca_server_port, IPPROTO_UDP); if (~status & CA_M_SUCCESS) { ca_static->ca_piiuCast = NULL; @@ -1154,8 +1162,8 @@ int epicsShareAPI ca_search_and_connect /* * reset broadcasted search counters */ - cacClrSearchCounters(); - + ca_static->ca_conn_next_retry = ca_static->currentTime; + cacSetRetryInterval (0u); UNLOCK; /* @@ -1726,7 +1734,7 @@ LOCAL void ca_put_notify_action(PUTNOTIFY *ppn) { CACLIENTPUTNOTIFY *pcapn; struct ioc_in_use *piiu; - struct ca_static *pcas; + struct CA_STATIC *pcas; chid chix; /* @@ -3589,7 +3597,7 @@ int ca_channel_status(int tid) { chid chix; IIU *piiu; - struct ca_static *pcas; + struct CA_STATIC *pcas; pcas = (struct ca_static *) taskVarGet(tid, (int *)&ca_static); diff --git a/src/ca/acctst.c b/src/ca/acctst.c index c652c723d..6ad84e6b6 100644 --- a/src/ca/acctst.c +++ b/src/ca/acctst.c @@ -7,6 +7,9 @@ static char *sccsId = "@(#) $Id$"; /* * $Log$ + * Revision 1.45 1997/04/29 06:07:16 jhill + * local host connect compatible + * * Revision 1.44 1997/04/10 19:26:05 jhill * asynch connect, faster connect, ... * @@ -100,6 +103,7 @@ void write_event(struct event_handler_args args); void conn(struct connection_handler_args args); void get_cb(struct event_handler_args args); void accessSecurity_cb(struct access_rights_handler_args args); +void pend_event_delay_test(dbr_double_t request); void doubleTest( chid chan, @@ -179,26 +183,12 @@ int doacctst(char *pname) /* * CA pend event delay accuracy test + * (CA asssumes that search requests can be sent + * at least every 25 mS on all supported os) */ - { - TS_STAMP end_time; - TS_STAMP start_time; - dbr_double_t delay; - dbr_double_t request = 0.5; - dbr_double_t accuracy; - - tsLocalTime(&start_time); - status = ca_pend_event(request); - if (status != ECA_TIMEOUT) { - SEVCHK(status, NULL); - } - tsLocalTime(&end_time); - TsDiffAsDouble(&delay,&end_time,&start_time); - accuracy = 100.0*(delay-request)/request; - printf("CA pend event delay accuracy = %f %%\n", - accuracy); - assert (fabs(accuracy) < 10.0); - } + pend_event_delay_test(1.0); + pend_event_delay_test(0.1); + pend_event_delay_test(0.25); size = dbr_size_n(DBR_GR_FLOAT, NUM); ptr = (struct dbr_gr_float *) malloc(size); @@ -974,6 +964,30 @@ int doacctst(char *pname) return(0); } +/* + * pend_event_delay_test() + */ +void pend_event_delay_test(dbr_double_t request) +{ + int status; + TS_STAMP end_time; + TS_STAMP start_time; + dbr_double_t delay; + dbr_double_t accuracy; + + tsLocalTime(&start_time); + status = ca_pend_event(request); + if (status != ECA_TIMEOUT) { + SEVCHK(status, NULL); + } + tsLocalTime(&end_time); + TsDiffAsDouble(&delay,&end_time,&start_time); + accuracy = 100.0*(delay-request)/request; + printf("CA pend event delay = %f sec results in accuracy = %f %%\n", + request, accuracy); + assert (fabs(accuracy) < 10.0); +} + void floatTest( chid chan, dbr_float_t beginValue, diff --git a/src/ca/bsd_depen.c b/src/ca/bsd_depen.c index b64d11932..13e495299 100644 --- a/src/ca/bsd_depen.c +++ b/src/ca/bsd_depen.c @@ -127,17 +127,16 @@ int cac_select_io(struct timeval *ptimeout, int flags) piiu->recvPending = FALSE; } - if (flags&CA_DO_SENDS || piiu->pushPending) { - if (piiu->state==iiu_connecting) { + if (piiu->state==iiu_connecting) { + FD_SET (piiu->sock_chan, &pfdi->writeMask); + ioPending = TRUE; + } + else if (flags&CA_DO_SENDS || piiu->pushPending) { + if (cacRingBufferReadSize(&piiu->send, FALSE)>0) { + maxfd = max (maxfd,piiu->sock_chan); FD_SET (piiu->sock_chan, &pfdi->writeMask); ioPending = TRUE; } - else { - if (cacRingBufferReadSize(&piiu->send, FALSE)>0) { - maxfd = max (maxfd,piiu->sock_chan); - FD_SET (piiu->sock_chan, &pfdi->writeMask); - } - } } } UNLOCK; diff --git a/src/ca/caProto.h b/src/ca/caProto.h index db5b00801..d1b892a76 100644 --- a/src/ca/caProto.h +++ b/src/ca/caProto.h @@ -29,6 +29,9 @@ * * History * $Log$ + * Revision 1.3 1997/01/22 21:08:17 jhill + * removed use of ## for VAXC port + * * Revision 1.2 1996/09/16 16:32:49 jhill * added CA version string * @@ -68,6 +71,9 @@ * * .10 050594 joh New command added for CA V4.3 - wakeup the server * $Log$ + * Revision 1.3 1997/01/22 21:08:17 jhill + * removed use of ## for VAXC port + * * Revision 1.2 1996/09/16 16:32:49 jhill * added CA version string * @@ -87,8 +93,8 @@ * TCP/UDP port number (bumped each major protocol change) */ #define CA_PROTOCOL_VERSION 4u -#define CA_MINOR_VERSION 7u -#define CA_VERSION_STRING "4.7" +#define CA_MINOR_VERSION 8u +#define CA_VERSION_STRING "4.8" #define CA_UKN_MINOR_VERSION 0u /* unknown minor version */ #if CA_PROTOCOL_VERSION == 4u #define CA_V41(MAJOR,MINOR) ((MINOR)>=1u) @@ -98,6 +104,7 @@ #define CA_V45(MAJOR,MINOR) ((MINOR)>=5u) #define CA_V46(MAJOR,MINOR) ((MINOR)>=6u) #define CA_V47(MAJOR,MINOR) ((MINOR)>=7u) +#define CA_V48(MAJOR,MINOR) ((MINOR)>=8u) #elif CA_PROTOCOL_VERSION > 4u #define CA_V41(MAJOR,MINOR) ( 1u ) #define CA_V42(MAJOR,MINOR) ( 1u ) @@ -106,6 +113,7 @@ #define CA_V45(MAJOR,MINOR) ( 1u ) #define CA_V46(MAJOR,MINOR) ( 1u ) #define CA_V47(MAJOR,MINOR) ( 1u ) +#define CA_V48(MAJOR,MINOR) ( 1u ) #else #define CA_V41(MAJOR,MINOR) ( 0u ) #define CA_V42(MAJOR,MINOR) ( 0u ) @@ -114,6 +122,7 @@ #define CA_V45(MAJOR,MINOR) ( 0u ) #define CA_V46(MAJOR,MINOR) ( 0u ) #define CA_V47(MAJOR,MINOR) ( 0u ) +#define CA_V48(MAJOR,MINOR) ( 0u ) #endif /* diff --git a/src/ca/cadef.h b/src/ca/cadef.h index 91ea33eff..e7fd340f8 100644 --- a/src/ca/cadef.h +++ b/src/ca/cadef.h @@ -190,22 +190,25 @@ typedef void caArh(struct access_rights_handler_args args); typedef void caArh(); #endif /*CAC_ANSI_FUNC_PROTO*/ +/* + * The fields in this structure may change or even vanish in the future. + * Please use the macros above to access the information in this structure. + */ struct channel_in_use{ - ELLNODE node; /* list ptrs */ - short type; /* database field type */ -#define TYPENOTCONN (-1) /* the type when disconnected */ - unsigned short count; /* array element count */ + ELLNODE node; /* list ptrs */ + short type; /* database field type */ +#define TYPENOTCONN (-1) /* the type when disconnected */ + unsigned short count; /* array element count */ union{ - unsigned sid; /* server id */ - struct dbAddr *paddr; /* database address */ + unsigned sid; /* server id */ + struct dbAddr *paddr; /* database address */ } id; - const void *puser; /* user available area */ - enum channel_state state; /* connected/ disconnected etc */ - caar ar; /* access rights */ + const void *puser; /* user available area */ + short state; /* connected/ disconnected etc */ + unsigned short retrySeqNo; /* search retry seq number */ + caar ar; /* access rights */ + - /* - * The following fields may change or even vanish in the future - */ caCh *pConnFunc; caArh *pAccessRightsFunc; ELLLIST eventq; diff --git a/src/ca/catime.c b/src/ca/catime.c index 5d86c7d18..15943337a 100644 --- a/src/ca/catime.c +++ b/src/ca/catime.c @@ -142,7 +142,7 @@ int catime (char *channelName, enum appendNumberFlag appNF) itemList[i].name[strsize]= '\0'; itemList[i].count = 1; } - +#if 0 printf ("sync search test\n"); assert (100u<=NELEMENTS(itemList)); timeIt (test_sync_search, itemList, 100u); @@ -155,7 +155,7 @@ int catime (char *channelName, enum appendNumberFlag appNF) fflush (stdout); ca_pend_event(1.0); printf ("hopefully done\n"); - +#endif printf ("search test\n"); timeIt (test_search, itemList, NELEMENTS(itemList)); printSearchStat(NELEMENTS(itemList)); diff --git a/src/ca/conn.c b/src/ca/conn.c index 992b899fa..e684e25b3 100644 --- a/src/ca/conn.c +++ b/src/ca/conn.c @@ -30,6 +30,9 @@ /* (dont send all chans in a block) */ /* */ /* $Log$ + * Revision 1.38 1997/04/10 19:26:09 jhill + * asynch connect, faster connect, ... + * * Revision 1.37 1996/11/02 00:50:46 jhill * many pc port, const in API, and other changes * @@ -67,6 +70,7 @@ LOCAL void logRetryInterval(char *pFN, unsigned lineno); #endif LOCAL void retrySearchRequest(); +LOCAL unsigned bhtHashIP(const struct sockaddr_in *pina); /* @@ -232,6 +236,11 @@ LOCAL void retrySearchRequest () } LOCK; + + /* + * increment the retry sequence number + */ + ca_static->ca_search_retry_seq_no++; /* allowed to roll over */ /* * dynamically adjust the number of UDP frames per @@ -265,7 +274,7 @@ LOCAL void retrySearchRequest () /* * double UDP frames per try if we have a good score */ - if (ca_static->ca_frames_per_try < (UINT_MAX/2u) ) { + if (ca_static->ca_frames_per_try < (UINT_MAX/4u) ) { ca_static->ca_frames_per_try += ca_static->ca_frames_per_try; #ifdef DEBUG printf ("Increasing frame count to %u t=%u r=%u\n", @@ -309,11 +318,31 @@ LOCAL void retrySearchRequest () if (ca_static->ca_search_responses==0u) { cacSetRetryInterval(ca_static->ca_min_retry+1u); } - else { - ca_static->ca_search_responses=0u; - } - ca_static->ca_search_tries = 0u; + ca_static->ca_min_retry = UINT_MAX; + + /* + * increment the retry sequence number + * (this prevents the time of the next search + * try from being set to the current time if + * we are handling a response from an old + * search message) + */ + ca_static->ca_search_retry_seq_no++; /* allowed to roll over */ + + /* + * so that old search tries will not update the counters + */ + ca_static->ca_seq_no_at_list_begin = ca_static->ca_search_retry_seq_no; + /* + * keeps the search try/response counters in bounds + * (but keep some of the info from the previous iteration) + */ + ca_static->ca_search_responses = ca_static->ca_search_responses/16u; + ca_static->ca_search_tries = ca_static->ca_search_tries/16u; +#ifdef DEBUG + printf ("saw end of list\n"); +#endif } /* @@ -324,6 +353,10 @@ LOCAL void retrySearchRequest () if (status != ECA_NORMAL) { nSent++; + if (nSent>=ca_static->ca_frames_per_try) { + break; + } + /* * flush out the search request buffer */ @@ -337,11 +370,7 @@ LOCAL void retrySearchRequest () break; } } - - if (nSent>=ca_static->ca_frames_per_try) { - break; - } - + chan->retrySeqNo = ca_static->ca_search_retry_seq_no; chan = (ciu) ellFirst (&piiuCast->chidlist); /* @@ -374,19 +403,13 @@ LOCAL void retrySearchRequest () &ca_static->currentTime, &ca_static->ca_conn_retry_delay); LOGRETRYINTERVAL -} - -/* - * cacClrSearchCounters() - * (reset broadcasted search counters) - */ -void cacClrSearchCounters() -{ - ca_static->ca_search_responses = 0u; - ca_static->ca_search_tries = 0; - ca_static->ca_frames_per_try = TRIESPERFRAME; - ca_static->ca_conn_next_retry = ca_static->currentTime; - cacSetRetryInterval(0u); +#ifdef DEBUG +printf("sent %u at cur sec=%u cur usec=%u delay sec=%u delay usec = %u\n", + nSent, ca_static->currentTime.tv_sec, + ca_static->currentTime.tv_usec, + ca_static->ca_conn_retry_delay.tv_sec, + ca_static->ca_conn_retry_delay.tv_usec); +#endif } /* @@ -398,18 +421,11 @@ void cacSetRetryInterval(unsigned retryNo) long idelay; ca_real delay; - /* - * NOOP if no change - */ - if (ca_static->ca_search_retry == retryNo) { - return; - } - /* * set the retry interval */ + retryNo = min(retryNo, CHAR_BIT*sizeof(idelay)-1); ca_static->ca_search_retry = retryNo; - assert(ca_static->ca_search_retry < CHAR_BIT*sizeof(idelay)); idelay = 1; idelay = idelay << ca_static->ca_search_retry; delay = idelay * CA_RECAST_DELAY; /* sec */ @@ -418,6 +434,11 @@ void cacSetRetryInterval(unsigned retryNo) ca_static->ca_conn_retry_delay.tv_sec = idelay; ca_static->ca_conn_retry_delay.tv_usec = (long) ((delay-idelay)*USEC_PER_SEC); +#if 0 + printf ("new search period is %u sec %u usec\n", + ca_static->ca_conn_retry_delay.tv_sec, + ca_static->ca_conn_retry_delay.tv_usec); +#endif } @@ -454,7 +475,7 @@ LOCAL void logRetryInterval(char *pFN, unsigned lineno) /* * MARK_SERVER_AVAILABLE */ -void mark_server_available(const struct in_addr *pnet_addr) +void mark_server_available(const struct sockaddr_in *pnet_addr) { ciu chan; ca_real currentPeriod; @@ -527,7 +548,7 @@ void mark_server_available(const struct in_addr *pnet_addr) #ifdef DEBUG ca_printf( "new server at %x cur=%f avg=%f\n", - pnet_addr->s_addr, + pnet_addr->sin_addr.s_addr, currentPeriod, pBHE->averagePeriod); #endif @@ -549,7 +570,7 @@ void mark_server_available(const struct in_addr *pnet_addr) #ifdef DEBUG ca_printf( "net resume seen %x cur=%f avg=%f\n", - pnet_addr->s_addr, + pnet_addr->sin_addr.s_addr, currentPeriod, pBHE->averagePeriod); #endif @@ -563,7 +584,7 @@ void mark_server_available(const struct in_addr *pnet_addr) #ifdef DEBUG ca_printf( "reboot seen %x cur=%f avg=%f\n", - pnet_addr->s_addr, + pnet_addr->sin_addr.s_addr, currentPeriod, pBHE->averagePeriod); #endif @@ -658,20 +679,17 @@ void mark_server_available(const struct in_addr *pnet_addr) * * LOCK must be applied */ -bhe *createBeaconHashEntry(const struct in_addr *pnet_addr, unsigned sawBeacon) +bhe *createBeaconHashEntry(const struct sockaddr_in *pina, unsigned sawBeacon) { bhe *pBHE; unsigned index; - pBHE = lookupBeaconInetAddr(pnet_addr); + pBHE = lookupBeaconInetAddr(pina); if(pBHE){ return pBHE; } - index = ntohl(pnet_addr->s_addr); - index &= BHT_INET_ADDR_MASK; - - assert(indexca_beaconHash)); + index = bhtHashIP(pina); pBHE = (bhe *)calloc(1,sizeof(*pBHE)); if(!pBHE){ @@ -679,13 +697,13 @@ bhe *createBeaconHashEntry(const struct in_addr *pnet_addr, unsigned sawBeacon) } #ifdef DEBUG - ca_printf("new beacon at %x\n", pnet_addr->s_addr); + ca_printf("new beacon at %x %u\n", pina->sin_addr.s_addr, pina->sin_port); #endif /* * store the inet address */ - pBHE->inetAddr = *pnet_addr; + pBHE->inetAddr = *pina; /* * set average to -1.0 so that when the next beacon @@ -727,19 +745,17 @@ bhe *createBeaconHashEntry(const struct in_addr *pnet_addr, unsigned sawBeacon) * * LOCK must be applied */ -bhe *lookupBeaconInetAddr (const struct in_addr *pnet_addr) +bhe *lookupBeaconInetAddr (const struct sockaddr_in *pina) { bhe *pBHE; unsigned index; - index = ntohl(pnet_addr->s_addr); - index &= BHT_INET_ADDR_MASK; - - assert(indexca_beaconHash)); + index = bhtHashIP(pina); pBHE = ca_static->ca_beaconHash[index]; - while(pBHE){ - if(pBHE->inetAddr.s_addr == pnet_addr->s_addr){ + while (pBHE) { + if ( pBHE->inetAddr.sin_addr.s_addr == pina->sin_addr.s_addr && + pBHE->inetAddr.sin_port == pina->sin_port) { break; } pBHE = pBHE->pNext; @@ -754,21 +770,19 @@ bhe *lookupBeaconInetAddr (const struct in_addr *pnet_addr) * * LOCK must be applied */ -void removeBeaconInetAddr (const struct in_addr *pnet_addr) +void removeBeaconInetAddr (const struct sockaddr_in *pina) { bhe *pBHE; bhe **ppBHE; unsigned index; - index = ntohl (pnet_addr->s_addr); - index &= BHT_INET_ADDR_MASK; - - assert (indexca_beaconHash)); + index = bhtHashIP(pina); ppBHE = &ca_static->ca_beaconHash[index]; pBHE = *ppBHE; while (pBHE) { - if (pBHE->inetAddr.s_addr == pnet_addr->s_addr) { + if ( pBHE->inetAddr.sin_addr.s_addr == pina->sin_addr.s_addr && + pBHE->inetAddr.sin_port == pina->sin_port) { *ppBHE = pBHE->pNext; free (pBHE); return; @@ -779,13 +793,34 @@ void removeBeaconInetAddr (const struct in_addr *pnet_addr) assert (0); } +/* + * bhtHashIP() + */ +LOCAL unsigned bhtHashIP(const struct sockaddr_in *pina) +{ + unsigned index; + +#if BHT_INET_ADDR_MASK != 0xff +# error BHT_INET_ADDR_MASK changed - recode this routine ! +#endif + + index = pina->sin_addr.s_addr; + index ^= pina->sin_port; + index = (index>>16u) ^ index; + index = (index>>8u) ^ index; + index &= BHT_INET_ADDR_MASK; + assert(indexca_beaconHash)); + return index; +} + + /* * freeBeaconHash() * * LOCK must be applied */ -void freeBeaconHash(struct ca_static *ca_temp) +void freeBeaconHash(struct CA_STATIC *ca_temp) { bhe *pBHE; bhe **ppBHE; diff --git a/src/ca/convert.c b/src/ca/convert.c index cc114d117..ed3cedbe5 100644 --- a/src/ca/convert.c +++ b/src/ca/convert.c @@ -95,7 +95,7 @@ LOCAL CACVRTFUNC cvrt_put_ackt; LOCAL CACVRTFUNC cvrt_stsack_string; /* cvrt is (array of) (pointer to) (function returning) int */ -CACVRTFUNC *cac_dbr_cvrt[] +epicsShareDef CACVRTFUNC *cac_dbr_cvrt[] = { cvrt_string, diff --git a/src/ca/iocinf.c b/src/ca/iocinf.c index f52396be0..e37bfcca5 100644 --- a/src/ca/iocinf.c +++ b/src/ca/iocinf.c @@ -47,6 +47,9 @@ /* address in use so that test works on UNIX */ /* kernels that support multicast */ /* $Log$ + * Revision 1.70 1997/05/05 04:44:39 jhill + * socket buf matches CA buf size, and pushPending flag added + * * Revision 1.69 1997/04/23 17:05:05 jhill * pc port changes * @@ -133,9 +136,8 @@ LOCAL void close_ioc (IIU *piiu); * */ int alloc_ioc( -const struct in_addr *pnet_addr, -unsigned short port, -struct ioc_in_use **ppiiu +const struct sockaddr_in *pina, +struct ioc_in_use **ppiiu ) { int status; @@ -145,9 +147,9 @@ struct ioc_in_use **ppiiu * look for an existing connection */ LOCK; - pBHE = lookupBeaconInetAddr(pnet_addr); + pBHE = lookupBeaconInetAddr(pina); if(!pBHE){ - pBHE = createBeaconHashEntry(pnet_addr, FALSE); + pBHE = createBeaconHashEntry(pina, FALSE); if(!pBHE){ UNLOCK; return ECA_ALLOCMEM; @@ -166,8 +168,7 @@ struct ioc_in_use **ppiiu else{ status = create_net_chan( ppiiu, - pnet_addr, - port, + pina, IPPROTO_TCP); if(status == ECA_NORMAL){ pBHE->piiu = *ppiiu; @@ -181,14 +182,13 @@ struct ioc_in_use **ppiiu /* - * CREATE_NET_CHANNEL() + * CREATE_NET_CHAN() * */ int create_net_chan( -struct ioc_in_use **ppiiu, -const struct in_addr *pnet_addr, /* only used by TCP connections */ -unsigned short port, -int net_proto +struct ioc_in_use **ppiiu, +const struct sockaddr_in *pina, /* only used by TCP connections */ +int net_proto ) { struct ioc_in_use *piiu; @@ -228,7 +228,6 @@ int net_proto { case IPPROTO_TCP: - assert(pnet_addr); pNode = (caAddrNode *)calloc(1,sizeof(*pNode)); if(!pNode){ free(piiu); @@ -236,9 +235,8 @@ int net_proto return ECA_ALLOCMEM; } memset((char *)&pNode->destAddr,0,sizeof(pNode->destAddr)); - pNode->destAddr.in.sin_family = AF_INET; - pNode->destAddr.in.sin_addr = *pnet_addr; - pNode->destAddr.in.sin_port = htons (port); + + pNode->destAddr.in = *pina; ellAdd(&piiu->destAddr, &pNode->node); piiu->recvBytes = tcp_recv_msg; piiu->sendBytes = cac_connect_iiu; @@ -321,7 +319,6 @@ int net_proto { int i; - int size; /* set TCP buffer sizes */ i = MAX_MSG_SIZE; @@ -352,25 +349,9 @@ int net_proto UNLOCK; return ECA_SOCK; } - - /* fetch the TCP send buffer size */ - i = sizeof(size); - status = getsockopt( - sock, - SOL_SOCKET, - SO_SNDBUF, - (char *)&size, - &i); - if(status < 0 || i != sizeof(size)){ - free(pNode); - free(piiu); - socket_close(sock); - UNLOCK; - return ECA_SOCK; - } } - cacRingBufferInit(&piiu->recv, sizeof(piiu->send.buf)); + cacRingBufferInit(&piiu->recv, sizeof(piiu->recv.buf)); cacRingBufferInit(&piiu->send, sizeof(piiu->send.buf)); cac_gettimeval (&piiu->timeAtLastRecv); @@ -401,7 +382,6 @@ int net_proto case IPPROTO_UDP: - assert(!pnet_addr); piiu->recvBytes = udp_recv_msg; piiu->sendBytes = cac_udp_send_msg_piiu; piiu->procInput = ca_process_udp; @@ -492,7 +472,7 @@ int net_proto ca_static->ca_server_port); - cacRingBufferInit(&piiu->recv, sizeof(piiu->send.buf)); + cacRingBufferInit(&piiu->recv, sizeof(piiu->recv.buf)); cacRingBufferInit(&piiu->send, min(MAX_UDP, sizeof(piiu->send.buf))); @@ -513,7 +493,7 @@ int net_proto default: free(piiu); - genLocalExcep (ECA_INTERNAL,"alloc_ioc: ukn protocol"); + genLocalExcep (ECA_INTERNAL,"create_net_chan: ukn protocol"); /* * turn off gcc warnings */ @@ -622,9 +602,6 @@ LOCAL void cac_connect_iiu (struct ioc_in_use *piiu) errnoCpy==EALREADY || errnoCpy==EINVAL /* for early WINSOCK */ ) { - ca_printf( - "CAC: duplicate connect err %d=\"%s\"\n", - errnoCpy, strerror(errnoCpy)); return; } else if(errnoCpy==EINTR) { @@ -971,7 +948,7 @@ LOCAL void cac_tcp_send_msg_piiu(struct ioc_in_use *piiu) localError = SOCKERRNO; if( localError == EWOULDBLOCK || - localError == ENOBUFS || + /* localError == ENOBUFS || */ localError == EINTR){ UNLOCK; return; @@ -1388,7 +1365,7 @@ LOCAL void close_ioc (IIU *piiu) */ pNode = (caAddrNode *) piiu->destAddr.node.next; assert (pNode); - removeBeaconInetAddr (&pNode->destAddr.in.sin_addr); + removeBeaconInetAddr (&pNode->destAddr.in); /* * Mark all of their channels disconnected diff --git a/src/ca/iocinf.h b/src/ca/iocinf.h index 01c72cfee..1374fa516 100644 --- a/src/ca/iocinf.h +++ b/src/ca/iocinf.h @@ -32,6 +32,9 @@ /************************************************************************/ /* $Log$ + * Revision 1.63 1997/05/05 04:45:25 jhill + * send_needed => pushPending, and added ca_number_iiu_in_fc + * * Revision 1.62 1997/04/29 06:11:08 jhill * use free lists * @@ -315,7 +318,7 @@ typedef struct caclient_put_notify{ unsigned long valueSize; /* size of block pointed to by dbPutNotify */ void (*caUserCallback)(struct event_handler_args); void *caUserArg; - struct ca_static *pcas; + struct CA_STATIC *pcas; int busy; }CACLIENTPUTNOTIFY; #endif /*vxWorks*/ @@ -434,7 +437,7 @@ typedef struct ioc_in_use{ struct ca_buffer send; struct ca_buffer recv; caHdr curMsg; - struct ca_static *pcas; + struct CA_STATIC *pcas; void *pCurData; void (*sendBytes)(struct ioc_in_use *); void (*recvBytes)(struct ioc_in_use *); @@ -464,11 +467,11 @@ typedef struct ioc_in_use{ /* * for the beacon's recvd hash table */ -#define BHT_INET_ADDR_MASK 0x7f +#define BHT_INET_ADDR_MASK 0xff typedef struct beaconHashEntry{ struct beaconHashEntry *pNext; IIU *piiu; - struct in_addr inetAddr; + struct sockaddr_in inetAddr; ca_time timeStamp; ca_real averagePeriod; }bhe; @@ -483,7 +486,7 @@ typedef struct { fd_set writeMask; }caFDInfo; -struct ca_static{ +struct CA_STATIC { ELLLIST ca_iiuList; ELLLIST ca_ioeventlist; ELLLIST ca_pend_read_list; @@ -516,8 +519,8 @@ struct ca_static{ void *ca_sgFreeListPVT; void *ca_sgopFreeListPVT; ciu ca_pEndOfBCastList; - unsigned long ca_search_responses; /* num valid search resp within seq # */ - unsigned long ca_search_tries; /* num search tries within seq # */ + unsigned ca_search_responses; /* num valid search resp within seq # */ + unsigned ca_search_tries; /* num search tries within seq # */ unsigned ca_search_retry; /* search retry seq number */ unsigned ca_min_retry; /* min retry no so far */ unsigned ca_frames_per_try; /* # of UDP frames per search try */ @@ -528,6 +531,8 @@ struct ca_static{ unsigned ca_number_iiu_in_fc; unsigned short ca_server_port; unsigned short ca_repeater_port; + unsigned short ca_search_retry_seq_no; /* search retry seq number */ + unsigned short ca_seq_no_at_list_begin; /* search retry seq number at beg of list*/ char ca_sprintf_buf[256]; char ca_new_err_code_msg_buf[128u]; unsigned ca_post_msg_active:1; @@ -592,7 +597,7 @@ typedef struct{ */ GLBLTYPE -struct ca_static *ca_static; +struct CA_STATIC *ca_static; /* * CA internal functions @@ -614,14 +619,14 @@ void issue_client_host_name(struct ioc_in_use *piiu); int ca_defunct(void); int ca_printf(char *pformat, ...); void manage_conn(); -void mark_server_available(const struct in_addr *pnet_addr); +void mark_server_available(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); void ca_repeater(void); void cac_recv_task(int tid); void ca_sg_init(void); -void ca_sg_shutdown(struct ca_static *ca_temp); +void ca_sg_shutdown(struct CA_STATIC *ca_temp); int cac_select_io(struct timeval *ptimeout, int flags); void caHostFromInetAddr( const struct in_addr *pnet_addr, @@ -635,9 +640,8 @@ int post_msg( unsigned long blockSize ); int alloc_ioc( - const struct in_addr *pnet_addr, - unsigned short port, - struct ioc_in_use **ppiiu + const struct sockaddr_in *pina, + struct ioc_in_use **ppiiu ); unsigned long cacRingBufferWrite( struct ca_buffer *pRing, @@ -668,20 +672,19 @@ char *localUserName(void); char *localHostName(void); int create_net_chan( -struct ioc_in_use **ppiiu, -const struct in_addr *pnet_addr, /* only used by TCP connections */ -unsigned short port, -int net_proto +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 port); int ca_os_independent_init (void); -void freeBeaconHash(struct ca_static *ca_temp); -void removeBeaconInetAddr(const struct in_addr *pnet_addr); -bhe *lookupBeaconInetAddr(const struct in_addr *pnet_addr); -bhe *createBeaconHashEntry(const struct in_addr *pnet_addr, unsigned sawBeacon); +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); @@ -691,8 +694,8 @@ 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); -int cac_os_depen_init(struct ca_static *pcas); -void cac_os_depen_exit (struct ca_static *pcas); +int cac_os_depen_init(struct CA_STATIC *pcas); +void cac_os_depen_exit (struct CA_STATIC *pcas); void ca_process_exit(); void ca_spawn_repeater(void); void cac_gettimeval(struct timeval *pt); @@ -711,7 +714,6 @@ void genLocalExcepWFL(long stat, char *ctx, genLocalExcepWFL (STAT, PCTX, __FILE__, __LINE__) void cac_reconnect_channel(ciu chan); void retryPendingClaims(IIU *piiu); -void cacClrSearchCounters(); void cacSetRetryInterval(unsigned retryNo); void addToChanList(ciu chan, IIU *piiu); void removeFromChanList(ciu chan); diff --git a/src/ca/net_convert.h b/src/ca/net_convert.h index 4ea4098d5..8b7fd4fa1 100644 --- a/src/ca/net_convert.h +++ b/src/ca/net_convert.h @@ -28,6 +28,11 @@ #define _NET_CONVERT_H #include "db_access.h" +#include "shareLib.h" + +#ifdef __cplusplus +extern "C" { +#endif /* * Here are the definitions for architecture dependent byte ordering @@ -85,7 +90,7 @@ typedef void CACVRTFUNC(void *pSrc, void *pDest, int hton, unsigned long count); #ifdef CONVERSION_REQUIRED /* cvrt is (array of) (pointer to) (function returning) int */ -extern CACVRTFUNC *cac_dbr_cvrt[LAST_BUFFER_TYPE+1]; +epicsShareExtern CACVRTFUNC *cac_dbr_cvrt[LAST_BUFFER_TYPE+1]; #endif @@ -123,20 +128,20 @@ extern CACVRTFUNC *cac_dbr_cvrt[LAST_BUFFER_TYPE+1]; #ifdef CA_LITTLE_ENDIAN # ifndef ntohl # define ntohl(LONG)\ - (\ - ((LONG) & (dbr_long_t) 0xff000000) >> 24 |\ - ((LONG) & (dbr_long_t) 0x000000ff) << 24 |\ - ((LONG) & (dbr_long_t) 0x0000ff00) << 8 |\ - ((LONG) & (dbr_long_t) 0x00ff0000) >> 8\ + ( (dbr_long_t) (\ + ( ((dbr_ulong_t)LONG) & 0xff000000 ) >> 24u |\ + ( ((dbr_ulong_t)LONG) & 0x000000ff ) << 24u |\ + ( ((dbr_ulong_t)LONG) & 0x0000ff00 ) << 8u |\ + ( ((dbr_ulong_t)LONG) & 0x00ff0000 ) >> 8u )\ ) # endif # ifndef htonl # define htonl(LONG)\ - ( (dbr_long_t) \ - (((LONG) & (dbr_long_t) 0x000000ff) << 24 |\ - ((LONG) & (dbr_long_t) 0xff000000) >> 24 |\ - ((LONG) & (dbr_long_t) 0x00ff0000) >> 8 |\ - ((LONG) & (dbr_long_t) 0x0000ff00) << 8 )\ + ( (dbr_long_t) (\ + ( ((dbr_ulong_t)(LONG)) & 0x000000ff ) << 24u |\ + ( ((dbr_ulong_t)(LONG)) & 0xff000000 ) >> 24u |\ + ( ((dbr_ulong_t)(LONG)) & 0x00ff0000 ) >> 8u |\ + ( ((dbr_ulong_t)(LONG)) & 0x0000ff00 ) << 8u )\ ) # endif # else @@ -183,4 +188,8 @@ extern CACVRTFUNC *cac_dbr_cvrt[LAST_BUFFER_TYPE+1]; void dbr_ntohf(dbr_float_t *pNet, dbr_float_t *pHost); #endif +#ifdef __cplusplus +} +#endif + #endif /* define _NET_CONVERT_H */ diff --git a/src/ca/posix_depen.c b/src/ca/posix_depen.c index 00d6845c5..d13cb688c 100644 --- a/src/ca/posix_depen.c +++ b/src/ca/posix_depen.c @@ -29,6 +29,9 @@ * Modification Log: * ----------------- * $Log$ + * Revision 1.21 1997/04/10 19:26:17 jhill + * asynch connect, faster connect, ... + * * Revision 1.20 1996/11/02 00:51:02 jhill * many pc port, const in API, and other changes * @@ -110,7 +113,7 @@ void os_specific_sg_delete(CASG *pcasg) /* * CAC_ADD_TASK_VARIABLE() */ -int cac_add_task_variable(struct ca_static *ca_temp) +int cac_add_task_variable(struct CA_STATIC *ca_temp) { ca_static = ca_temp; return ECA_NORMAL; @@ -120,7 +123,7 @@ int cac_add_task_variable(struct ca_static *ca_temp) /* * cac_os_depen_init() */ -int cac_os_depen_init(struct ca_static *pcas) +int cac_os_depen_init(struct CA_STATIC *pcas) { int status; @@ -135,7 +138,7 @@ int cac_os_depen_init(struct ca_static *pcas) /* * cac_os_depen_exit () */ -void cac_os_depen_exit (struct ca_static *pcas) +void cac_os_depen_exit (struct CA_STATIC *pcas) { ca_static = pcas; ca_process_exit(); diff --git a/src/ca/service.c b/src/ca/service.c index dcf814a59..d9b46cc04 100644 --- a/src/ca/service.c +++ b/src/ca/service.c @@ -533,21 +533,33 @@ const struct in_addr *pnet_addr case CA_PROTO_RSRV_IS_UP: LOCK; { - struct in_addr ina; + struct sockaddr_in ina; /* * this allows a fan-out server to potentially * insert the true address of a server - * (servers prior to 3.13 always set this + * + * (servers always set this * field to one of the ip addresses of the host) - * (clients prior to 3.13 always expect that this + * (clients always expect that this * field is set to the server's IP address). */ + ina.sin_family = AF_INET; if (piiu->curMsg.m_available != INADDR_ANY) { - ina.s_addr = piiu->curMsg.m_available; + ina.sin_addr.s_addr = piiu->curMsg.m_available; } else { - ina = *pnet_addr; + ina.sin_addr = *pnet_addr; + } + if (piiu->curMsg.m_count != 0) { + ina.sin_port = htons (piiu->curMsg.m_count); + } + else { + /* + * old servers dont supply this and the + * default port must be assumed + */ + ina.sin_port = htons (ca_static->ca_server_port); } mark_server_available(&ina); } @@ -788,13 +800,13 @@ IIU *piiu, const struct in_addr *pnet_addr ) { - unsigned short port; - char rej[64]; - ciu chan; - int status; - IIU *allocpiiu; - unsigned short *pMinorVersion; - unsigned minorVersion; + struct sockaddr_in ina; + char rej[64]; + ciu chan; + int status; + IIU *allocpiiu; + unsigned short *pMinorVersion; + unsigned minorVersion; if (piiu!=piiuCast) { return; @@ -828,29 +840,6 @@ const struct in_addr *pnet_addr return; } - /* - * Ignore duplicate search replies - */ - if (piiuCast != (IIU *) chan->piiu) { - caAddrNode *pNode; - IIU *tcpPIIU = (IIU *) chan->piiu; - - pNode = (caAddrNode *) ellFirst(&tcpPIIU->destAddr); - assert(pNode); - if (pNode->destAddr.in.sin_addr.s_addr != pnet_addr->s_addr) { - caHostFromInetAddr(pnet_addr,rej,sizeof(rej)); - sprintf( - sprintf_buf, - "Channel: %s Accepted: %s Rejected: %s ", - (char *)(chan + 1), - tcpPIIU->host_name_str, - rej); - genLocalExcep (ECA_DBLCHNL, sprintf_buf); - } - UNLOCK; - return; - } - /* * Starting with CA V4.1 the minor version number * is appended to the end of each search reply. @@ -868,13 +857,50 @@ const struct in_addr *pnet_addr * the type field is abused to carry the port number * so that we can have multiple servers on one host */ - if (CA_V45 (CA_PROTOCOL_VERSION,minorVersion)) { - port = piiu->curMsg.m_type; + ina.sin_family = AF_INET; + if (CA_V48 (CA_PROTOCOL_VERSION,minorVersion)) { + if (piiu->curMsg.m_cid != ~0ul) { + ina.sin_addr.s_addr = htonl(piiu->curMsg.m_cid); + } + else { + ina.sin_addr = *pnet_addr; + } + ina.sin_port = htons(piiu->curMsg.m_type); + } + else if (CA_V45 (CA_PROTOCOL_VERSION,minorVersion)) { + ina.sin_port = htons(piiu->curMsg.m_type); + ina.sin_addr = *pnet_addr; } else { - port = ca_static->ca_server_port; + ina.sin_port = htons(ca_static->ca_server_port); + ina.sin_addr = *pnet_addr; } - status = alloc_ioc (pnet_addr, port, &allocpiiu); + + /* + * Ignore duplicate search replies + */ + if (piiuCast != (IIU *) chan->piiu) { + caAddrNode *pNode; + IIU *tcpPIIU = (IIU *) chan->piiu; + + pNode = (caAddrNode *) ellFirst(&tcpPIIU->destAddr); + assert(pNode); + if (pNode->destAddr.in.sin_addr.s_addr != ina.sin_addr.s_addr || + pNode->destAddr.in.sin_port != ina.sin_port) { + caHostFromInetAddr(pnet_addr,rej,sizeof(rej)); + sprintf( + sprintf_buf, + "Channel: %s Accepted: %s Rejected: %s ", + (char *)(chan + 1), + tcpPIIU->host_name_str, + rej); + genLocalExcep (ECA_DBLCHNL, sprintf_buf); + } + UNLOCK; + return; + } + + status = alloc_ioc (&ina, &allocpiiu); switch (status) { case ECA_NORMAL: @@ -913,8 +939,15 @@ const struct in_addr *pnet_addr issue_client_host_name(allocpiiu); } - if (ca_static->ca_search_responsesca_search_responses++; + /* + * increase the valid search response count only if this + * response matches up with a request since the beginning + * of the search list + */ + if (ca_static->ca_seq_no_at_list_begin <= chan->retrySeqNo) { + if (ca_static->ca_search_responsesca_search_responses++; + } } /* @@ -948,13 +981,12 @@ const struct in_addr *pnet_addr /* * Reset the delay to the next search request if we get - * at least one response. This may result in an over - * run of the UDP input queue of the server in some - * cases (and therefore in redundant search requests) - * but it does significantly reduce the connect delays - * when 1000's of channels must be connected. + * at least one response. However, dont reset this delay if we + * get a delayed response to an old search request. */ - ca_static->ca_conn_next_retry = ca_static->currentTime; + if (chan->retrySeqNo == ca_static->ca_search_retry_seq_no) { + ca_static->ca_conn_next_retry = ca_static->currentTime; + } /* * claim the resource in the IOC diff --git a/src/ca/syncgrp.c b/src/ca/syncgrp.c index e2406148e..4891830d3 100644 --- a/src/ca/syncgrp.c +++ b/src/ca/syncgrp.c @@ -29,6 +29,9 @@ * Modification Log: * ----------------- * $Log$ + * Revision 1.23 1997/04/29 06:12:42 jhill + * use free lists + * * Revision 1.22 1996/11/22 19:08:02 jhill * added const to API * @@ -81,7 +84,7 @@ void ca_sg_init(void) /* * ca_sg_shutdown() */ -void ca_sg_shutdown(struct ca_static *ca_temp) +void ca_sg_shutdown(struct CA_STATIC *ca_temp) { CASG *pcasg; CASG *pnextcasg; diff --git a/src/ca/vms_depen.c b/src/ca/vms_depen.c index b80aba53f..07937958c 100644 --- a/src/ca/vms_depen.c +++ b/src/ca/vms_depen.c @@ -32,6 +32,9 @@ * cjm 20-Nov-95 Add code for gettimeofday * * $Log$ + * Revision 1.21 1997/01/22 21:11:49 jhill + * moved vms includes here + * * Revision 1.20 1996/07/02 23:04:07 jhill * took &tz out of gettimeofday() * @@ -164,7 +167,7 @@ void cac_block_for_sg_completion(CASG *pcasg, struct timeval *pTV) /* * cac_os_depen_init() */ -int cac_os_depen_init(struct ca_static *pcas) +int cac_os_depen_init(struct CA_STATIC *pcas) { int status; @@ -179,7 +182,7 @@ int cac_os_depen_init(struct ca_static *pcas) /* * cac_os_depen_exit () */ -void cac_os_depen_exit (struct ca_static *pcas) +void cac_os_depen_exit (struct CA_STATIC *pcas) { ca_static = pcas; ca_process_exit(); diff --git a/src/ca/vxWorks_depen.c b/src/ca/vxWorks_depen.c index 57a8c7433..d88cde6aa 100644 --- a/src/ca/vxWorks_depen.c +++ b/src/ca/vxWorks_depen.c @@ -29,6 +29,9 @@ * Modification Log: * ----------------- * $Log$ + * Revision 1.30 1997/04/29 06:13:49 jhill + * use free lists + * * Revision 1.29 1997/04/23 17:05:10 jhill * pc port changes * @@ -71,8 +74,8 @@ LOCAL void ca_repeater_task(); LOCAL void ca_task_exit_tcb(WIND_TCB *ptcb); LOCAL void ca_extra_event_labor(void *pArg); -LOCAL int cac_os_depen_exit_tid (struct ca_static *pcas, int tid); -LOCAL int cac_add_task_variable (struct ca_static *ca_temp); +LOCAL int cac_os_depen_exit_tid (struct CA_STATIC *pcas, int tid); +LOCAL int cac_add_task_variable (struct CA_STATIC *ca_temp); LOCAL void deleteCallBack(CALLBACK *pcb); LOCAL void ca_check_for_fp(); LOCAL int event_import(int tid); @@ -238,7 +241,7 @@ void cac_block_for_sg_completion(CASG *pcasg, struct timeval *pTV) /* * CAC_ADD_TASK_VARIABLE() */ -LOCAL int cac_add_task_variable (struct ca_static *ca_temp) +LOCAL int cac_add_task_variable (struct CA_STATIC *ca_temp) { static char ca_installed; TVIU *ptviu; @@ -314,7 +317,7 @@ LOCAL int cac_add_task_variable (struct ca_static *ca_temp) LOCAL void ca_task_exit_tcb(WIND_TCB *ptcb) { int status; - struct ca_static *ca_temp; + struct CA_STATIC *ca_temp; # ifdef DEBUG ca_printf("CAC: entering the exit handler %x\n", ptcb); @@ -327,9 +330,9 @@ LOCAL void ca_task_exit_tcb(WIND_TCB *ptcb) * the task id - somthing which may not be true * on future releases of vxWorks */ - ca_temp = (struct ca_static *) + ca_temp = (struct CA_STATIC *) taskVarGet((int)ptcb, (int *) &ca_static); - if (ca_temp == (struct ca_static *) ERROR){ + if (ca_temp == (struct CA_STATIC *) ERROR){ return; } @@ -362,7 +365,7 @@ LOCAL void ca_task_exit_tcb(WIND_TCB *ptcb) /* * cac_os_depen_init() */ -int cac_os_depen_init(struct ca_static *pcas) +int cac_os_depen_init(struct CA_STATIC *pcas) { char name[15]; int status; @@ -426,7 +429,7 @@ int cac_os_depen_init(struct ca_static *pcas) /* * cac_os_depen_exit () */ -void cac_os_depen_exit (struct ca_static *pcas) +void cac_os_depen_exit (struct CA_STATIC *pcas) { cac_os_depen_exit_tid (pcas, 0); } @@ -435,7 +438,7 @@ void cac_os_depen_exit (struct ca_static *pcas) /* * cac_os_depen_exit_tid () */ -LOCAL int cac_os_depen_exit_tid (struct ca_static *pcas, int tid) +LOCAL int cac_os_depen_exit_tid (struct CA_STATIC *pcas, int tid) { int status; ciu chix; @@ -665,7 +668,7 @@ LOCAL int event_import(int tid) int ca_import(int tid) { int status; - struct ca_static *pcas; + struct CA_STATIC *pcas; TVIU *ptviu; ca_check_for_fp(); @@ -674,9 +677,9 @@ int ca_import(int tid) * just return success if they have already done * a ca import for this task */ - pcas = (struct ca_static *) + pcas = (struct CA_STATIC *) taskVarGet(taskIdSelf(), (int *)&ca_static); - if (pcas != (struct ca_static *) ERROR){ + if (pcas != (struct CA_STATIC *) ERROR){ return ECA_NORMAL; } @@ -685,9 +688,9 @@ int ca_import(int tid) return ECA_ALLOCMEM; } - pcas = (struct ca_static *) + pcas = (struct CA_STATIC *) taskVarGet(tid, (int *)&ca_static); - if (pcas == (struct ca_static *) ERROR){ + if (pcas == (struct CA_STATIC *) ERROR){ free(ptviu); return ECA_NOCACTX; } @@ -718,7 +721,7 @@ int ca_import_cancel(int tid) { int status; TVIU *ptviu; - struct ca_static *pcas; + struct CA_STATIC *pcas; if (tid == taskIdSelf()) { pcas = NULL; @@ -730,9 +733,9 @@ int ca_import_cancel(int tid) /* * Attempt to attach to the specified context */ - ca_static = (struct ca_static *) + ca_static = (struct CA_STATIC *) taskVarGet(tid, (int *)&ca_static); - if (ca_static == (struct ca_static *) ERROR){ + if (ca_static == (struct CA_STATIC *) ERROR){ ca_static = pcas; return ECA_NOCACTX; } @@ -829,7 +832,7 @@ LOCAL void ca_extra_event_labor(void *pArg) { int status; CACLIENTPUTNOTIFY *ppnb; - struct ca_static *pcas; + struct CA_STATIC *pcas; struct event_handler_args args; pcas = pArg; diff --git a/src/ca/windows_depen.c b/src/ca/windows_depen.c index 3c535e390..6ac24a22d 100644 --- a/src/ca/windows_depen.c +++ b/src/ca/windows_depen.c @@ -32,6 +32,9 @@ * Modification Log: * ----------------- * $Log$ + * Revision 1.27 1997/05/01 19:46:32 jhill + * fixed unintialized variable bug + * * Revision 1.26 1997/04/11 20:36:00 jhill * kay's perl branch * @@ -147,7 +150,7 @@ void cac_block_for_sg_completion(CASG *pcasg, struct timeval *pTV) /* * cac_os_depen_init() */ -int cac_os_depen_init(struct ca_static *pcas) +int cac_os_depen_init(struct CA_STATIC *pcas) { int status; @@ -164,7 +167,7 @@ int cac_os_depen_init(struct ca_static *pcas) /* * cac_os_depen_exit () */ -void cac_os_depen_exit (struct ca_static *pcas) +void cac_os_depen_exit (struct CA_STATIC *pcas) { ca_static = pcas; ca_process_exit(); diff --git a/src/include/cadef.h b/src/include/cadef.h index 91ea33eff..e7fd340f8 100644 --- a/src/include/cadef.h +++ b/src/include/cadef.h @@ -190,22 +190,25 @@ typedef void caArh(struct access_rights_handler_args args); typedef void caArh(); #endif /*CAC_ANSI_FUNC_PROTO*/ +/* + * The fields in this structure may change or even vanish in the future. + * Please use the macros above to access the information in this structure. + */ struct channel_in_use{ - ELLNODE node; /* list ptrs */ - short type; /* database field type */ -#define TYPENOTCONN (-1) /* the type when disconnected */ - unsigned short count; /* array element count */ + ELLNODE node; /* list ptrs */ + short type; /* database field type */ +#define TYPENOTCONN (-1) /* the type when disconnected */ + unsigned short count; /* array element count */ union{ - unsigned sid; /* server id */ - struct dbAddr *paddr; /* database address */ + unsigned sid; /* server id */ + struct dbAddr *paddr; /* database address */ } id; - const void *puser; /* user available area */ - enum channel_state state; /* connected/ disconnected etc */ - caar ar; /* access rights */ + const void *puser; /* user available area */ + short state; /* connected/ disconnected etc */ + unsigned short retrySeqNo; /* search retry seq number */ + caar ar; /* access rights */ + - /* - * The following fields may change or even vanish in the future - */ caCh *pConnFunc; caArh *pAccessRightsFunc; ELLLIST eventq;