diff --git a/src/ca/access.c b/src/ca/access.c index ed8aa76ea..b61fe773e 100644 --- a/src/ca/access.c +++ b/src/ca/access.c @@ -99,6 +99,9 @@ /************************************************************************/ /* * $Log$ + * Revision 1.96 1997/06/13 16:57:38 jhill + * fixed warning + * * Revision 1.95 1997/06/13 09:14:06 jhill * connect/search proto changes * @@ -288,7 +291,7 @@ db_field_log *pfl LOCAL void ca_put_notify_action(PUTNOTIFY *ppn); #endif LOCAL void ca_pend_io_cleanup(); -LOCAL void create_udp_fd(); + static int issue_ca_array_put ( unsigned cmd, @@ -411,7 +414,7 @@ const void *pext return ECA_BADCHID; } - LD_CA_TIME (SELECT_POLL, &itimeout); + LD_CA_TIME (cac_fetch_poll_period(), &itimeout); cac_mux_io (&itimeout); LOCK; @@ -760,7 +763,7 @@ int ca_os_independent_init (void) /* * create_udp_fd */ -LOCAL void create_udp_fd() +void cac_create_udp_fd() { int status; @@ -1116,7 +1119,7 @@ int epicsShareAPI ca_search_and_connect #endif if (!ca_static->ca_piiuCast) { - create_udp_fd(); + cac_create_udp_fd(); if(!ca_static->ca_piiuCast){ return ECA_NOCAST; } @@ -2779,18 +2782,6 @@ int epicsShareAPI ca_pend (ca_real timeout, int early) INITCHK; - /* - * select() under WIN32 gives us grief - * if we delay with out interest in at - * least one fd - */ - if (!ca_static->ca_piiuCast) { - create_udp_fd(); - if(!ca_static->ca_piiuCast){ - return ECA_NOCAST; - } - } - if(EVENTLOCKTEST){ return ECA_EVDISALLOW; } @@ -2808,7 +2799,7 @@ int epicsShareAPI ca_pend (ca_real timeout, int early) /* * force the flush */ - LD_CA_TIME (0.0, &tmo); + CLR_CA_TIME (&tmo); cac_mux_io(&tmo); return ECA_NORMAL; } @@ -2817,7 +2808,7 @@ int epicsShareAPI ca_pend (ca_real timeout, int early) /* * force the flush */ - LD_CA_TIME (0.0, &tmo); + CLR_CA_TIME (&tmo); cac_mux_io(&tmo); return ECA_TIMEOUT; } @@ -2831,20 +2822,20 @@ int epicsShareAPI ca_pend (ca_real timeout, int early) /* * force the flush */ - LD_CA_TIME (0.0, &tmo); + CLR_CA_TIME (&tmo); cac_mux_io(&tmo); return ECA_NORMAL; } if(timeout == 0.0){ - remaining = SELECT_POLL; + remaining = cac_fetch_poll_period(); } else{ remaining = timeout-delay; /* * Allow for CA background labor */ - remaining = min(SELECT_POLL, remaining); + remaining = min(cac_fetch_poll_period(), remaining); } @@ -2875,7 +2866,7 @@ int epicsShareAPI ca_pend (ca_real timeout, int early) /* * force the flush */ - LD_CA_TIME (0.0, &tmo); + CLR_CA_TIME (&tmo); cac_block_for_io_completion (&tmo); return ECA_TIMEOUT; } @@ -2890,6 +2881,22 @@ int epicsShareAPI ca_pend (ca_real timeout, int early) } } +/* + * cac_fetch_poll_period() + */ +double cac_fetch_poll_period(void) +{ + if (!piiuCast) { + return SELECT_POLL_NO_SEARCH; + } + else if (ellCount(&piiuCast->chidlist)==0) { + return SELECT_POLL_NO_SEARCH; + } + else { + return SELECT_POLL_SEARCH; + } +} + /* * cac_time_diff() @@ -3014,7 +3021,7 @@ int epicsShareAPI ca_flush_io() * while performing socket io and processing recv backlog */ ca_static->ca_flush_pending = TRUE; - LD_CA_TIME (0.0, &timeout); + CLR_CA_TIME (&timeout); cac_mux_io (&timeout); return ECA_NORMAL; diff --git a/src/ca/acctst.c b/src/ca/acctst.c index 25744f814..92ba15c86 100644 --- a/src/ca/acctst.c +++ b/src/ca/acctst.c @@ -7,6 +7,9 @@ static char *sccsId = "@(#) $Id$"; /* * $Log$ + * Revision 1.47 1997/06/25 06:12:13 jhill + * fixed warnings + * * Revision 1.46 1997/06/13 09:14:09 jhill * connect/search proto changes * @@ -355,8 +358,13 @@ int doacctst(char *pname) if (ca_state(chix1)==cs_never_conn) { status = ca_pend_io(1e-16); if (status==ECA_TIMEOUT) { + /* + * under vxWorks another thread may connect the + * channel before this gets a chance to run + */ +#ifndef vxWorks assert(ca_state(chix1)==cs_never_conn); - +#endif printf("waiting on pend io verify connect..."); fflush(stdout); while (ca_state(chix1)!=cs_conn) { @@ -371,7 +379,13 @@ int doacctst(char *pname) SEVCHK(status, NULL); status = ca_pend_io(1e-16); if (status==ECA_TIMEOUT) { + /* + * under vxWorks another thread may connect the + * channel before this gets a chance to run + */ +#ifndef vxWorks assert(ca_state(chix2)==cs_never_conn); +#endif } else { assert(ca_state(chix2)==cs_conn); diff --git a/src/ca/iocinf.c b/src/ca/iocinf.c index e37bfcca5..6623abde3 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.71 1997/06/13 09:14:19 jhill + * connect/search proto changes + * * Revision 1.70 1997/05/05 04:44:39 jhill * socket buf matches CA buf size, and pushPending flag added * @@ -1926,7 +1929,7 @@ void cac_mux_io(struct timeval *ptimeout) * (this results in improved max throughput) */ while (TRUE) { - LD_CA_TIME (0.0, &timeout); + CLR_CA_TIME (&timeout); /* * NOTE cac_select_io() will set the * send flag for a particular iiu irregradless @@ -1960,7 +1963,7 @@ void cac_mux_io(struct timeval *ptimeout) } else { if (caSendMsgPending()) { - LD_CA_TIME (SELECT_POLL, &timeout); + LD_CA_TIME (cac_fetch_poll_period(), &timeout); } else { ca_static->ca_flush_pending = FALSE; @@ -1973,7 +1976,7 @@ void cac_mux_io(struct timeval *ptimeout) } } else { - LD_CA_TIME (0.0, &timeout); + CLR_CA_TIME (&timeout); } ca_process_input_queue(); } diff --git a/src/ca/iocinf.h b/src/ca/iocinf.h index 1374fa516..ea3fd610e 100644 --- a/src/ca/iocinf.h +++ b/src/ca/iocinf.h @@ -32,6 +32,9 @@ /************************************************************************/ /* $Log$ + * Revision 1.64 1997/06/13 09:14:21 jhill + * connect/search proto changes + * * Revision 1.63 1997/05/05 04:45:25 jhill * send_needed => pushPending, and added ca_number_iiu_in_fc * @@ -268,6 +271,8 @@ typedef struct timeval ca_time; ((PCATIME)->tv_sec = (long) (FLOAT_TIME), \ (PCATIME)->tv_usec = (long) ( ((FLOAT_TIME)-(PCATIME)->tv_sec)*USEC_PER_SEC )) +#define CLR_CA_TIME(PCATIME) ((PCATIME)->tv_sec = 0l,(PCATIME)->tv_usec = 0l) + /* * these control the duration and period of name resolution * broadcasts @@ -283,10 +288,25 @@ typedef struct timeval ca_time; /* * NOTE: These must be larger than one vxWorks tick or we will end up - * using the CPU. A vxWorks tick is usually 1/60th of a sec. + * using the CPU. A vxWorks tick is usually 1/60th of a sec. The + * vxWorks implementation of select is not efficient. + * select() with no delay takes (on a hk nitro 060): + * 17uS (no fd) + * 56uS (one UDP read fd) + * 80uS (two UDP read fd) + * 113uS (one UDP read/write fd) + * 185uS (two UDP read/write fd) + * 3 uS are required to call FD_ZERO (&readMask) + * and FD_ZERO (&writeMask) + * 4 uS required to call cac_gettimeval() */ -#define SELECT_POLL (0.025) /* units sec - polls into recast */ -#define CA_RECAST_DELAY (0.025) /* initial delay to next recast (sec) */ +#ifdef vxWorks +#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 */ +#endif +#define SELECT_POLL_NO_SEARCH (0.5) /* units sec - polls for conn heartbeat */ +#define CA_RECAST_DELAY SELECT_POLL_SEARCH /* 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) */ @@ -717,6 +737,8 @@ void retryPendingClaims(IIU *piiu); void cacSetRetryInterval(unsigned retryNo); void addToChanList(ciu chan, IIU *piiu); void removeFromChanList(ciu chan); +void cac_create_udp_fd(); +double cac_fetch_poll_period(void); /* * !!KLUDGE!! diff --git a/src/ca/syncgrp.c b/src/ca/syncgrp.c index 4891830d3..56c593041 100644 --- a/src/ca/syncgrp.c +++ b/src/ca/syncgrp.c @@ -29,6 +29,9 @@ * Modification Log: * ----------------- * $Log$ + * Revision 1.24 1997/06/13 09:14:26 jhill + * connect/search proto changes + * * Revision 1.23 1997/04/29 06:12:42 jhill * use free lists * @@ -309,7 +312,7 @@ int epicsShareAPI ca_sg_block(const CA_SYNC_GID gid, ca_real timeout) /* * Allow for CA background labor */ - remaining = min(SELECT_POLL, remaining); + remaining = min(cac_fetch_poll_period(), remaining); /* * wait for asynch notification diff --git a/src/ca/vxWorks_depen.c b/src/ca/vxWorks_depen.c index d88cde6aa..d6bfd1b58 100644 --- a/src/ca/vxWorks_depen.c +++ b/src/ca/vxWorks_depen.c @@ -29,6 +29,9 @@ * Modification Log: * ----------------- * $Log$ + * Revision 1.31 1997/06/13 09:14:28 jhill + * connect/search proto changes + * * Revision 1.30 1997/04/29 06:13:49 jhill * use free lists * @@ -932,7 +935,7 @@ void cac_recv_task(int tid) * 2) we queue up sends resulting from recvs properly */ while (TRUE) { - LD_CA_TIME (0.0, &timeout); + CLR_CA_TIME (&timeout); count = cac_select_io(&timeout, CA_DO_RECVS); if (count<=0) { break; diff --git a/src/ca/windows_depen.c b/src/ca/windows_depen.c index 6ac24a22d..fd2da5df0 100644 --- a/src/ca/windows_depen.c +++ b/src/ca/windows_depen.c @@ -32,6 +32,9 @@ * Modification Log: * ----------------- * $Log$ + * Revision 1.28 1997/06/13 09:14:29 jhill + * connect/search proto changes + * * Revision 1.27 1997/05/01 19:46:32 jhill * fixed unintialized variable bug * @@ -159,8 +162,21 @@ int cac_os_depen_init(struct CA_STATIC *pcas) /* DllMain does most OS dependent init & cleanup */ status = ca_os_independent_init (); - - return status; + if (status!=ECA_NORMAL) { + return status; + } + /* + * select() under WIN32 gives us grief + * if we delay with out interest in at + * least one fd (so we create the UDP + * fd during init before it is used for + * the first time) + */ + cac_create_udp_fd(); + if(!ca_static->ca_piiuCast){ + return ECA_NOCAST; + } + return ECA_NORMAL; } @@ -492,7 +508,7 @@ BOOL epicsShareAPI DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved) #endif #endif /* init. winsock */ - if ((status = WSAStartup(MAKEWORD(2,0), &WsaData)) != 0) { + if ((status = WSAStartup(MAKEWORD(2,0), &WsaData)) != 0) { WSACleanup(); fprintf(stderr,"Cant init winsock \n"); return FALSE;