From 3959edb8bb868e44b8300ec3932c30748362a470 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Wed, 31 Jul 1991 16:50:27 +0000 Subject: [PATCH] *** empty log message *** --- src/ca/access.c | 35 ++++++++++++++++++++++------------- src/ca/iocinf.c | 26 +++++++++++++++++--------- src/ca/iocinf.h | 5 ++++- src/ca/os_depen.h | 10 ++++++++-- src/ca/service.c | 15 +++++++++++++-- src/rsrv/camsgtask.c | 18 +++++++----------- 6 files changed, 71 insertions(+), 38 deletions(-) diff --git a/src/ca/access.c b/src/ca/access.c index 6716906a9..fad5437bc 100644 --- a/src/ca/access.c +++ b/src/ca/access.c @@ -30,14 +30,17 @@ /* 060591 joh delinting */ /* 061391 joh RISC alignment in outgoing messages */ /* 070191 joh allways use memcpy in ca_put */ -/* 071291 joh added CLAIM_CIU message */ +/* 071291 joh added CLAIM_CIU message */ +/* 072391 joh added event locking for vxWorks */ +/* 072591 joh quick POLL in ca_pend_io() should return */ +/* ECA_NORMAL not ECA_TIMEOUT if pend count == 0 */ /* */ /*_begin */ /************************************************************************/ /* */ /* Title: IOC high level access routines */ -/* File: atcs:[ca]access.c */ -/* Environment: VMS, UNIX, VRTX */ +/* File: access.c */ +/* Environment: VMS, UNIX, vxWorks */ /* Equipment: VAX, SUN, VME */ /* */ /* */ @@ -50,8 +53,7 @@ /* Special comments */ /* ------- -------- */ /* Things that could be done to improve this code */ -/* 1) Check timeouts on ca_pend for values to large */ -/* 2) Allow them to recv channel A when channel B changes */ +/* 1) Allow them to recv channel A when channel B changes */ /* */ /************************************************************************/ /*_end */ @@ -249,6 +251,7 @@ ca_task_initialize ca_static->ca_tid = taskIdSelf(); FASTLOCKINIT(&client_lock); + FASTLOCKINIT(&event_lock); evuser = (void *) db_init_events(); if (!evuser) @@ -781,7 +784,9 @@ ca_build_and_connect args.chid = chix; args.op = CA_OP_CONN_UP; + LOCKEVENTS; (*chix->connection_func) (args); + UNLOCKEVENTS; } return ECA_NORMAL; } @@ -1648,6 +1653,7 @@ void *pfl; * I would like to tell um with the event handler but this would * not be upward compatible. so I run the exception handler. */ + LOCKEVENTS; if(status == ERROR){ if(ca_static->ca_exception_func){ struct exception_handler_args args; @@ -1664,13 +1670,15 @@ void *pfl; (*ca_static->ca_exception_func)(args); } } - else + else{ (*monix->usr_func)( monix->usr_arg, monix->chan, type, count, pval); + } + UNLOCKEVENTS; /* * @@ -1962,9 +1970,8 @@ int early; cac_send_msg(); UNLOCK; - if(pndrecvcnt<1) - if(early) - return ECA_NORMAL; + if(pndrecvcnt<1 && early) + return ECA_NORMAL; /* * quick exit if a poll @@ -1992,6 +1999,9 @@ int early; UNLOCK; } #endif + if(pndrecvcnt<1 && early) + return ECA_NORMAL; + return ECA_TIMEOUT; } @@ -2034,14 +2044,13 @@ int early; lib$signal(status); } #endif - if(pndrecvcnt<1) - if(early) - return ECA_NORMAL; - LOCK; manage_conn(TRUE); UNLOCK; + if(pndrecvcnt<1 && early) + return ECA_NORMAL; + if(timeout != 0.0){ if(timeout < time(NULL)-beg_time){ struct ioc_in_use *piiu; diff --git a/src/ca/iocinf.c b/src/ca/iocinf.c index 2e403e694..4ed98a463 100644 --- a/src/ca/iocinf.c +++ b/src/ca/iocinf.c @@ -123,6 +123,8 @@ void vms_recv_msg_ast(); /* * ALLOC_IOC() * + * allocate and initialize an IOC info block for unallocated IOC + * * LOCK should be on while in this routine */ alloc_ioc(pnet_addr, net_proto, iocix) @@ -203,8 +205,6 @@ client_channel_exists(chan) /* * CREATE_NET_CHANNEL() * - * allocate and initialize an IOC info block for unallocated IOC - * * LOCK should be on while in this routine */ create_net_chan(piiu) @@ -337,8 +337,6 @@ struct ioc_in_use *piiu; } #endif - - /* connect */ status = connect( sock, @@ -352,7 +350,6 @@ struct ioc_in_use *piiu; } return ECA_CONN; } - piiu->max_msg = MAX_TCP; /* @@ -420,7 +417,7 @@ struct ioc_in_use *piiu; ca_signal(ECA_INTERNAL,"alloc_ioc: ukn protocol\n"); } /* setup cac_send_msg(), recv_msg() buffers */ - if(!piiu->send) + if(!piiu->send){ if(! (piiu->send = (struct buffer *) malloc(sizeof(struct buffer))) ){ status = socket_close(sock); @@ -429,9 +426,11 @@ struct ioc_in_use *piiu; } return ECA_ALLOCMEM; } + } + piiu->send->stk = 0; - if(!piiu->recv) + if(!piiu->recv){ if(! (piiu->recv = (struct buffer *) malloc(sizeof(struct buffer))) ){ status = socket_close(sock); @@ -440,11 +439,15 @@ struct ioc_in_use *piiu; } return ECA_ALLOCMEM; } + } piiu->recv->stk = 0; piiu->conn_up = TRUE; - if(fd_register_func) + if(fd_register_func){ + LOCKEVENTS; (*fd_register_func)(fd_register_arg, sock, TRUE); + UNLOCKEVENTS; + } /* Set up recv thread for VMS */ @@ -1099,12 +1102,17 @@ struct ioc_in_use *piiu; if(chix->connection_func){ args.chid = chix; args.op = CA_OP_CONN_DOWN; + LOCKEVENTS; (*chix->connection_func)(args); + UNLOCKEVENTS; } } - if(fd_register_func) + if(fd_register_func){ + LOCKEVENTS; (*fd_register_func)(fd_register_arg, piiu->sock_chan, FALSE); + UNLOCKEVENTS; + } status = socket_close(piiu->sock_chan); if(status < 0){ diff --git a/src/ca/iocinf.h b/src/ca/iocinf.h index 2d2b548ca..7ffd9d3bd 100644 --- a/src/ca/iocinf.h +++ b/src/ca/iocinf.h @@ -12,6 +12,7 @@ /* .01 08xx87 joh Init Release */ /* .02 01xx90 joh fd_set in the UNIX version only */ /* .03 060691 joh Rearanged buffer struct for SPARC port */ +/* .04 072391 joh new lock prevents event preemption on vxWorks */ /* */ /*_begin */ /************************************************************************/ @@ -136,6 +137,7 @@ typedef unsigned long ca_time; #define io_done_flag (ca_static->ca_io_done_flag) #define evuser (ca_static->ca_evuser) #define client_lock (ca_static->ca_client_lock) +#define event_lock (ca_static->ca_event_lock) #define local_chidlist (ca_static->ca_local_chidlist) #define dbfree_ev_list (ca_static->ca_dbfree_ev_list) #define lcl_buff_list (ca_static->ca_lcl_buff_list) @@ -171,7 +173,8 @@ struct ca_static{ #ifdef vxWorks int ca_io_done_flag; void *ca_evuser; - FAST_LOCK ca_client_lock; + FAST_LOCK ca_client_lock; + FAST_LOCK ca_event_lock; /* dont allow events to preempt */ int ca_tid; LIST ca_local_chidlist; LIST ca_dbfree_ev_list; diff --git a/src/ca/os_depen.h b/src/ca/os_depen.h index 7530db235..781c39f93 100644 --- a/src/ca/os_depen.h +++ b/src/ca/os_depen.h @@ -32,16 +32,22 @@ astenblwas = sys$setast(FALSE); # define UNLOCK\ if(astenblwas == SS$_WASSET)sys$setast(TRUE);} +# define LOCKEVENTS +# define UNLOCKEVENTS #endif #ifdef vxWorks -# define LOCK FASTLOCK(&client_lock); -# define UNLOCK FASTUNLOCK(&client_lock); +# define LOCK FASTLOCK(&client_lock); +# define UNLOCK FASTUNLOCK(&client_lock); +# define LOCKEVENTS FASTLOCK(&event_lock); +# define UNLOCKEVENTS FASTUNLOCK(&event_lock); #endif #ifdef UNIX # define LOCK # define UNLOCK +# define LOCKEVENTS +# define UNLOCKEVENTS #endif #ifdef vxWorks diff --git a/src/ca/service.c b/src/ca/service.c index 967c56731..8327a1ce1 100644 --- a/src/ca/service.c +++ b/src/ca/service.c @@ -24,6 +24,7 @@ /* 071291 joh now claiming channel in use block over TCP so */ /* problems with duplicate port assigned to */ /* client after reboot go away */ +/* 072391 joh added event locking for vxWorks */ /* */ /*_begin */ /************************************************************************/ @@ -63,7 +64,9 @@ #include #include -void reconnect_channel(); +void reconnect_channel(); +void ca_request_event(); + #define BUFSTAT printf("expected %d left %d\n",msgcnt,*pbufcnt); @@ -162,7 +165,9 @@ post_msg(hdrptr, pbufcnt, pnet_addr, piiu) args.count = t_count; args.dbr = (void *) (hdrptr + 1); + LOCKEVENTS; (*monix->usr_func) (args); + UNLOCKEVENTS; } LOCK; lstDelete(&pend_read_list, monix); @@ -229,7 +234,9 @@ post_msg(hdrptr, pbufcnt, pnet_addr, piiu) args.dbr = (void *) (hdrptr + 1); /* call their handler */ + LOCKEVENTS; (*monix->usr_func) (args); + UNLOCKEVENTS; break; } @@ -494,7 +501,10 @@ post_msg(hdrptr, pbufcnt, pnet_addr, piiu) args.addr = (void *) (req->m_available); args.stat = ntohl((int) t_available); args.op = op; args.ctx = context; + + LOCKEVENTS; (*ca_static->ca_exception_func) (args); + UNLOCKEVENTS; break; } default: @@ -529,7 +539,6 @@ struct in_addr *pnet_addr; evid pevent; int status; - void ca_request_event(); LOCK; @@ -606,7 +615,9 @@ struct in_addr *pnet_addr; args.chid = chan; args.op = CA_OP_CONN_UP; + LOCKEVENTS; (*chan->connection_func)(args); + UNLOCKEVENTS; } else if(chan->state==cs_never_conn){ /* decrement the outstanding IO count */ diff --git a/src/rsrv/camsgtask.c b/src/rsrv/camsgtask.c index 4df5cd39c..90b6264b5 100644 --- a/src/rsrv/camsgtask.c +++ b/src/rsrv/camsgtask.c @@ -122,9 +122,9 @@ FAST int sock; return; } - if(MPDEBUG==2){ + if(MPDEBUG>0){ logMsg( "camsgtask: Recieved connection request\n"); - logMsg("from addr %x, udp port %x \n", + logMsg("from addr %x, port %x \n", client->addr.sin_addr, client->addr.sin_port); } @@ -171,12 +171,14 @@ FAST int sock; /* * normal conn lost conditions */ - if(anerrno == ECONNABORTED || anerrno == ECONNRESET){ - break; + if(MPDEBUG==0){ + if(anerrno==ECONNABORTED||anerrno==ECONNRESET){ + break; + } } logMsg("camsgtask: Exiting after msg recv error\n"); - printErrno(errnoGet(taskIdSelf())); + printErrno(anerrno); break; } @@ -227,12 +229,6 @@ FAST int sock; cas_send_msg(client, TRUE); } - /* - * dont hang around if there are no - * connections to process variables - */ - if (client->addrq.count == 0) - break; } free_client(client);