ca_printf
This commit is contained in:
@@ -69,6 +69,9 @@
|
||||
/* cs_closed */
|
||||
/* 042892 joh no longer checks the status from free() as */
|
||||
/* this varies from OS to OS */
|
||||
/* 050492 joh batch up flow control messages by setting a */
|
||||
/* send_needed flag */
|
||||
/* 060392 joh added ca_host_name() */
|
||||
/* */
|
||||
/*_begin */
|
||||
/************************************************************************/
|
||||
@@ -478,7 +481,7 @@ ca_add_task_variable()
|
||||
int status;
|
||||
|
||||
# if DEBUG
|
||||
printf("adding task variable\n");
|
||||
ca_printf("adding task variable\n");
|
||||
# endif
|
||||
|
||||
/*
|
||||
@@ -498,7 +501,7 @@ ca_add_task_variable()
|
||||
* in a task exit handler.
|
||||
*/
|
||||
# if DEBUG
|
||||
printf("adding the CA delete hook\n");
|
||||
ca_printf("adding the CA delete hook\n");
|
||||
# endif
|
||||
|
||||
# ifdef V5_vxWorks
|
||||
@@ -558,7 +561,7 @@ ca_task_exit_tcb(ptcb)
|
||||
WIND_TCB *ptcb;
|
||||
{
|
||||
# if DEBUG
|
||||
printf("entering the exit handler %x\n", ptcb);
|
||||
ca_printf("entering the exit handler %x\n", ptcb);
|
||||
# endif
|
||||
|
||||
/*
|
||||
@@ -608,7 +611,7 @@ ca_process_exit()
|
||||
#endif
|
||||
|
||||
# ifdef DEBUG
|
||||
printf("entering the exit handler 2 %x\n", tid);
|
||||
ca_printf("entering the exit handler 2 %x\n", tid);
|
||||
# endif
|
||||
|
||||
# if defined(vxWorks)
|
||||
@@ -623,12 +626,12 @@ ca_process_exit()
|
||||
|
||||
if (ca_temp == (struct ca_static *) ERROR){
|
||||
# if DEBUG
|
||||
printf("task variable lookup failed\n");
|
||||
ca_printf("task variable lookup failed\n");
|
||||
# endif
|
||||
return;
|
||||
}
|
||||
# if DEBUG
|
||||
printf( "exit handler with ca_static = %x\n",
|
||||
ca_printf( "exit handler with ca_static = %x\n",
|
||||
ca_static);
|
||||
# endif
|
||||
# else
|
||||
@@ -992,6 +995,9 @@ void build_msg(chix, reply_type)
|
||||
register int size;
|
||||
register int cmd;
|
||||
register struct extmsg *mptr;
|
||||
struct ioc_in_use *piiu;
|
||||
|
||||
piiu = &iiu[chix->iocix];
|
||||
|
||||
if (VALID_BUILD(chix)) {
|
||||
size = chix->name_length + sizeof(struct extmsg);
|
||||
@@ -1001,7 +1007,7 @@ void build_msg(chix, reply_type)
|
||||
cmd = IOC_SEARCH;
|
||||
}
|
||||
|
||||
mptr = CAC_ALLOC_MSG(&iiu[chix->iocix], size);
|
||||
mptr = CAC_ALLOC_MSG(piiu, size);
|
||||
|
||||
mptr->m_cmmd = htons(cmd);
|
||||
mptr->m_available = (int) chix;
|
||||
@@ -1026,7 +1032,9 @@ void build_msg(chix, reply_type)
|
||||
mptr++;
|
||||
strncpy(mptr, chix + 1, chix->name_length);
|
||||
|
||||
CAC_ADD_MSG(&iiu[chix->iocix]);
|
||||
CAC_ADD_MSG(piiu);
|
||||
|
||||
piiu->send_needed = TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -1193,6 +1201,9 @@ issue_get_callback(monix)
|
||||
unsigned size = 0;
|
||||
unsigned count;
|
||||
register struct extmsg *mptr;
|
||||
struct ioc_in_use *piiu;
|
||||
|
||||
piiu = &iiu[chix->iocix];
|
||||
|
||||
/*
|
||||
* dont send the message if the conn is down
|
||||
@@ -1212,7 +1223,7 @@ issue_get_callback(monix)
|
||||
count = monix->count;
|
||||
}
|
||||
|
||||
mptr = CAC_ALLOC_MSG(&iiu[chix->iocix], size);
|
||||
mptr = CAC_ALLOC_MSG(piiu, size);
|
||||
|
||||
/* msg header only on db read notify req */
|
||||
mptr->m_cmmd = htons(IOC_READ_NOTIFY);
|
||||
@@ -1221,7 +1232,9 @@ issue_get_callback(monix)
|
||||
mptr->m_count = htons(count);
|
||||
mptr->m_pciu = chix->paddr;
|
||||
|
||||
CAC_ADD_MSG(&iiu[chix->iocix]);
|
||||
CAC_ADD_MSG(piiu);
|
||||
|
||||
piiu->send_needed = TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -1659,6 +1672,9 @@ ca_request_event(monix)
|
||||
unsigned size = sizeof(struct mon_info);
|
||||
unsigned count;
|
||||
register struct monops *mptr;
|
||||
struct ioc_in_use *piiu;
|
||||
|
||||
piiu = &iiu[chix->iocix];
|
||||
|
||||
/*
|
||||
* dont send the message if the conn is down
|
||||
@@ -1679,7 +1695,7 @@ ca_request_event(monix)
|
||||
count = monix->count;
|
||||
}
|
||||
|
||||
mptr = (struct monops *) CAC_ALLOC_MSG(&iiu[chix->iocix], size);
|
||||
mptr = (struct monops *) CAC_ALLOC_MSG(piiu, size);
|
||||
|
||||
/* msg header */
|
||||
mptr->m_header.m_cmmd = htons(IOC_EVENT_ADD);
|
||||
@@ -1694,7 +1710,9 @@ ca_request_event(monix)
|
||||
htonf(&monix->timeout, &mptr->m_info.m_toval);
|
||||
mptr->m_info.m_mask = htons(monix->mask);
|
||||
|
||||
CAC_ADD_MSG(&iiu[chix->iocix]);
|
||||
CAC_ADD_MSG(piiu);
|
||||
|
||||
piiu->send_needed = TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -2293,19 +2311,19 @@ char *message;
|
||||
ca_status = ECA_INTERNAL;
|
||||
}
|
||||
|
||||
printf(
|
||||
ca_printf(
|
||||
"CA.Diagnostic.....................................................\n");
|
||||
|
||||
printf(
|
||||
ca_printf(
|
||||
" Message: [%s]\n", ca_message_text[CA_EXTRACT_MSG_NO(ca_status)]);
|
||||
|
||||
if(message)
|
||||
printf(
|
||||
ca_printf(
|
||||
" Severity: [%s] Context: [%s]\n",
|
||||
severity[CA_EXTRACT_SEVERITY(ca_status)],
|
||||
message);
|
||||
else
|
||||
printf(
|
||||
ca_printf(
|
||||
" Severity: [%s]\n", severity[CA_EXTRACT_SEVERITY(ca_status)]);
|
||||
|
||||
/*
|
||||
@@ -2327,7 +2345,7 @@ char *message;
|
||||
abort();
|
||||
}
|
||||
|
||||
printf(
|
||||
ca_printf(
|
||||
"..................................................................\n");
|
||||
|
||||
|
||||
@@ -2358,7 +2376,7 @@ ca_busy_message(piiu)
|
||||
*mptr = nullmsg;
|
||||
mptr->m_cmmd = htons(IOC_EVENTS_OFF);
|
||||
CAC_ADD_MSG(piiu);
|
||||
cac_send_msg();
|
||||
piiu->send_needed = TRUE;
|
||||
UNLOCK;
|
||||
}
|
||||
|
||||
@@ -2384,7 +2402,7 @@ ca_ready_message(piiu)
|
||||
*mptr = nullmsg;
|
||||
mptr->m_cmmd = htons(IOC_EVENTS_ON);
|
||||
CAC_ADD_MSG(piiu);
|
||||
cac_send_msg();
|
||||
piiu->send_needed = TRUE;
|
||||
UNLOCK;
|
||||
|
||||
}
|
||||
@@ -2404,6 +2422,7 @@ noop_msg(piiu)
|
||||
*mptr = nullmsg;
|
||||
mptr->m_cmmd = htons(IOC_NOOP);
|
||||
CAC_ADD_MSG(piiu);
|
||||
piiu->send_needed = TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -2429,6 +2448,7 @@ chid pchan;
|
||||
mptr->m_cmmd = htons(IOC_CLAIM_CIU);
|
||||
mptr->m_pciu = pchan->paddr;
|
||||
CAC_ADD_MSG(piiu);
|
||||
piiu->send_needed = TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -2488,4 +2508,18 @@ ca_defunct()
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* CA_HOST_NAME_FUNCTION()
|
||||
*
|
||||
* returns a pointer to the channel's host name
|
||||
*
|
||||
* currently implemented as a function
|
||||
* (may be implemented as a MACRO in the future)
|
||||
*/
|
||||
char
|
||||
*ca_host_name_function(chix)
|
||||
chid chix;
|
||||
{
|
||||
return iiu[chix->iocix].host_name_str;
|
||||
}
|
||||
|
||||
@@ -2,9 +2,18 @@
|
||||
* CA test/debug routine
|
||||
*/
|
||||
|
||||
#if 0
|
||||
#define CA_TEST_CHNL "ca:ai_2000"
|
||||
#define CA_TEST_CHNL4 "ca:bo_000"
|
||||
|
||||
#define CA_TEST_CHNL4 "ca:ai_2000"
|
||||
#else
|
||||
#if 0
|
||||
#define CA_TEST_CHNL "ts2:ai0"
|
||||
#define CA_TEST_CHNL4 "ts2:ai0"
|
||||
#else
|
||||
#define CA_TEST_CHNL "q0_ao"
|
||||
#define CA_TEST_CHNL4 "q0_ao"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* System includes */
|
||||
#if defined(UNIX)
|
||||
@@ -71,7 +80,7 @@ main()
|
||||
|
||||
SEVCHK(ca_task_initialize(), "Unable to initialize");
|
||||
|
||||
printf("begin\n");
|
||||
ca_printf("begin\n");
|
||||
#ifdef VMS
|
||||
lib$init_timer();
|
||||
#endif
|
||||
@@ -80,7 +89,7 @@ main()
|
||||
malloc(dbr_size[DBR_GR_FLOAT] +
|
||||
dbr_value_size[DBR_GR_FLOAT] * (NUM - 1));
|
||||
|
||||
for (i = 0; i < 0; i++) {
|
||||
for (i = 0; i < 10; i++) {
|
||||
|
||||
status = ca_array_build(CA_TEST_CHNL, /* channel ASCII name */
|
||||
DBR_GR_FLOAT, /* fetch external type */
|
||||
@@ -122,10 +131,8 @@ main()
|
||||
SEVCHK(ca_clear_channel(chix3), NULL);
|
||||
SEVCHK(ca_clear_channel(chix1), NULL);
|
||||
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
|
||||
status = ca_array_build(
|
||||
CA_TEST_CHNL, /* channel ASCII name */
|
||||
DBR_GR_FLOAT, /* fetch external type */
|
||||
@@ -164,13 +171,13 @@ main()
|
||||
SEVCHK(status, NULL);
|
||||
|
||||
if (INVALID_DB_REQ(chix1->type))
|
||||
printf("Failed to locate %s\n", CA_TEST_CHNL);
|
||||
ca_printf("Failed to locate %s\n", CA_TEST_CHNL);
|
||||
if (INVALID_DB_REQ(chix2->type))
|
||||
printf("Failed to locate %s\n", CA_TEST_CHNL);
|
||||
ca_printf("Failed to locate %s\n", CA_TEST_CHNL);
|
||||
if (INVALID_DB_REQ(chix3->type))
|
||||
printf("Failed to locate %s\n", CA_TEST_CHNL);
|
||||
ca_printf("Failed to locate %s\n", CA_TEST_CHNL);
|
||||
if (INVALID_DB_REQ(chix4->type))
|
||||
printf("Failed to locate %s\n", CA_TEST_CHNL4);
|
||||
ca_printf("Failed to locate %s\n", CA_TEST_CHNL4);
|
||||
/*
|
||||
* SEVCHK(status,NULL); if(status == ECA_TIMEOUT) exit();
|
||||
*/
|
||||
@@ -181,7 +188,7 @@ main()
|
||||
|
||||
pfloat = &ptr->value;
|
||||
for (i = 0; i < NUM; i++)
|
||||
printf("Value Returned from build %f\n", pfloat[i]);
|
||||
ca_printf("Value Returned from build %f\n", pfloat[i]);
|
||||
|
||||
#ifdef VMS
|
||||
lib$init_timer();
|
||||
@@ -191,7 +198,7 @@ main()
|
||||
* verify we dont jam up on many uninterrupted
|
||||
* solicitations
|
||||
*/
|
||||
printf("Performing multiple get test...");
|
||||
ca_printf("Performing multiple get test...");
|
||||
#ifdef UNIX
|
||||
fflush(stdout);
|
||||
#endif
|
||||
@@ -203,12 +210,12 @@ main()
|
||||
}
|
||||
SEVCHK(ca_pend_io(200.0), NULL);
|
||||
}
|
||||
printf("done.\n");
|
||||
ca_printf("done.\n");
|
||||
|
||||
/*
|
||||
* verify we can add many monitors at once
|
||||
*/
|
||||
printf("Performing multiple monitor test...");
|
||||
ca_printf("Performing multiple monitor test...");
|
||||
#ifdef UNIX
|
||||
fflush(stdout);
|
||||
#endif
|
||||
@@ -238,7 +245,7 @@ main()
|
||||
SEVCHK(ca_get(DBR_FLOAT,chix4,&temp),NULL);
|
||||
SEVCHK(ca_pend_io(100.0),NULL);
|
||||
}
|
||||
printf("done.\n");
|
||||
ca_printf("done.\n");
|
||||
|
||||
if (VALID_DB_REQ(chix4->type)) {
|
||||
status = ca_add_event(DBR_FLOAT, chix4, EVENT_ROUTINE, 0xaaaaaaaa, &monix);
|
||||
@@ -282,15 +289,15 @@ main()
|
||||
lib$show_timer();
|
||||
#endif
|
||||
for (i = 0; i < NUM; i++) {
|
||||
printf("Float value Returned from put/get %f\n", pfloat[i]);
|
||||
printf("Double value Returned from put/get %f\n", pdouble[i]);
|
||||
printf("GR Float value Returned from put/get %f\n", pgrfloat[i].value);
|
||||
ca_printf("Float value Returned from put/get %f\n", pfloat[i]);
|
||||
ca_printf("Double value Returned from put/get %f\n", pdouble[i]);
|
||||
ca_printf("GR Float value Returned from put/get %f\n", pgrfloat[i].value);
|
||||
}
|
||||
|
||||
for (i = 0; i < 10; i++)
|
||||
ca_get_callback(DBR_GR_FLOAT, chix1, ca_test_event, NULL);
|
||||
|
||||
printf("-- Put/Gets done- waiting for Events --\n");
|
||||
ca_printf("-- Put/Gets done- waiting for Events --\n");
|
||||
status = ca_pend_event(60.0);
|
||||
if (status == ECA_TIMEOUT) {
|
||||
|
||||
@@ -314,7 +321,7 @@ null_event()
|
||||
static int i;
|
||||
|
||||
if (i++ > 1000) {
|
||||
printf("1000 occured\n");
|
||||
ca_printf("1000 occured\n");
|
||||
i = 0;
|
||||
}
|
||||
}
|
||||
@@ -342,9 +349,9 @@ conn(args)
|
||||
{
|
||||
|
||||
if (args.op == CA_OP_CONN_UP)
|
||||
printf("Channel On Line [%s]\n", ca_name(args.chid));
|
||||
ca_printf("Channel On Line [%s]\n", ca_name(args.chid));
|
||||
else if (args.op == CA_OP_CONN_DOWN)
|
||||
printf("Channel Off Line [%s]\n", ca_name(args.chid));
|
||||
ca_printf("Channel Off Line [%s]\n", ca_name(args.chid));
|
||||
else
|
||||
printf("Ukn conn ev\n");
|
||||
ca_printf("Ukn conn ev\n");
|
||||
}
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
/* .02 031892 joh initial broadcast retry delay is now a #define */
|
||||
/* .03 031992 joh reset the iiu delay if the current time */
|
||||
/* is specified */
|
||||
/* .04 043092 joh check to see if the conn is up when setting */
|
||||
/* for CA_CUURRENT_TIME to be safe */
|
||||
/* */
|
||||
/*_begin */
|
||||
/************************************************************************/
|
||||
@@ -69,7 +71,14 @@ char silent;
|
||||
int search_type;
|
||||
|
||||
if(iiu[i].next_retry == CA_CURRENT_TIME){
|
||||
iiu[i].next_retry = current + iiu[i].retry_delay;
|
||||
if(iiu[i].conn_up){
|
||||
iiu[i].next_retry =
|
||||
current + CA_RETRY_PERIOD;
|
||||
}
|
||||
else{
|
||||
iiu[i].next_retry =
|
||||
current + iiu[i].retry_delay;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -113,7 +122,7 @@ char silent;
|
||||
}
|
||||
|
||||
if(retry_cnt){
|
||||
printf("<Trying> ");
|
||||
ca_printf("<Trying> ");
|
||||
#ifdef UNIX
|
||||
fflush(stdout);
|
||||
#endif
|
||||
@@ -156,7 +165,7 @@ struct in_addr *pnet_addr;
|
||||
manage_conn(TRUE);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("<%s> ",host_from_addr(pnet_addr));
|
||||
ca_printf("<%s> ",host_from_addr(pnet_addr));
|
||||
#ifdef UNIX
|
||||
fflush(stdout);
|
||||
#endif
|
||||
@@ -230,7 +239,7 @@ struct in_addr *pnet_addr;
|
||||
iiu[BROADCAST_IIU].next_retry =
|
||||
time(NULL) + iiu[BROADCAST_IIU].retry_delay;
|
||||
#ifdef DEBUG
|
||||
printf("<Trying ukn online after pseudo random delay=%d sec> ",
|
||||
ca_printf("<Trying ukn online after pseudo random delay=%d sec> ",
|
||||
iiu[BROADCAST_IIU].retry_delay);
|
||||
#ifdef UNIX
|
||||
fflush(stdout);
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
*/
|
||||
no_cvrt()
|
||||
{
|
||||
printf("Sorry, conversion for that type currently not implemented\n");
|
||||
ca_printf("Sorry, conversion for that type currently not implemented\n");
|
||||
exit();
|
||||
}
|
||||
cvrt_sts_char() {no_cvrt();}
|
||||
@@ -213,8 +213,8 @@ int num; /* number of values */
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
printf("CA: sorry no code for conversions of doubles\n");
|
||||
printf("CA: setting your variable to nill\n");
|
||||
ca_printf("CA: sorry no code for conversions of doubles\n");
|
||||
ca_printf("CA: setting your variable to nill\n");
|
||||
for(i=0; i<num; i++){
|
||||
*d++ = 0.0;
|
||||
}
|
||||
|
||||
105
src/ca/iocinf.c
105
src/ca/iocinf.c
@@ -31,6 +31,11 @@
|
||||
/* 022692 joh better prefix on messages */
|
||||
/* 031892 joh initial rebroadcast delay is now a #define */
|
||||
/* 042892 joh made local routines static */
|
||||
/* 050492 joh dont call cac_send_msg() until all messages */
|
||||
/* have been processed to support batching */
|
||||
/* 050492 joh added new fd array to select */
|
||||
/* 072392 joh use SO_REUSEADDR when testing to see */
|
||||
/* if the repeater has been started */
|
||||
/* */
|
||||
/*_begin */
|
||||
/************************************************************************/
|
||||
@@ -180,7 +185,9 @@ unsigned short *iocix;
|
||||
status = create_net_chan(&iiu[i]);
|
||||
if(status != ECA_NORMAL)
|
||||
return status;
|
||||
ca_signal(ECA_NEWCONN,host_from_addr(pnet_addr));
|
||||
ca_signal(
|
||||
ECA_NEWCONN,
|
||||
iiu[i].host_name_str);
|
||||
}
|
||||
|
||||
*iocix = i;
|
||||
@@ -299,7 +306,7 @@ struct ioc_in_use *piiu;
|
||||
if(status < 0){
|
||||
abort();
|
||||
}
|
||||
printf( "CAC: linger was on:%d linger:%d\n",
|
||||
ca_printf( "CAC: linger was on:%d linger:%d\n",
|
||||
linger.l_onoff,
|
||||
linger.l_linger);
|
||||
}
|
||||
@@ -344,7 +351,7 @@ struct ioc_in_use *piiu;
|
||||
&piiu->sock_addr,
|
||||
sizeof(piiu->sock_addr));
|
||||
if(status < 0){
|
||||
printf("CAC: no conn errno %d\n", MYERRNO);
|
||||
ca_printf("CAC: no conn errno %d\n", MYERRNO);
|
||||
status = socket_close(sock);
|
||||
if(status<0){
|
||||
SEVCHK(ECA_INTERNAL,NULL);
|
||||
@@ -363,6 +370,7 @@ struct ioc_in_use *piiu;
|
||||
FIONBIO,
|
||||
&true);
|
||||
#endif
|
||||
|
||||
break;
|
||||
|
||||
case IPPROTO_UDP:
|
||||
@@ -386,7 +394,7 @@ struct ioc_in_use *piiu;
|
||||
&true,
|
||||
sizeof(true));
|
||||
if(status<0){
|
||||
printf("CAC: sso (errno=%d)\n",MYERRNO);
|
||||
ca_printf("CAC: sso (errno=%d)\n",MYERRNO);
|
||||
status = socket_close(sock);
|
||||
if(status < 0){
|
||||
SEVCHK(ECA_INTERNAL,NULL);
|
||||
@@ -406,7 +414,7 @@ struct ioc_in_use *piiu;
|
||||
(struct sockaddr *) &saddr,
|
||||
sizeof(saddr));
|
||||
if(status<0){
|
||||
printf("CAC: bind (errno=%d)\n",MYERRNO);
|
||||
ca_printf("CAC: bind (errno=%d)\n",MYERRNO);
|
||||
ca_signal(ECA_INTERNAL,"bind failed");
|
||||
}
|
||||
|
||||
@@ -442,6 +450,21 @@ struct ioc_in_use *piiu;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Save the Host name for efficient access in the
|
||||
* future.
|
||||
*/
|
||||
{
|
||||
char *ptmpstr;
|
||||
int len;
|
||||
|
||||
ptmpstr = host_from_addr(&piiu->sock_addr.sin_addr);
|
||||
strncpy(
|
||||
piiu->host_name_str,
|
||||
ptmpstr,
|
||||
sizeof(piiu->host_name_str)-1);
|
||||
}
|
||||
|
||||
piiu->recv->stk = 0;
|
||||
piiu->conn_up = TRUE;
|
||||
if(fd_register_func){
|
||||
@@ -543,7 +566,7 @@ notify_ca_repeater()
|
||||
&saddr,
|
||||
sizeof saddr);
|
||||
if(status < 0){
|
||||
printf("CAC: notify_ca_repeater: send to lcl addr failed\n");
|
||||
ca_printf("CAC: notify_ca_repeater: send to lcl addr failed\n");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
@@ -635,7 +658,7 @@ void cac_send_msg()
|
||||
for(piiu=iiu; piiu<&iiu[nxtiiu]; piiu++){
|
||||
if(piiu->send->stk){
|
||||
inaddr = &piiu->sock_addr.sin_addr;
|
||||
iocname = host_from_addr(inaddr);
|
||||
iocname = piiu->host_name_str;
|
||||
#ifdef CLOSE_ON_EXPIRED
|
||||
ca_signal(ECA_DLCKREST, iocname);
|
||||
close_ioc(piiu);
|
||||
@@ -712,7 +735,7 @@ register struct ioc_in_use *piiu;
|
||||
if(status == cnt){
|
||||
break;
|
||||
}
|
||||
else if(status>=0){
|
||||
else if(status>0){
|
||||
if(status>cnt){
|
||||
ca_signal(
|
||||
ECA_INTERNAL,
|
||||
@@ -722,6 +745,10 @@ register struct ioc_in_use *piiu;
|
||||
cnt = cnt-status;
|
||||
pmsg = (void *) (status+(char *)pmsg);
|
||||
}
|
||||
else if(status == 0){
|
||||
ca_printf("sent zero\n");
|
||||
TCPDELAY;
|
||||
}
|
||||
#ifdef UNIX
|
||||
else if(MYERRNO == EWOULDBLOCK){
|
||||
if(pmsg != piiu->send->buf){
|
||||
@@ -742,7 +769,7 @@ register struct ioc_in_use *piiu;
|
||||
if( MYERRNO != EPIPE &&
|
||||
MYERRNO != ECONNRESET &&
|
||||
MYERRNO != ETIMEDOUT){
|
||||
printf(
|
||||
ca_printf(
|
||||
"CAC: error on socket send() %d\n",
|
||||
MYERRNO);
|
||||
}
|
||||
@@ -750,14 +777,12 @@ register struct ioc_in_use *piiu;
|
||||
return OK;
|
||||
}
|
||||
|
||||
if(status == 0){
|
||||
TCPDELAY;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* reset send stack */
|
||||
piiu->send->stk = 0;
|
||||
piiu->send_needed = FALSE;
|
||||
|
||||
/*
|
||||
* reset the delay to the next keepalive
|
||||
@@ -794,13 +819,14 @@ struct timeval *ptimeout;
|
||||
for(piiu=iiu;piiu<&iiu[nxtiiu];piiu++)
|
||||
if(piiu->conn_up){
|
||||
FD_SET(piiu->sock_chan,&readch);
|
||||
FD_SET(piiu->sock_chan,&excepch);
|
||||
}
|
||||
|
||||
status = select(
|
||||
sizeof(fd_set)*NBBY,
|
||||
&readch,
|
||||
NULL,
|
||||
NULL,
|
||||
&excepch,
|
||||
ptmptimeout);
|
||||
|
||||
if(status<=0){
|
||||
@@ -808,12 +834,12 @@ struct timeval *ptimeout;
|
||||
return;
|
||||
|
||||
if(MYERRNO == EINTR){
|
||||
printf("cac: select was interrupted\n");
|
||||
ca_printf("cac: select was interrupted\n");
|
||||
TCPDELAY;
|
||||
continue;
|
||||
}
|
||||
else if(MYERRNO == EWOULDBLOCK){
|
||||
printf("CAC: blocked at select ?\n");
|
||||
ca_printf("CAC: blocked at select ?\n");
|
||||
return;
|
||||
}
|
||||
else{ char text[255];
|
||||
@@ -823,10 +849,14 @@ struct timeval *ptimeout;
|
||||
MYERRNO);
|
||||
ca_signal(ECA_INTERNAL,text); } }
|
||||
|
||||
for(piiu=iiu;piiu<&iiu[nxtiiu];piiu++)
|
||||
if(piiu->conn_up)
|
||||
if(FD_ISSET(piiu->sock_chan,&readch) )
|
||||
for(piiu=iiu;piiu<&iiu[nxtiiu];piiu++){
|
||||
if(piiu->conn_up){
|
||||
if(FD_ISSET(piiu->sock_chan,&readch) ||
|
||||
FD_ISSET(piiu->sock_chan,&excepch)){
|
||||
recv_msg(piiu);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* double check to make sure that nothing is left pending
|
||||
@@ -862,10 +892,14 @@ struct ioc_in_use *piiu;
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("CAC: cac_send_msg: ukn protocol\n");
|
||||
ca_printf("CAC: cac_send_msg: ukn protocol\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
if(piiu->send_needed){
|
||||
cac_send_msg_piiu(piiu);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -909,7 +943,7 @@ struct ioc_in_use *piiu;
|
||||
if( MYERRNO != EPIPE &&
|
||||
MYERRNO != ECONNRESET &&
|
||||
MYERRNO != ETIMEDOUT){
|
||||
printf( "CAC: unexpected recv error (errno=%d)\n",
|
||||
ca_printf( "CAC: unexpected recv error (errno=%d)\n",
|
||||
MYERRNO);
|
||||
}
|
||||
LOCK;
|
||||
@@ -921,7 +955,7 @@ struct ioc_in_use *piiu;
|
||||
|
||||
byte_cnt = (long) status;
|
||||
if(byte_cnt>MAX_MSG_SIZE){
|
||||
printf( "CAC: recv_msg(): message overflow %l\n",
|
||||
ca_printf( "CAC: recv_msg(): message overflow %l\n",
|
||||
byte_cnt-MAX_MSG_SIZE);
|
||||
LOCK;
|
||||
close_ioc(piiu);
|
||||
@@ -953,7 +987,7 @@ struct ioc_in_use *piiu;
|
||||
rcvb->buf + rcvb->stk - byte_cnt,
|
||||
byte_cnt);
|
||||
#ifdef DEBUG
|
||||
printf( "CAC: realigned message of %d bytes\n",
|
||||
ca_printf( "CAC: realigned message of %d bytes\n",
|
||||
byte_cnt);
|
||||
#endif
|
||||
}
|
||||
@@ -1026,7 +1060,7 @@ struct ioc_in_use *piiu;
|
||||
rcvb->stk += status;
|
||||
pmsglog->nbytes = (long) status;
|
||||
#ifdef DEBUG
|
||||
printf("CAC: recieved a udp reply of %d bytes\n",byte_cnt);
|
||||
ca_printf("CAC: recieved a udp reply of %d bytes\n",byte_cnt);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1058,7 +1092,7 @@ struct ioc_in_use *piiu;
|
||||
&pmsglog->addr.sin_addr,
|
||||
piiu);
|
||||
if(status != OK || msgcount != 0){
|
||||
printf( "CAC: UDP alignment problem %d\n",
|
||||
ca_printf( "CAC: UDP alignment problem %d\n",
|
||||
msgcount);
|
||||
}
|
||||
|
||||
@@ -1251,11 +1285,11 @@ struct ioc_in_use *piiu;
|
||||
SEVCHK(ECA_INTERNAL,NULL);
|
||||
}
|
||||
piiu->sock_chan = -1;
|
||||
if(piiu->chidlist.count)
|
||||
if(piiu->chidlist.count){
|
||||
ca_signal(
|
||||
ECA_DISCONN,
|
||||
host_from_addr(&piiu->sock_addr.sin_addr));
|
||||
|
||||
piiu->host_name_str);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1267,7 +1301,7 @@ struct ioc_in_use *piiu;
|
||||
*
|
||||
* NOTE: potential race condition here can result
|
||||
* in two copies of the repeater being spawned
|
||||
* however the repeater detectes this prints a message
|
||||
* however the repeater detectes this, prints a message,
|
||||
* and lets the other task start the repeater.
|
||||
*
|
||||
* QUESTION: is there a better way to test for a port in use?
|
||||
@@ -1282,6 +1316,7 @@ struct ioc_in_use *piiu;
|
||||
* Attempting to bind the open socket to another port
|
||||
* also does not work.
|
||||
*
|
||||
* 072392 - problem solved by using SO_REUSEADDR
|
||||
*/
|
||||
repeater_installed()
|
||||
{
|
||||
@@ -1295,8 +1330,19 @@ repeater_installed()
|
||||
sock = socket( AF_INET, /* domain */
|
||||
SOCK_DGRAM, /* type */
|
||||
0); /* deflt proto */
|
||||
if(sock == ERROR)
|
||||
if(sock == ERROR){
|
||||
abort();
|
||||
}
|
||||
|
||||
status = setsockopt( sock,
|
||||
SOL_SOCKET,
|
||||
SO_REUSEADDR,
|
||||
NULL,
|
||||
0);
|
||||
if(status<0){
|
||||
ca_printf( "%s: set socket option failed\n",
|
||||
__FILE__);
|
||||
}
|
||||
|
||||
memset(&bd,0,sizeof bd);
|
||||
bd.sin_family = AF_INET;
|
||||
@@ -1316,5 +1362,6 @@ repeater_installed()
|
||||
SEVCHK(ECA_INTERNAL,NULL);
|
||||
}
|
||||
|
||||
|
||||
return installed;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
* .06 joh 111991 added EVENTLOCKTEST
|
||||
* .07 joh 120291 added declaration of taskIdCurrent for
|
||||
* compiling with V4 vxWorks
|
||||
* .08 joh 062692 took out printf to logMsg MACRO
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -108,7 +109,6 @@
|
||||
# define abort(A) taskSuspend(VXTHISTASKID)
|
||||
# define memcpy(D,S,N) bcopy(S,D,N)
|
||||
# define memset(D,V,N) bfill(D,N,V)
|
||||
# define printf logMsg
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
/* connect tests wont fail */
|
||||
/* 042892 joh No longer checking the status from free() */
|
||||
/* since it varies from os to os */
|
||||
/* 040592 joh took out extra cac_send_msg() calls */
|
||||
/* */
|
||||
/*_begin */
|
||||
/************************************************************************/
|
||||
@@ -88,7 +89,7 @@ void reconnect_channel();
|
||||
void ca_request_event();
|
||||
int client_channel_exists();
|
||||
|
||||
#define BUFSTAT printf("expected %d left %d\n",msgcnt,*pbufcnt);
|
||||
#define BUFSTAT ca_printf("expected %d left %d\n",msgcnt,*pbufcnt);
|
||||
|
||||
|
||||
|
||||
@@ -121,7 +122,7 @@ post_msg(hdrptr, pbufcnt, pnet_addr, piiu)
|
||||
|
||||
while (*pbufcnt >= sizeof(*hdrptr)) {
|
||||
#ifdef DEBUG
|
||||
printf("bytes left %d, pending msgcnt %d\n",
|
||||
ca_printf("bytes left %d, pending msgcnt %d\n",
|
||||
*pbufcnt,
|
||||
pndrecvcnt);
|
||||
#endif
|
||||
@@ -134,7 +135,7 @@ post_msg(hdrptr, pbufcnt, pnet_addr, piiu)
|
||||
t_count = ntohs(hdrptr->m_count);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("MSG: cmd:%d type:%d cnt:%d npost:%d avail:%x\n",
|
||||
ca_printf("MSG: cmd:%d type:%d cnt:%d npost:%d avail:%x\n",
|
||||
t_cmmd,
|
||||
t_type,
|
||||
t_count,
|
||||
@@ -347,7 +348,7 @@ post_msg(hdrptr, pbufcnt, pnet_addr, piiu)
|
||||
|
||||
if (chpiiu->sock_addr.sin_addr.s_addr ==
|
||||
pnet_addr->s_addr) {
|
||||
printf("<Extra> ");
|
||||
ca_printf("<Extra> ");
|
||||
# ifdef UNIX
|
||||
fflush(stdout);
|
||||
# endif
|
||||
@@ -357,8 +358,7 @@ post_msg(hdrptr, pbufcnt, pnet_addr, piiu)
|
||||
|
||||
sprintf(acc,
|
||||
"%s",
|
||||
host_from_addr(
|
||||
&chpiiu->sock_addr.sin_addr));
|
||||
chpiiu->host_name_str);
|
||||
sprintf(rej,
|
||||
"%s",
|
||||
host_from_addr(pnet_addr));
|
||||
@@ -410,7 +410,7 @@ post_msg(hdrptr, pbufcnt, pnet_addr, piiu)
|
||||
case REPEATER_CONFIRM:
|
||||
ca_static->ca_repeater_contacted = TRUE;
|
||||
#ifdef DEBUG
|
||||
printf("repeater confirmation recv\n");
|
||||
ca_printf("repeater confirmation recv\n");
|
||||
#endif
|
||||
break;
|
||||
|
||||
@@ -540,7 +540,7 @@ post_msg(hdrptr, pbufcnt, pnet_addr, piiu)
|
||||
break;
|
||||
}
|
||||
default:
|
||||
printf("post_msg(): Corrupt cmd in msg %x\n",
|
||||
ca_printf("post_msg(): Corrupt cmd in msg %x\n",
|
||||
t_cmmd);
|
||||
|
||||
*pbufcnt = 0;
|
||||
@@ -584,9 +584,9 @@ struct in_addr *pnet_addr;
|
||||
&newiocix
|
||||
);
|
||||
if(status != ECA_NORMAL){
|
||||
printf("... %s ...\n", ca_message(status));
|
||||
printf("for %s on %s\n", chan+1, host_from_addr(pnet_addr));
|
||||
printf("ignored search reply- proceeding\n");
|
||||
ca_printf("... %s ...\n", ca_message(status));
|
||||
ca_printf("for %s on %s\n", chan+1, host_from_addr(pnet_addr));
|
||||
ca_printf("ignored search reply- proceeding\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -638,7 +638,6 @@ struct in_addr *pnet_addr;
|
||||
issue_get_callback(pevent);
|
||||
}
|
||||
}
|
||||
cac_send_msg();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -648,7 +647,6 @@ struct in_addr *pnet_addr;
|
||||
pevent;
|
||||
pevent = (evid)pevent->node.next)
|
||||
ca_request_event(pevent);
|
||||
cac_send_msg();
|
||||
}
|
||||
|
||||
UNLOCK;
|
||||
|
||||
@@ -23,50 +23,50 @@ void
|
||||
ca_test_event(args)
|
||||
struct event_handler_args args;
|
||||
{
|
||||
printf("~~~### in test event for [%s] ###~~~\n",args.chid+1);
|
||||
printf("User argument\t%x\n", args.usr);
|
||||
printf("Native channel data type\t%d\n", args.chid->type);
|
||||
printf("Monitor data type\t%d\n", args.type);
|
||||
ca_printf("~~~### in test event for [%s] ###~~~\n",args.chid+1);
|
||||
ca_printf("User argument\t%x\n", args.usr);
|
||||
ca_printf("Native channel data type\t%d\n", args.chid->type);
|
||||
ca_printf("Monitor data type\t%d\n", args.type);
|
||||
switch(args.type){
|
||||
case DBR_STRING:
|
||||
printf("Value:\t<%s>\n",args.dbr);
|
||||
ca_printf("Value:\t<%s>\n",args.dbr);
|
||||
break;
|
||||
case DBR_CHAR:
|
||||
printf("Value:\t<%d>\n",*(char *)args.dbr);
|
||||
ca_printf("Value:\t<%d>\n",*(char *)args.dbr);
|
||||
break;
|
||||
#if DBR_INT != DBR_SHORT
|
||||
case DBR_INT:
|
||||
#endif
|
||||
case DBR_SHORT:
|
||||
case DBR_ENUM:
|
||||
printf("Value:\t<%d>\n",*(short *)args.dbr);
|
||||
ca_printf("Value:\t<%d>\n",*(short *)args.dbr);
|
||||
break;
|
||||
case DBR_LONG:
|
||||
printf("Value:\t<%d>\n",*(long *)args.dbr);
|
||||
ca_printf("Value:\t<%d>\n",*(long *)args.dbr);
|
||||
break;
|
||||
case DBR_FLOAT:
|
||||
printf("Value:\t<%f>\n",*(float *)args.dbr);
|
||||
ca_printf("Value:\t<%f>\n",*(float *)args.dbr);
|
||||
break;
|
||||
case DBR_DOUBLE:
|
||||
printf("Value:\t<%f>\n",*(double *)args.dbr);
|
||||
ca_printf("Value:\t<%f>\n",*(double *)args.dbr);
|
||||
break;
|
||||
case DBR_STS_STRING:
|
||||
printf("Value:\t<%s>\n",((struct dbr_sts_string *)args.dbr)->value);
|
||||
ca_printf("Value:\t<%s>\n",((struct dbr_sts_string *)args.dbr)->value);
|
||||
break;
|
||||
case DBR_STS_INT:
|
||||
printf("Value:\t<%d>\n",((struct dbr_sts_int *)args.dbr)->value);
|
||||
ca_printf("Value:\t<%d>\n",((struct dbr_sts_int *)args.dbr)->value);
|
||||
break;
|
||||
case DBR_STS_FLOAT:
|
||||
printf("Value:\t<%f>\n",((struct dbr_sts_float *)args.dbr)->value);
|
||||
ca_printf("Value:\t<%f>\n",((struct dbr_sts_float *)args.dbr)->value);
|
||||
break;
|
||||
case DBR_STS_ENUM:
|
||||
printf("Value:\t<%d>\n",((struct dbr_sts_enum *)args.dbr)->value);
|
||||
ca_printf("Value:\t<%d>\n",((struct dbr_sts_enum *)args.dbr)->value);
|
||||
break;
|
||||
case DBR_GR_FLOAT:
|
||||
printf("Value:\t<%f>\n",((struct dbr_gr_float *)args.dbr)->value);
|
||||
ca_printf("Value:\t<%f>\n",((struct dbr_gr_float *)args.dbr)->value);
|
||||
break;
|
||||
default:
|
||||
printf( "Sorry test_event does not handle data type %d yet\n",
|
||||
ca_printf( "Sorry test_event does not handle data type %d yet\n",
|
||||
args.type);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user