*** empty log message ***

This commit is contained in:
Jeff Hill
1991-11-04 17:20:53 +00:00
parent ea08949a7b
commit 97451d9aae
15 changed files with 351 additions and 227 deletions

View File

@@ -62,24 +62,27 @@
/************************************************************************/
/*_end */
/*
* allocate error message string array
* here so I can use sizeof
*/
#define CA_ERROR_GLBLSOURCE
#if defined(VMS)
# include stsdef.h
# include ssdef.h
# include psldef.h
# include prcdef.h
# include descrip.h
#elif defined(UNIX)
#elif defined(vxWorks)
# include <vxWorks.h>
# include <taskLib.h>
# include <task_params.h>
#else
@@@@ dont compile @@@@
#endif
/*
* allocate error message string array
* here so I can use sizeof
*/
#define CA_ERROR_GLBLSOURCE
/*
* allocate db_access message strings here
*/

View File

@@ -7,17 +7,16 @@
/* System includes */
#ifdef UNIX
#include <stdio.h>
#endif
#include <vxWorks.h>
#ifdef vxWorks
#include <taskLib.h>
#if defined(UNIX)
# include <stdio.h>
#elif defined(vxWorks)
# include <vxWorks.h>
# include <taskLib.h>
#endif
#include <cadef.h>
#include <db_access.h>
#include <os_depen.h>
/*

View File

@@ -24,11 +24,14 @@
/* */
/************************************************************************/
/*_end */
#ifdef UNIX
#include <stdio.h>
#if defined(UNIX)
# include <stdio.h>
#elif defined(VMS)
#elif defined(vxWorks)
#else
@@@@ dont compile @@@@
#endif
#include <vxWorks.h>
#include <cadef.h>
#include <db_access.h>
#include <iocmsg.h>
@@ -108,8 +111,8 @@ char silent;
#endif
if(!silent && retry_cnt_no_handler){
sprintf(string, "%d channels outstanding", retry_cnt);
ca_signal(ECA_CHIDRETRY, string);
sprintf(sprintf_buf, "%d channels outstanding", retry_cnt);
ca_signal(ECA_CHIDRETRY, sprintf_buf);
}
}

View File

@@ -34,13 +34,29 @@
/*_end */
#include <types.h>
#include <vxWorks.h>
#include <socket.h>
#include <ioctl.h>
#ifdef vxWorks
#include <ioLib.h>
#if defined(vxWorks)
# include <vxWorks.h>
# include <ioLib.h>
# include <socket.h>
# include <ioctl.h>
# ifdef V5_vxWorks
# include <vxTypes.h>
# else
# include <types.h>
# endif
#elif defined(VMS)
# include <sys/types.h>
# include <sys/socket.h>
# include <sys/ioctl.h>
#elif defined(UNIX)
# include <sys/types.h>
# include <sys/socket.h>
# include <sys/ioctl.h>
#else
@@@@ dont compile @@@@
#endif
#include <os_depen.h>
#include <cadef.h>
#include <iocmsg.h>
#include <iocinf.h>

View File

@@ -18,6 +18,12 @@
/* each message */
/* 071291 joh no longer sends id at TCP connect */
/* 082791 joh split send_msg() into two subroutines */
/* 110491 joh call recv_msg to free up deadlock only if */
/* client blocks on send as before */
/* 110491 joh mark all channels disconnected prior to */
/* calling the first connection handler on */
/* disconnect */
/* 110491 joh allow cac_send_msg() to be called recursively */
/* */
/*_begin */
/************************************************************************/
@@ -48,21 +54,23 @@
#if defined(VMS)
# include <iodef.h>
# include <inetiodef.h>
# include <stsdef.h>
# include <types.h>
# include <errno.h>
# include <socket.h>
# include <in.h>
# include <tcp.h>
# include <ioctl.h>
# include <sys/types.h>
# define __TIME /* dont include VMS CC time.h under MULTINET */
# include <sys/time.h>
# include <vms/inetiodef.h>
# include <tcp/errno.h>
# include <sys/socket.h>
# include <netinet/in.h>
# include <netinet/tcp.h>
# include <sys/ioctl.h>
#elif defined(UNIX)
# include <types.h>
# include <errno.h>
# include <socket.h>
# include <in.h>
# include <tcp.h>
# include <ioctl.h>
# include <sys/types.h>
# include <sys/errno.h>
# include <sys/socket.h>
# include <netinet/in.h>
# include <netinet/tcp.h>
# include <sys/ioctl.h>
#elif defined(vxWorks)
# include <vxWorks.h>
# ifdef V5_vxWorks
@@ -464,7 +472,7 @@ struct ioc_in_use *piiu;
/* Set up recv thread for VMS */
#ifdef VMS
# if defined(VMS)
{
/*
* request to be informed of future IO
@@ -487,8 +495,7 @@ struct ioc_in_use *piiu;
exit();
}
}
# endif
# ifdef vxWorks
# elif defined(vxWorks)
{
void recv_task();
int pri;
@@ -518,7 +525,7 @@ struct ioc_in_use *piiu;
piiu->recv_tid = status;
}
#endif
# endif
return ECA_NORMAL;
}
@@ -582,12 +589,14 @@ void cac_send_msg()
if(!ca_static->ca_repeater_contacted)
notify_ca_repeater();
#if 0
/*
* dont call it recursively
*/
if(send_msg_active){
return;
}
#endif
send_msg_active++;
@@ -596,8 +605,10 @@ void cac_send_msg()
*
*/
while(TRUE){
done = TRUE;
for(piiu=iiu;piiu<&iiu[nxtiiu];piiu++){
for(piiu=iiu; piiu<&iiu[nxtiiu]; piiu++){
if(!piiu->send->stk)
continue;
@@ -615,7 +626,7 @@ void cac_send_msg()
if(done){
/*
* allways double check that we
* are finished incase somthing was added
* are finished in case somthing was added
* to a send buffer and a recursive
* ca_send_msg() call was refused above
*/
@@ -628,17 +639,6 @@ void cac_send_msg()
break;
}
/*
* Ensure we do not accumulate extra recv
* messages (for TCP)
*/
/*
* free up push pull deadlock only
* if recv not already in progress
*/
if(post_msg_active==0)
recv_msg_select(&notimeout);
if(retry_count-- <= 0){
char *iocname;
struct in_addr *inaddr;
@@ -647,7 +647,6 @@ void cac_send_msg()
inaddr = &piiu->sock_addr.sin_addr;
iocname = host_from_addr(inaddr);
#ifdef CLOSE_ON_EXPIRED
ca_signal(ECA_DLCKREST, iocname);
close_ioc(piiu);
#else
@@ -685,24 +684,18 @@ register struct ioc_in_use *piiu;
pmsg = (void *) piiu->send->buf;
while(TRUE){
int sock;
if(piiu->conn_up){
/*
* send UDP or TCP message depending
* on whether this channel has a TCP
* connection yet
*
/*
* use TCP if connection exists
*/
status = sendto(
piiu->sock_chan,
pmsg,
cnt,
0,
&piiu->sock_addr,
sizeof(piiu->sock_addr));
sock = piiu->sock_chan;
}
else{
/*
* send UDP message
* use UDP
*
* NOTE: this does not use a broadcast
* if the location of the channel is
@@ -711,26 +704,30 @@ register struct ioc_in_use *piiu;
* (piiu->sock_addr points to the
* known address)
*/
status = sendto(
iiu[BROADCAST_IIU].sock_chan,
pmsg,
cnt,
0,
&piiu->sock_addr,
sizeof(piiu->sock_addr));
if(!iiu[BROADCAST_IIU].conn_up)
return ERROR;
sock = iiu[BROADCAST_IIU].sock_chan;
}
status = sendto(
sock,
pmsg,
cnt,
0,
&piiu->sock_addr,
sizeof(piiu->sock_addr));
/*
* normal fast exit
*/
if(status == cnt)
if(status == cnt){
break;
if(status>=0){
}
else if(status>=0){
if(status>cnt){
ca_signal(
ECA_INTERNAL,
"more sent than requested");
"more sent than requested ?");
}
cnt = cnt-status;
@@ -748,14 +745,25 @@ register struct ioc_in_use *piiu;
cnt);
piiu->send->stk = cnt;
}
/*
* Ensure we do not accumulate extra recv
* messages (for TCP)
*
* frees up push pull deadlock only
* if recv not already in progress
*/
if(post_msg_active==0)
recv_msg_select(&notimeout);
return ERROR;
}
#endif
else{
if(MYERRNO != EPIPE && MYERRNO != ECONNRESET)
printf(
"CA: error on socket send() %d\n",
MYERRNO);
if(MYERRNO != EPIPE && MYERRNO != ECONNRESET){
printf(
"CA: error on socket send() %d\n",
MYERRNO);
}
close_ioc(piiu);
return OK;
}
@@ -884,8 +892,7 @@ struct ioc_in_use *piiu;
void tcp_recv_msg(piiu)
struct ioc_in_use *piiu;
{
unsigned long byte_cnt;
unsigned long byte_sum;
long byte_cnt;
int status;
int timeoutcnt;
struct buffer *rcvb = piiu->recv;
@@ -926,9 +933,9 @@ struct ioc_in_use *piiu;
}
byte_cnt = (unsigned long) status;
byte_cnt = (long) status;
if(byte_cnt>MAX_MSG_SIZE){
printf( "recv_msg(): message overflow %u\n",
printf( "recv_msg(): message overflow %l\n",
byte_cnt-MAX_MSG_SIZE);
LOCK;
close_ioc(piiu);
@@ -945,7 +952,7 @@ struct ioc_in_use *piiu;
&byte_cnt,
&piiu->sock_addr.sin_addr,
piiu);
if(byte_cnt){
if(byte_cnt>0){
/*
* realign partial message
*/
@@ -985,8 +992,7 @@ struct ioc_in_use *piiu;
char *ptr;
unsigned nchars;
struct msglog{
unsigned nbytes;
unsigned RISC_pad;
long nbytes;
struct sockaddr_in addr;
};
struct msglog *pmsglog;
@@ -1024,7 +1030,7 @@ struct ioc_in_use *piiu;
* log the msg size
*/
rcvb->stk += status;
pmsglog->nbytes = (unsigned long) status;
pmsglog->nbytes = (long) status;
#ifdef DEBUG
printf("recieved a udp reply of %d bytes\n",byte_cnt);
#endif
@@ -1048,7 +1054,7 @@ struct ioc_in_use *piiu;
pmsglog = (struct msglog *) rcvb->buf;
while(pmsglog < (struct msglog *)&rcvb->buf[rcvb->stk]){
unsigned long msgcount;
long msgcount;
/* post message to the user */
msgcount = pmsglog->nbytes;
@@ -1056,7 +1062,7 @@ struct ioc_in_use *piiu;
&msgcount,
&pmsglog->addr.sin_addr,
piiu);
if(msgcount){
if(msgcount != 0){
printf( "CA: UDP alignment problem %d\n",
msgcount);
}
@@ -1203,12 +1209,25 @@ struct ioc_in_use *piiu;
FD_CLR(piiu->sock_chan, &readch);
# endif
/*
* Mark all of their channels disconnected
* prior to calling handlers incase the
* handler tries to use a channel before
* I mark it disconnected.
*/
chix = (chid) &piiu->chidlist.node.next;
while(chix = (chid) chix->node.next){
chix->type = TYPENOTCONN;
chix->count = 0;
chix->state = cs_prev_conn;
chix->paddr = NULL;
}
/*
* call their connection handler as required
*/
chix = (chid) &piiu->chidlist.node.next;
while(chix = (chid) chix->node.next){
if(chix->connection_func){
args.chid = chix;
args.op = CA_OP_CONN_DOWN;
@@ -1234,6 +1253,9 @@ struct ioc_in_use *piiu;
ECA_DISCONN,
host_from_addr(&piiu->sock_addr.sin_addr));
if(piiu == &iiu[BROADCAST_IIU]){
ca_signal(ECA_INTERNAL, "Unable to perform UDP broadcast\n");
}
}

View File

@@ -16,6 +16,7 @@
/* .05 082791 joh declaration of ca_request_event() */
/* .06 082791 joh added send message in progress flag */
/* .07 091691 joh moved channel_state enum to cadef.h for export */
/* .08 102991 joh added sprintf buffer */
/* */
/*_begin */
/************************************************************************/
@@ -41,30 +42,34 @@
#ifndef INCiocinfh
#define INCiocinfh
#define DONT_COMPILE @@@@ dont compile in this case @@@@
#if defined(UNIX)
# include <sys/types.h>
# include <netinet/in.h>
#elif defined(VMS)
# include <ssdef>
# include <sys/types.h>
# include <netinet/in.h>
#elif defined(vxWorks)
# ifdef V5_vxWorks
# include <vxTypes.h>
# else
# include <types.h>
# endif
# include <in.h>
#else
DONT_COMPILE
#endif
#ifndef INClstLibh
# include <lstLib.h>
#endif
#ifndef _TYPES_
# include <types.h>
#endif
#ifndef __IN_HEADER__
# include <in.h>
#endif
#ifdef VMS
# include <ssdef>
#endif
#ifndef INCos_depenh
# include <os_depen.h>
#endif
#define DONT_COMPILE @@@@ dont compile in this case @@@@
/* throw out requests prior to last ECA_TIMEOUT from ca_pend */
#define VALID_MSG(PIIU) (piiu->read_seq == piiu->cur_read_seq)
@@ -133,6 +138,7 @@ typedef unsigned long ca_time;
#define fd_register_arg (ca_static->ca_fd_register_arg)
#define post_msg_active (ca_static->ca_post_msg_active)
#define send_msg_active (ca_static->ca_send_msg_active)
#define sprintf_buf (ca_static->ca_sprintf_buf)
#if defined(UNIX)
# define readch (ca_static->ca_readch)
@@ -172,6 +178,7 @@ struct ca_static{
unsigned short ca_send_msg_active;
short ca_cast_available;
struct in_addr ca_castaddr;
char ca_sprintf_buf[128];
#if defined(UNIX)
fd_set ca_readch;
#elif defined(VMS)

View File

@@ -25,6 +25,9 @@
# include <sys/time.h>
# endif
#elif defined(vxWorks)
# ifndef INCvxWorksh
# include <vxWorks.h>
# endif
# ifndef INCfast_lockh
# include <fast_lock.h>
# endif

View File

@@ -49,18 +49,31 @@
*
*/
#include <vxWorks.h>
#include <lstLib.h>
#ifdef VMS
#include <stsdef.h>
#if defined(VMS)
# include <stsdef.h>
# include <errno.h>
# include <sys/types.h>
# include <sys/socket.h>
# include <netinet/in.h>
# include <sys/ioctl.h>
#elif defined(UNIX)
# include <errno.h>
# include <sys/types.h>
# include <sys/socket.h>
# include <netinet/in.h>
# include <sys/ioctl.h>
#elif defined(vxWorks)
# include <vxWorks.h>
# include <errno.h>
# include <types.h>
# include <socket.h>
# include <in.h>
# include <ioctl.h>
#else
@@@@ dont compile @@@@
#endif
#include <errno.h>
#include <types.h>
#include <socket.h>
#include <in.h>
#include <ioctl.h>
#include <lstLib.h>
#include <iocmsg.h>
#include <os_depen.h>

View File

@@ -25,6 +25,7 @@
/* problems with duplicate port assigned to */
/* client after reboot go away */
/* 072391 joh added event locking for vxWorks */
/* 100391 joh added missing ntohs() for the VAX */
/* */
/*_begin */
/************************************************************************/
@@ -47,25 +48,32 @@
/************************************************************************/
/*_end */
#ifdef VMS
#include <stsdef.h>
#if defined(VMS)
# include <sys/types.h>
# include <stsdef.h>
#elif defined(UNIX)
# include <sys/types.h>
# include <stdio.h>
#elif defined(vxWorks)
# include <vxWorks.h>
# ifdef V5_vxWorks
# include <vxTypes.h>
# else
# include <types.h>
# endif
#else
@@@@ dont compile @@@@
#endif
#ifdef UNIX
#include <stdio.h>
#endif
#include <os_depen.h>
#include <cadef.h>
#include <net_convert.h>
#include <db_access.h>
#include <iocmsg.h>
#include <iocinf.h>
#include <vxWorks.h>
#include <types.h>
#include <cadef.h>
#include <net_convert.h>
#include <db_access.h>
#include <iocmsg.h>
#include <iocinf.h>
void reconnect_channel();
void ca_request_event();
void reconnect_channel();
void ca_request_event();
#define BUFSTAT printf("expected %d left %d\n",msgcnt,*pbufcnt);
@@ -79,10 +87,10 @@ void ca_request_event();
*/
void
post_msg(hdrptr, pbufcnt, pnet_addr, piiu)
register struct extmsg *hdrptr;
register unsigned long *pbufcnt;
struct in_addr *pnet_addr;
struct ioc_in_use *piiu;
register struct extmsg *hdrptr;
register long *pbufcnt;
struct in_addr *pnet_addr;
struct ioc_in_use *piiu;
{
evid monix;
long msgcnt;
@@ -246,6 +254,16 @@ post_msg(hdrptr, pbufcnt, pnet_addr, piiu)
chid chan = (chid) hdrptr->m_pciu;
unsigned size;
/*
* ignore IOC_READ_BUILDS after
* connection occurs
*/
if(t_cmmd == IOC_READ_BUILD){
if(chan->state == cs_conn){
break;
}
}
/*
* only count get returns if from the current
* read seq
@@ -294,21 +312,21 @@ post_msg(hdrptr, pbufcnt, pnet_addr, piiu)
/*
* ignore broadcast replies for deleted channels
*
* lock required for client_channel_exists()
* lock required around use of the sprintf buffer
*/
LOCK;
status = client_channel_exists(chan);
UNLOCK;
if (!status) {
char msg[64];
sprintf(
msg,
"Search reply from %s",
sprintf_buf,
"Chid %x Search reply from %s",
chan,
host_from_addr(pnet_addr));
ca_signal(ECA_NOCHANMSG,msg);
ca_signal(ECA_NOCHANMSG, sprintf_buf);
break;
}
UNLOCK;
chpiiu = &iiu[chan->iocix];
@@ -317,13 +335,12 @@ post_msg(hdrptr, pbufcnt, pnet_addr, piiu)
if (chpiiu->sock_addr.sin_addr.s_addr ==
pnet_addr->s_addr) {
printf("<Extra> ");
#ifdef UNIX
fflush(stdout);
#endif
# ifdef UNIX
fflush(stdout);
# endif
} else {
char msg[256];
char acc[64];
char rej[64];
char acc[128];
char rej[128];
sprintf(acc,
"%s",
@@ -332,26 +349,29 @@ post_msg(hdrptr, pbufcnt, pnet_addr, piiu)
sprintf(rej,
"%s",
host_from_addr(pnet_addr));
LOCK;
sprintf(
msg,
sprintf_buf,
"Channel: %s Accepted: %s Rejected: %s ",
chan + 1,
acc,
rej);
ca_signal(ECA_DBLCHNL, msg);
ca_signal(ECA_DBLCHNL, sprintf_buf);
UNLOCK;
}
# ifdef IOC_READ_FOLLOWING_BUILD
/*
* IOC_BUILD messages allways have a
* IOC_BUILD messages always have a
* IOC_READ msg following. (IOC_BUILD
* messages are sometimes followed by
* error messages which are ignored
* on double replies)
*/
if (t_cmmd == IOC_BUILD)
if (t_cmmd == IOC_BUILD){
msgcnt += sizeof(struct extmsg) +
(hdrptr + 1)->m_postsize;
ntohs((hdrptr + 1)->m_postsize);
}
# endif
break;
}
reconnect_channel(hdrptr, pnet_addr);

View File

@@ -37,6 +37,7 @@
* .05 joh 082691 use db_post_single_event() instead of read_reply()
* to avoid deadlock condition between the client
* and the server.
* .06 joh 110491 lock added for IOC_CLAIM_CIU command
*/
#include <vxWorks.h>
@@ -66,7 +67,7 @@ void search_fail_reply();
/*
* CAMESSSAGE()
* CAMESSAGE()
*
*
*/
@@ -119,13 +120,13 @@ camessage(client, recv)
pevext =
(struct event_ext *) malloc(size);
if (!pevext) {
LOCK_SEND(client);
LOCK_CLIENT(client);
send_err(
mp,
ECA_ALLOCMEM,
client,
RECORD_NAME(MPTOPADDR(mp)));
UNLOCK_SEND(client);
UNLOCK_CLIENT(client);
break;
}
}
@@ -148,13 +149,13 @@ camessage(client, recv)
(unsigned) ((struct monops *) mp)->m_info.m_mask,
pevext + 1);
if (status == ERROR) {
LOCK_SEND(client);
LOCK_CLIENT(client);
send_err(
mp,
ECA_ADDFAIL,
client,
RECORD_NAME(MPTOPADDR(mp)));
UNLOCK_SEND(client);
UNLOCK_CLIENT(client);
}
/*
@@ -235,22 +236,24 @@ camessage(client, recv)
mp->m_count
);
if (status < 0) {
LOCK_SEND(client);
LOCK_CLIENT(client);
send_err(
mp,
ECA_PUTFAIL,
client,
RECORD_NAME(MPTOPADDR(mp)));
UNLOCK_SEND(client);
UNLOCK_CLIENT(client);
}
break;
case IOC_EVENTS_ON:
{
struct event_ext evext;
struct channel_in_use *pciu =
(struct channel_in_use *) & client->addrq;
client->eventsoff = FALSE;
LOCK_CLIENT(client);
while (pciu = (struct channel_in_use *)
pciu->node.next) {
@@ -260,8 +263,10 @@ camessage(client, recv)
pevext->node.next){
if (pevext->modified) {
evext = *pevext;
evext.send_lock = FALSE;
read_reply(
pevext,
&evext,
MPTOPADDR(&pevext->msg),
TRUE,
NULL);
@@ -269,6 +274,7 @@ camessage(client, recv)
}
}
}
UNLOCK_CLIENT(client);
break;
}
case IOC_EVENTS_OFF:
@@ -290,26 +296,31 @@ camessage(client, recv)
* channel in use block prior to
* timeout must reconnect
*/
LOCK_CLIENT(prsrv_cast_client);
status = lstFind(
&prsrv_cast_client->addrq,
mp->m_pciu);
if(status<0){
if(status >= 0){
lstDelete(
&prsrv_cast_client->addrq,
mp->m_pciu);
}
UNLOCK_CLIENT(prsrv_cast_client);
if(status < 0){
free_client(client);
logMsg("cas: client timeout disconnect\n");
exit();
}
lstDelete(
&prsrv_cast_client->addrq,
mp->m_pciu);
LOCK_CLIENT(client);
lstAdd(&client->addrq, mp->m_pciu);
UNLOCK_CLIENT(client);
break;
default:
log_header(mp, nmsg);
LOCK_SEND(client);
LOCK_CLIENT(client);
send_err(mp, ECA_INTERNAL, client, "Invalid Msg");
UNLOCK_SEND(client);
UNLOCK_CLIENT(client);
return ERROR;
}
recv->stk += msgsize;
@@ -354,18 +365,18 @@ struct client *client;
/*
* send delete confirmed message
*/
LOCK_SEND(client);
LOCK_CLIENT(client);
reply = (struct extmsg *) ALLOC_MSG(client, 0);
if (!reply) {
UNLOCK_SEND(client);
UNLOCK_CLIENT(client);
taskSuspend(0);
}
*reply = *mp;
END_MSG(client);
UNLOCK_SEND(client);
lstDelete(&client->addrq, pciu);
UNLOCK_CLIENT(client);
FASTLOCK(&rsrv_free_addrq_lck);
lstAdd(&rsrv_free_addrq, pciu);
FASTUNLOCK(&rsrv_free_addrq_lck);
@@ -408,17 +419,17 @@ event_cancel_reply(mp, client)
/*
* send delete confirmed message
*/
LOCK_SEND(client);
LOCK_CLIENT(client);
reply = (struct extmsg *) ALLOC_MSG(client, 0);
if (!reply) {
UNLOCK_SEND(client);
UNLOCK_CLIENT(client);
taskSuspend(0);
}
*reply = pevext->msg;
reply->m_postsize = 0;
END_MSG(client);
UNLOCK_SEND(client);
UNLOCK_CLIENT(client);
FASTLOCK(&rsrv_free_eventq_lck);
lstAdd(&rsrv_free_eventq, pevext);
@@ -429,9 +440,9 @@ event_cancel_reply(mp, client)
/*
* Not Found- return an error message
*/
LOCK_SEND(client);
LOCK_CLIENT(client);
send_err(mp, ECA_BADMONID, client, NULL);
UNLOCK_SEND(client);
UNLOCK_CLIENT(client);
return;
}
@@ -465,13 +476,13 @@ void *pfl;
return;
}
if (pevext->send_lock)
LOCK_SEND(client);
LOCK_CLIENT(client);
reply = (struct extmsg *) ALLOC_MSG(client, pevext->size);
if (!reply) {
send_err(mp, ECA_TOLARGE, client, RECORD_NAME(paddr));
if (pevext->send_lock)
UNLOCK_SEND(client);
UNLOCK_CLIENT(client);
return;
}
*reply = *mp;
@@ -508,7 +519,7 @@ void *pfl;
}
if (pevext->send_lock)
UNLOCK_SEND(client);
UNLOCK_CLIENT(client);
return;
}
@@ -527,7 +538,7 @@ read_sync_reply(mp, client)
{
FAST struct extmsg *reply;
LOCK_SEND(client);
LOCK_CLIENT(client);
reply = (struct extmsg *) ALLOC_MSG(client, 0);
if (!reply)
taskSuspend(0);
@@ -536,7 +547,7 @@ read_sync_reply(mp, client)
END_MSG(client);
UNLOCK_SEND(client);
UNLOCK_CLIENT(client);
return;
}
@@ -582,34 +593,43 @@ build_reply(mp, client)
if (!pchannel) {
pchannel = (struct channel_in_use *) calloc(1, sizeof(*pchannel));
if (!pchannel) {
LOCK_SEND(client);
LOCK_CLIENT(client);
send_err(mp, ECA_ALLOCMEM, client, RECORD_NAME(&tmp_addr));
UNLOCK_SEND(client);
UNLOCK_CLIENT(client);
return;
}
}
pchannel->ticks_at_creation = tickGet();
pchannel->addr = tmp_addr;
pchannel->chid = (void *) mp->m_pciu;
/* store the addr block in a Q so it can be deallocated */
lstAdd(addrq, pchannel);
/*
* ALLOC_MSG allways allocs at least the sizeof extmsg Large
* requested size insures both messages sent in one reply NOTE: my
* UDP reliability schemes rely on both msgs in same reply Therefore
* the send buffer locked while both messages are placed
*/
LOCK_SEND(client);
LOCK_CLIENT(client);
/* store the addr block in a Q so it can be deallocated */
lstAdd(addrq, pchannel);
if (mp->m_cmmd == IOC_BUILD) {
FAST short type = (mp + 1)->m_type;
FAST unsigned int count = (mp + 1)->m_count;
FAST unsigned int size;
size = (count - 1) * dbr_value_size[type] + dbr_size[type];
/*
* must be large enough to hold both the search and the build-get
* reply in one UDP message. Hence the extra sizeof(*mp) added
* in below.
*/
size = sizeof(*mp) + /* search reply hdr size */
sizeof(*mp) + /* build get reply hdr size */
(count - 1) * /* size of n-1 array elements */
dbr_value_size[type]
+ dbr_size[type]; /* size of the structure fetched */
get_reply = (struct extmsg *) ALLOC_MSG(client, size + sizeof(*mp));
get_reply = (struct extmsg *) ALLOC_MSG(client, size);
if (!get_reply) {
/* tell them that their request is to large */
send_err(mp, ECA_TOLARGE, client, RECORD_NAME(&tmp_addr));
@@ -631,6 +651,12 @@ build_reply(mp, client)
* is not flushed once each call.
*/
read_reply(&evext, &tmp_addr, TRUE, NULL);
/*
* this allows extra build replies
* to be dicarded
*/
get_reply->m_cmmd = IOC_READ_BUILD;
}
}
search_reply = (struct extmsg *) ALLOC_MSG(client, 0);
@@ -646,7 +672,7 @@ build_reply(mp, client)
search_reply->m_pciu = (void *) pchannel;
END_MSG(client);
UNLOCK_SEND(client);
UNLOCK_CLIENT(client);
return;
}
@@ -666,7 +692,7 @@ search_fail_reply(mp, client)
{
FAST struct extmsg *reply;
LOCK_SEND(client);
LOCK_CLIENT(client);
reply = (struct extmsg *) ALLOC_MSG(client, 0);
if (!reply) {
taskSuspend(0);
@@ -676,7 +702,7 @@ search_fail_reply(mp, client)
reply->m_postsize = 0;
END_MSG(client);
UNLOCK_SEND(client);
UNLOCK_CLIENT(client);
}

View File

@@ -104,12 +104,12 @@ FAST int sock;
* historical reasons
*/
client = (struct client *) create_udp_client(NULL);
udp_to_tcp(client, sock);
if (!client) {
logMsg("camsgtask: client init failed\n");
close(sock);
return;
}
udp_to_tcp(client, sock);
i = sizeof(client->addr);
status = getpeername(
@@ -118,7 +118,7 @@ FAST int sock;
&i);
if(status == ERROR){
logMsg("camsgtask: peer address fetch failed\n");
close(sock);
free_client(client);
return;
}
@@ -225,7 +225,7 @@ FAST int sock;
printErrno(errnoGet(taskIdSelf()));
cas_send_msg(client, TRUE);
}
if (nchars == 0){
else if (nchars == 0){
cas_send_msg(client, TRUE);
}

View File

@@ -30,6 +30,7 @@
* -----------------
* .01 joh 071591 log time of last io in the client structure
* .02 joh 091691 use greater than on the DEBUG level test
* .03 joh 110491 improved diagnostics
*/
#include <vxWorks.h>
@@ -54,12 +55,22 @@ int lock_needed;
{
int status;
if(CASDEBUG>2){
logMsg( "Sending a message of %d bytes\n",
pclient->send.cnt);
}
if(pclient->disconnect){
if(CASDEBUG>2){
logMsg( "msg Discard for sock %d addr %x\n",
pclient->sock,
pclient->addr.sin_addr.s_addr);
}
return;
}
if(lock_needed){
LOCK_SEND(pclient);
LOCK_CLIENT(pclient);
}
if(pclient->send.stk){
@@ -72,17 +83,14 @@ int lock_needed;
NULL,
&pclient->addr,
sizeof(pclient->addr));
if(status>=0){
if(CASDEBUG>2){
logMsg( "Sent a message of %d bytes\n",
pclient->send.cnt);
}
}
else{
if(status < 0){
logMsg("caserver: client unreachable\n");
logMsg("caserver: msg from vxWorks follows\n");
printErrno(errnoGet(taskIdSelf()));
pclient->disconnect = TRUE;
if(pclient==prsrv_cast_client){
taskSuspend(taskIdSelf());
}
}
pclient->send.stk = 0;
@@ -92,7 +100,7 @@ int lock_needed;
if(lock_needed){
UNLOCK_SEND(pclient);
UNLOCK_CLIENT(pclient);
}
return;

View File

@@ -33,6 +33,7 @@
* client_stat().
* .03 joh 080991 close the socket if task create fails
* .04 joh 090591 updated for v5 vxWorks
* .05 joh 103091 print task id and disconnect state in client_stat()
*/
#include <vxWorks.h>
@@ -272,7 +273,7 @@ struct client *client;
char *pproto;
unsigned long current;
unsigned long delay;
char *state[] = {"up", "down"};
if(client->proto == IPPROTO_UDP){
pproto = "UDP";
@@ -292,18 +293,20 @@ struct client *client;
delay = current + (~0L - client->ticks_at_last_io);
}
printf( "Socket %d, Protocol %s, secs since last interaction %d\n",
printf( "Socket=%d, Protocol=%s, tid=%x, secs since last interaction %d\n",
client->sock,
pproto,
client->tid,
delay/sysClkRateGet());
psaddr = &client->addr;
printf("\tRemote address %u.%u.%u.%u Remote port %d\n",
(psaddr->sin_addr.s_addr & 0xff000000) >> 24,
(psaddr->sin_addr.s_addr & 0x00ff0000) >> 16,
(psaddr->sin_addr.s_addr & 0x0000ff00) >> 8,
(psaddr->sin_addr.s_addr & 0x000000ff),
psaddr->sin_port);
printf("\tRemote address %u.%u.%u.%u Remote port %d state=%s\n",
(psaddr->sin_addr.s_addr & 0xff000000) >> 24,
(psaddr->sin_addr.s_addr & 0x00ff0000) >> 16,
(psaddr->sin_addr.s_addr & 0x0000ff00) >> 8,
(psaddr->sin_addr.s_addr & 0x000000ff),
psaddr->sin_port,
state[client->disconnect?1:0]);
printf("\tChannel count %d\n", lstCount(&client->addrq));
addr = (NODE *) & client->addrq;
while (addr = lstNext(addr))

View File

@@ -337,10 +337,10 @@ unsigned sock;
client->sock = sock;
client->send.maxstk = MAX_UDP-sizeof(client->recv.cnt);
FASTLOCKINIT(&client->send.lock);
FASTLOCKINIT(&client->lock);
client->recv.maxstk = MAX_UDP;
FASTLOCKINIT(&client->recv.lock);
return client;
}

View File

@@ -34,6 +34,7 @@
* .03 joh 071291 moved time stamp from client to the
* channel in use block
* .04 joh 071591 added ticks at last io to the client structure
* .05 joh 103191 moved lock from msg buf to client structure
*
*/
#ifndef INCLfast_lockh
@@ -56,7 +57,6 @@
struct message_buffer{
unsigned stk;
unsigned maxstk;
FAST_LOCK lock;
int cnt;
char buf[MAX_MSG_SIZE];
};
@@ -65,6 +65,7 @@ struct client{
NODE node;
int sock;
int proto;
FAST_LOCK lock;
LIST addrq;
struct message_buffer send;
struct message_buffer recv;
@@ -127,11 +128,11 @@ GLBLTYPE FAST_LOCK rsrv_free_addrq_lck;
GLBLTYPE FAST_LOCK rsrv_free_eventq_lck;
GLBLTYPE struct client *prsrv_cast_client;
#define LOCK_SEND(CLIENT)\
FASTLOCK(&(CLIENT)->send.lock);
#define LOCK_CLIENT(CLIENT)\
FASTLOCK(&(CLIENT)->lock);
#define UNLOCK_SEND(CLIENT)\
FASTUNLOCK(&(CLIENT)->send.lock);
#define UNLOCK_CLIENT(CLIENT)\
FASTUNLOCK(&(CLIENT)->lock);
#define EXTMSGPTR(CLIENT)\
((struct extmsg *) &(CLIENT)->send.buf[(CLIENT)->send.stk])