From 05578b2f59938c8a3f0ab4aea37f2ced0358cad9 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Thu, 5 Aug 1993 01:39:42 +0000 Subject: [PATCH] cycled through -Wall --- src/rsrv/camessage.c | 315 +++++++++++++++++++++++++-------------- src/rsrv/camsgtask.c | 165 ++++++++++++++++---- src/rsrv/caserverio.c | 37 ++++- src/rsrv/caservertask.c | 150 +++++++++++++++---- src/rsrv/cast_server.c | 173 +++++++++++++++------ src/rsrv/online_notify.c | 59 ++++++-- src/rsrv/rsrv_init.c | 34 ++++- src/rsrv/server.h | 44 +++--- 8 files changed, 704 insertions(+), 273 deletions(-) diff --git a/src/rsrv/camessage.c b/src/rsrv/camessage.c index 5341d2147..b3998b954 100644 --- a/src/rsrv/camessage.c +++ b/src/rsrv/camessage.c @@ -51,6 +51,10 @@ static char *sccsId = "$Id$\t$Date$"; #include #include #include +#include +#include +#include + #include #include #include @@ -61,15 +65,49 @@ static struct extmsg nill_msg; #define MPTOPADDR(MP) (&((struct channel_in_use *)(MP)->m_pciu)->addr) #define RECORD_NAME(PADDR) (((struct db_addr *)(PADDR))->precord) -static void search_reply(); -static void build_reply(); -static void read_reply(); -static void read_sync_reply(); -static void event_cancel_reply(); -static void clear_channel_reply(); -static void send_err(); -static void log_header(); -static void search_fail_reply(); +LOCAL void clear_channel_reply( +struct extmsg *mp, +struct client *client +); + +LOCAL void event_cancel_reply( +struct extmsg *mp, +struct client *client +); + +LOCAL void read_reply( +struct event_ext *pevext, +struct db_addr *paddr, +int hold, /* more on the way if true */ +void *pfl +); + +LOCAL void read_sync_reply( +struct extmsg *mp, +struct client *client +); + +LOCAL void build_reply( +struct extmsg *mp, +struct client *client +); + +LOCAL void search_fail_reply( +struct extmsg *mp, +struct client *client +); + +LOCAL void send_err( +struct extmsg *curp, +int status, +struct client *client, +char *footnote +); + +LOCAL void log_header( +struct extmsg *mp, +int mnum +); /* @@ -77,9 +115,10 @@ static void search_fail_reply(); * * */ -camessage(client, recv) - struct client *client; - struct message_buffer *recv; +int camessage( +struct client *client, +struct message_buffer *recv +) { int nmsg = 0; unsigned msgsize; @@ -89,8 +128,15 @@ camessage(client, recv) FAST struct event_ext *pevext; - if (CASDEBUG > 2) - logMsg("CAS: Parsing %d(decimal) bytes\n", recv->cnt); + if (CASDEBUG > 2){ + logMsg( "CAS: Parsing %d(decimal) bytes\n", + recv->cnt, + NULL, + NULL, + NULL, + NULL, + NULL); + } bytes_left = recv->cnt; while (bytes_left) { @@ -151,7 +197,7 @@ camessage(client, recv) read_reply, pevext, (unsigned) ((struct monops *) mp)->m_info.m_mask, - pevext + 1); + (struct event_block *)(pevext+1)); if (status == ERROR) { LOCK_CLIENT(client); send_err( @@ -202,7 +248,7 @@ camessage(client, recv) * messages sent by the server). */ - db_post_single_event(pevext+1); + db_post_single_event((struct event_block *)(pevext+1)); break; @@ -216,33 +262,33 @@ camessage(client, recv) case IOC_READ_NOTIFY: case IOC_READ: - { - struct event_ext evext; + { + struct event_ext evext; - pevext = &evext; - pevext->mp = mp; - pevext->client = client; - pevext->send_lock = TRUE; - pevext->get = TRUE; - if (mp->m_count == 1) - pevext->size = dbr_size[mp->m_type]; - else - pevext->size = (mp->m_count - 1) * - dbr_value_size[mp->m_type] + - dbr_size[mp->m_type]; + pevext = &evext; + pevext->mp = mp; + pevext->client = client; + pevext->send_lock = TRUE; + pevext->get = TRUE; + if (mp->m_count == 1) + pevext->size = dbr_size[mp->m_type]; + else + pevext->size = (mp->m_count - 1) * + dbr_value_size[mp->m_type] + + dbr_size[mp->m_type]; - /* - * Arguments to this routine organized in - * favor of the standard db event calling - * mechanism- routine(userarg, paddr). See - * events added above. - * - * Hold argument set true so the send message - * buffer is not flushed once each call. - */ - read_reply(pevext, MPTOPADDR(mp), TRUE, NULL); - break; - } + /* + * Arguments to this routine organized in + * favor of the standard db event calling + * mechanism- routine(userarg, paddr). See + * events added above. + * + * Hold argument set true so the send message + * buffer is not flushed once each call. + */ + read_reply(pevext, MPTOPADDR(mp), TRUE, NULL); + break; + } case IOC_SEARCH: case IOC_BUILD: build_reply(mp, client); @@ -265,38 +311,42 @@ camessage(client, recv) } break; case IOC_EVENTS_ON: - { - struct event_ext evext; - struct channel_in_use *pciu = - (struct channel_in_use *) & client->addrq; + { + struct event_ext evext; + struct channel_in_use *pciu; - client->eventsoff = FALSE; + client->eventsoff = FALSE; - LOCK_CLIENT(client); - while (pciu = (struct channel_in_use *) - pciu->node.next) { + LOCK_CLIENT(client); - pevext = (struct event_ext *) - & pciu->eventq; - while (pevext = (struct event_ext *) - pevext->node.next){ + pciu = (struct channel_in_use *) + client->addrq.node.next; + while (pciu) { + pevext = (struct event_ext *) + pciu->eventq.node.next; + while (pevext){ - if (pevext->modified) { - evext = *pevext; - evext.send_lock = FALSE; - evext.get = TRUE; - read_reply( - &evext, - MPTOPADDR(&pevext->msg), - TRUE, - NULL); - pevext->modified = FALSE; - } + if (pevext->modified) { + evext = *pevext; + evext.send_lock = FALSE; + evext.get = TRUE; + read_reply( + &evext, + MPTOPADDR(&pevext->msg), + TRUE, + NULL); + pevext->modified = FALSE; } + pevext = (struct event_ext *) + pevext->node.next; } - UNLOCK_CLIENT(client); - break; + + pciu = (struct channel_in_use *) + pciu->node.next; } + UNLOCK_CLIENT(client); + break; + } case IOC_EVENTS_OFF: client->eventsoff = TRUE; break; @@ -328,7 +378,13 @@ camessage(client, recv) UNLOCK_CLIENT(prsrv_cast_client); if(status < 0){ free_client(client); - logMsg("CAS: client timeout disconnect\n"); + logMsg("CAS: client timeout disconnect\n", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); exit(0); } LOCK_CLIENT(client); @@ -336,7 +392,13 @@ camessage(client, recv) UNLOCK_CLIENT(client); break; default: - logMsg("CAS: bad msg detected\n"); + logMsg("CAS: bad msg detected\n", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); log_header(mp, nmsg); #if 0 /* @@ -351,7 +413,13 @@ camessage(client, recv) * returning ERROR here disconnects * the client with the bad message */ - logMsg("CAS: forcing disconnect ...\n"); + logMsg("CAS: forcing disconnect ...\n", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); return ERROR; } @@ -370,10 +438,10 @@ camessage(client, recv) * * */ -LOCAL void -clear_channel_reply(mp, client) -FAST struct extmsg *mp; -struct client *client; +LOCAL void clear_channel_reply( +struct extmsg *mp, +struct client *client +) { FAST struct extmsg *reply; FAST struct event_ext *pevext; @@ -390,13 +458,19 @@ struct client *client; &client->addrq, mp->m_pciu); if(status < 0){ - logMsg("CAS: Attempt to delete nonexistent channel ignored\n"); + logMsg("CAS: Attempt to delete nonexistent channel ignored\n", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); return; } while (pevext = (struct event_ext *) lstGet(&pciu->eventq)) { - status = db_cancel_event(pevext + 1); + status = db_cancel_event((struct event_block *)(pevext+1)); if (status == ERROR){ taskSuspend(0); } @@ -439,10 +513,10 @@ struct client *client; * Much more efficient now since the event blocks hang off the channel in use * blocks not all together off the client block. */ -LOCAL void -event_cancel_reply(mp, client) - FAST struct extmsg *mp; - struct client *client; +LOCAL void event_cancel_reply( +struct extmsg *mp, +struct client *client +) { FAST struct extmsg *reply; FAST struct event_ext *pevext; @@ -454,7 +528,7 @@ event_cancel_reply(mp, client) pevext; pevext = (struct event_ext *) pevext->node.next) if (pevext->msg.m_available == mp->m_available) { - status = db_cancel_event(pevext + 1); + status = db_cancel_event((struct event_block *)(pevext+1)); if (status == ERROR) taskSuspend(0); lstDelete((LIST *)peventq, (NODE *)pevext); @@ -498,12 +572,12 @@ event_cancel_reply(mp, client) * * */ -LOCAL void -read_reply(pevext, paddr, hold, pfl) -FAST struct event_ext *pevext; -FAST struct db_addr *paddr; -int hold; /* more on the way if true */ -void *pfl; +LOCAL void read_reply( +struct event_ext *pevext, +struct db_addr *paddr, +int hold, /* more on the way if true */ +void *pfl +) { FAST struct extmsg *mp = pevext->mp; FAST struct client *client = pevext->client; @@ -575,10 +649,10 @@ void *pfl; * * */ -LOCAL void -read_sync_reply(mp, client) - FAST struct extmsg *mp; - struct client *client; +LOCAL void read_sync_reply( +struct extmsg *mp, +struct client *client +) { FAST struct extmsg *reply; @@ -603,10 +677,10 @@ read_sync_reply(mp, client) * * */ -LOCAL void -build_reply(mp, client) - FAST struct extmsg *mp; - struct client *client; +LOCAL void build_reply( +struct extmsg *mp, +struct client *client +) { LIST *addrq = &client->addrq; FAST struct extmsg *search_reply; @@ -624,7 +698,12 @@ build_reply(mp, client) if (status < 0) { if (CASDEBUG > 2) logMsg( "CAS: Lookup for channel \"%s\" failed\n", - mp + 1); + (int)(mp+1), + NULL, + NULL, + NULL, + NULL, + NULL); if (mp->m_type == DOREPLY) search_fail_reply(mp, client); return; @@ -730,10 +809,10 @@ build_reply(mp, client) * * */ -LOCAL void -search_fail_reply(mp, client) - FAST struct extmsg *mp; - struct client *client; +LOCAL void search_fail_reply( +struct extmsg *mp, +struct client *client +) { FAST struct extmsg *reply; @@ -759,12 +838,12 @@ search_fail_reply(mp, client) * send buffer lock must be on while in this routine * */ -LOCAL void -send_err(curp, status, client, footnote) - struct extmsg *curp; - int status; - struct client *client; - char *footnote; +LOCAL void send_err( +struct extmsg *curp, +int status, +struct client *client, +char *footnote +) { FAST struct extmsg *reply; FAST int size; @@ -819,20 +898,26 @@ send_err(curp, status, client, footnote) * Debug aid - print the header part of a message. * */ -LOCAL void -log_header (mp, mnum) -FAST struct extmsg *mp; -int mnum; +LOCAL void log_header( +struct extmsg *mp, +int mnum +) { logMsg( "CAS: N=%d cmd=%d type=%d pstsize=%d paddr=%x avail=%x\n", mnum, mp->m_cmmd, mp->m_type, mp->m_postsize, - MPTOPADDR(mp), - mp->m_available); + (int)MPTOPADDR(mp), + (int)mp->m_available); if(mp->m_cmmd==IOC_WRITE && mp->m_type==DBF_STRING) - logMsg("CAS: The string written: %s \n",mp+1); + logMsg("CAS: The string written: %s \n", + (int)(mp+1), + NULL, + NULL, + NULL, + NULL, + NULL); } @@ -843,9 +928,9 @@ int mnum; * * lock must be applied while in this routine */ -void -cas_send_heartbeat(pc) -struct client *pc; +void cas_send_heartbeat( +struct client *pc +) { FAST struct extmsg *reply; diff --git a/src/rsrv/camsgtask.c b/src/rsrv/camsgtask.c index 9448a09d3..ad73d0640 100644 --- a/src/rsrv/camsgtask.c +++ b/src/rsrv/camsgtask.c @@ -49,10 +49,18 @@ static char *sccsId = "@(#)camsgtask.c 1.13\t11/20/92"; #include #include #include +#include #include #include #include #include +#include +#include +#include +#include +#include + +#include #include #include #include @@ -64,15 +72,16 @@ static char *sccsId = "@(#)camsgtask.c 1.13\t11/20/92"; * * CA server TCP client task (one spawned for each client) */ -void camsgtask(sock) +int camsgtask(sock) FAST int sock; { int nchars; FAST int status; - FAST struct client *client = NULL; + FAST struct client *client; int i; int true = TRUE; + client = NULL; /* * see TCP(4P) this seems to make unsollicited single events much @@ -82,12 +91,18 @@ FAST int sock; sock, IPPROTO_TCP, TCP_NODELAY, - &true, + (char *)&true, sizeof true); if(status == ERROR){ - logMsg("CAS: TCP_NODELAY option set failed\n"); + logMsg("CAS: TCP_NODELAY option set failed\n", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); close(sock); - return; + return ERROR; } @@ -99,12 +114,18 @@ FAST int sock; sock, SOL_SOCKET, SO_KEEPALIVE, - &true, + (char *)&true, sizeof true); if(status == ERROR){ - logMsg("CAS: SO_KEEPALIVE option set failed\n"); + logMsg("CAS: SO_KEEPALIVE option set failed\n", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); close(sock); - return; + return ERROR; } #ifdef MATCHING_BUFFER_SIZES @@ -120,9 +141,15 @@ FAST int sock; &i, sizeof(i)); if(status < 0){ - logMsg("CAS: SO_SNDBUF set failed\n"); + logMsg("CAS: SO_SNDBUF set failed\n", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); close(sock); - return; + return ERROR; } i = MAX_MSG_SIZE; status = setsockopt( @@ -132,9 +159,15 @@ FAST int sock; (char *)&i, sizeof(i)); if(status < 0){ - logMsg("CAS: SO_RCVBUF set failed\n"); + logMsg("CAS: SO_RCVBUF set failed\n", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); close(sock); - return; + return ERROR; } #endif @@ -144,28 +177,66 @@ FAST int sock; */ client = (struct client *) create_udp_client(NULL); if (!client) { - logMsg("CAS: client init failed\n"); + logMsg("CAS: client init failed\n", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); close(sock); - return; + return ERROR; + } + + taskwdInsert( (int)taskIdCurrent, + NULL, + NULL); + + status = udp_to_tcp(client, sock); + if(status<0){ + logMsg("CAS: TCP convert failed\n", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); + free_client(client); + return ERROR; } - udp_to_tcp(client, sock); i = sizeof(client->addr); status = getpeername( sock, - &client->addr, + (struct sockaddr *)&client->addr, &i); if(status == ERROR){ - logMsg("CAS: peer address fetch failed\n"); + logMsg("CAS: peer address fetch failed\n", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); free_client(client); - return; + return ERROR; } if(CASDEBUG>0){ - logMsg( "CAS: Recieved connection request\n"); + logMsg( "CAS: Recieved connection request\n", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); logMsg( "from addr %x, port %x \n", - client->addr.sin_addr, - client->addr.sin_port); + client->addr.sin_addr.s_addr, + client->addr.sin_port, + NULL, + NULL, + NULL, + NULL); } LOCK_CLIENTQ; @@ -174,9 +245,15 @@ FAST int sock; client->evuser = (struct event_user *) db_init_events(); if (!client->evuser) { - logMsg("CAS: unable to init the event facility\n"); + logMsg("CAS: unable to init the event facility\n", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); free_client(client); - return; + return ERROR; } status = db_start_events( client->evuser, @@ -185,9 +262,15 @@ FAST int sock; NULL, 1); /* one priority notch lower */ if (status == ERROR) { - logMsg("CAS: unable to start the event facility\n"); + logMsg("CAS: unable to start the event facility\n", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); free_client(client); - return; + return ERROR; } client->recv.cnt = 0; @@ -201,14 +284,20 @@ FAST int sock; 0); if (nchars==0){ if(CASDEBUG>0){ - logMsg("CAS: nill message disconnect\n"); + logMsg("CAS: nill message disconnect\n", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); } break; } else if(nchars<=0){ long anerrno; - anerrno = errnoGet(taskIdSelf()); + anerrno = errnoGet(); /* * normal conn lost conditions @@ -220,7 +309,12 @@ FAST int sock; logMsg( "CAS: client disconnect(errno=%d)\n", - anerrno); + anerrno, + NULL, + NULL, + NULL, + NULL, + NULL); } break; @@ -228,6 +322,7 @@ FAST int sock; client->ticks_at_last_io = tickGet(); client->recv.cnt += nchars; + status = camessage(client, &client->recv); if(status == OK){ unsigned bytes_left; @@ -264,22 +359,26 @@ FAST int sock; break; } - /* * allow message to batch up if more are comming */ - status = ioctl(sock, FIONREAD, &nchars); + status = ioctl(sock, FIONREAD, (int)&nchars); if (status < 0) { logMsg("CAS: io ctl err %d\n", - errnoGet(taskIdSelf())); + errnoGet(), + NULL, + NULL, + NULL, + NULL, + NULL); cas_send_msg(client, TRUE); } else if (nchars == 0){ cas_send_msg(client, TRUE); } - } free_client(client); -} + return OK; +} diff --git a/src/rsrv/caserverio.c b/src/rsrv/caserverio.c index 974c39a66..5edc5f39e 100644 --- a/src/rsrv/caserverio.c +++ b/src/rsrv/caserverio.c @@ -45,8 +45,15 @@ static char *sccsId = "@(#)caserverio.c 1.10\t7/28/92"; #include #include #include +#include +#include +#include +#include +#include + #include + /* * @@ -62,14 +69,23 @@ int lock_needed; if(CASDEBUG>2){ logMsg( "CAS: Sending a message of %d bytes\n", - pclient->send.cnt); + pclient->send.cnt, + NULL, + NULL, + NULL, + NULL, + NULL); } if(pclient->disconnect){ if(CASDEBUG>2){ logMsg( "CAS: msg Discard for sock %d addr %x\n", pclient->sock, - pclient->addr.sin_addr.s_addr); + pclient->addr.sin_addr.s_addr, + NULL, + NULL, + NULL, + NULL); } return; } @@ -86,13 +102,13 @@ int lock_needed; pclient->send.buf, pclient->send.cnt, NULL, - &pclient->addr, + (struct sockaddr *)&pclient->addr, sizeof(pclient->addr)); if(status != pclient->send.cnt){ if(status < 0){ int anerrno; - anerrno = errnoGet(taskIdSelf()); + anerrno = errnoGet(); if( (anerrno!=ECONNABORTED&& anerrno!=ECONNRESET&& @@ -102,7 +118,12 @@ int lock_needed; logMsg( "CAS: client unreachable (errno=%d)\n", - anerrno); + anerrno, + NULL, + NULL, + NULL, + NULL, + NULL); } pclient->disconnect = TRUE; if(pclient==prsrv_cast_client){ @@ -113,7 +134,11 @@ int lock_needed; logMsg( "CAS: blk sock partial send: req %d sent %d \n", pclient->send.cnt, - status); + status, + NULL, + NULL, + NULL, + NULL); } } diff --git a/src/rsrv/caservertask.c b/src/rsrv/caservertask.c index f18602f7c..c0c983706 100644 --- a/src/rsrv/caservertask.c +++ b/src/rsrv/caservertask.c @@ -40,6 +40,7 @@ * .08 joh 021492 cleaned up terminate_one_client() * .09 joh 022092 print free list statistics in client_stat() * .10 joh 022592 print more statistics in client_stat() + * .11 joh 073093 added args to taskSpawn for v5.1 vxWorks */ static char *sccsId = "@(#)caservertask.c 1.13\t7/28/92"; @@ -48,14 +49,25 @@ static char *sccsId = "@(#)caservertask.c 1.13\t7/28/92"; #include #include #include +#include #include #include +#include +#include +#include +#include +#include +#include +#include +#include + +#include #include #include #include -LOCAL int terminate_one_client(); -LOCAL void log_one_client(); +LOCAL int terminate_one_client(struct client *client); +LOCAL void log_one_client(struct client *client); /* @@ -68,49 +80,79 @@ LOCAL void log_one_client(); * handle each of them * */ -void -req_server() +int req_server(void) { struct sockaddr_in serverAddr; /* server's address */ - FAST struct client *client; - FAST int status; - FAST int i; + int status; + int i; if (IOC_sock != 0 && IOC_sock != ERROR) if ((status = close(IOC_sock)) == ERROR) - logMsg("CAS: Unable to close open master socket\n"); + logMsg( "CAS: Unable to close open master socket\n", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); /* * Open the socket. Use ARPA Internet address format and stream * sockets. Format described in . */ if ((IOC_sock = socket(AF_INET, SOCK_STREAM, 0)) == ERROR) { - logMsg("CAS: Socket creation error\n"); + logMsg("CAS: Socket creation error\n", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); taskSuspend(0); } + taskwdInsert((int)taskIdCurrent,NULL,NULL); + /* Zero the sock_addr structure */ - bfill(&serverAddr, sizeof(serverAddr), 0); + bfill((char *)&serverAddr, sizeof(serverAddr), 0); serverAddr.sin_family = AF_INET; serverAddr.sin_port = CA_SERVER_PORT; /* get server's Internet address */ - if (bind(IOC_sock, &serverAddr, sizeof(serverAddr)) == ERROR) { - logMsg("CAS: Bind error\n"); + if (bind(IOC_sock, (struct sockaddr *)&serverAddr, sizeof(serverAddr)) == ERROR) { + logMsg("CAS: Bind error\n", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); close(IOC_sock); taskSuspend(0); } /* listen and accept new connections */ if (listen(IOC_sock, 10) == ERROR) { - logMsg("CAS: Listen error\n"); + logMsg("CAS: Listen error\n", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); close(IOC_sock); taskSuspend(0); } while (TRUE) { if ((i = accept(IOC_sock, NULL, 0)) == ERROR) { - logMsg("CAS: Accept error\n"); + logMsg("CAS: Accept error\n", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); taskSuspend(0); } else { status = taskSpawn(CA_CLIENT_NAME, @@ -118,10 +160,31 @@ req_server() CA_CLIENT_OPT, CA_CLIENT_STACK, (FUNCPTR) camsgtask, - i); + i, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); if (status == ERROR) { - logMsg("CAS: task creation failed\n"); - logMsg("CAS: (client ignored)\n"); + logMsg("CAS: task creation failed\n", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); + logMsg("CAS: (client ignored)\n", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); printErrno(errnoGet()); close(i); } @@ -135,9 +198,7 @@ req_server() * free_client() * */ -STATUS -free_client(client) -register struct client *client; +int free_client(struct client *client) { if (client) { /* remove it from the list of clients */ @@ -168,15 +229,15 @@ register struct client *client; UNLOCK_CLIENTQ; } + + return OK; } /* * TERMINATE_ONE_CLIENT */ -LOCAL int -terminate_one_client(client) -register struct client *client; +LOCAL int terminate_one_client(struct client *client) { FAST int servertid; FAST int tmpsock; @@ -185,14 +246,26 @@ register struct client *client; FAST struct channel_in_use *pciu; if (client->proto != IPPROTO_TCP) { - logMsg("CAS: non TCP client delete ignored\n"); + logMsg("CAS: non TCP client delete ignored\n", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); return ERROR; } tmpsock = client->sock; if(CASDEBUG>0){ - logMsg("CAS: Connection %d Terminated\n", tmpsock); + logMsg("CAS: Connection %d Terminated\n", + tmpsock, + NULL, + NULL, + NULL, + NULL, + NULL); } /* @@ -201,6 +274,7 @@ register struct client *client; servertid = client->tid; if (servertid != taskIdSelf()){ if (taskIdVerify(servertid) == OK){ + taskwdRemove(servertid); if (taskDelete(servertid) == ERROR) { printErrno(errnoGet()); } @@ -211,7 +285,8 @@ register struct client *client; while (pciu = (struct channel_in_use *) pciu->node.next){ while (pevext = (struct event_ext *) lstGet((LIST *)&pciu->eventq)) { - status = db_cancel_event(pevext + 1); + status = db_cancel_event( + (struct event_block *)(pevext + 1)); if (status == ERROR) taskSuspend(0); FASTLOCK(&rsrv_free_eventq_lck); @@ -226,7 +301,13 @@ register struct client *client; taskSuspend(0); } if (close(tmpsock) == ERROR) /* close socket */ - logMsg("CAS: Unable to close socket\n"); + logMsg("CAS: Unable to close socket\n", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); /* free dbaddr str */ FASTLOCK(&rsrv_free_addrq_lck); @@ -236,7 +317,13 @@ register struct client *client; FASTUNLOCK(&rsrv_free_addrq_lck); if(FASTLOCKFREE(&client->lock)<0){ - logMsg("CAS: couldnt free sem\n"); + logMsg("CAS: couldnt free sem\n", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); } return OK; @@ -247,8 +334,7 @@ register struct client *client; * client_stat() * */ -STATUS -client_stat() +int client_stat(void) { int bytes_reserved; struct client *client; @@ -290,9 +376,7 @@ client_stat() * log_one_client() * */ -LOCAL void -log_one_client(client) -struct client *client; +LOCAL void log_one_client(struct client *client) { struct channel_in_use *pciu; struct sockaddr_in *psaddr; diff --git a/src/rsrv/cast_server.c b/src/rsrv/cast_server.c index 0cbd0472b..d1ada3ae6 100644 --- a/src/rsrv/cast_server.c +++ b/src/rsrv/cast_server.c @@ -56,7 +56,7 @@ * pend which could lock up the cast server. */ -static char *sccsId = "@(#)cast_server.c 1.13\t7/28/92"; +static char *sccsId = "$Id$\t$Date$"; #include #include @@ -65,12 +65,22 @@ static char *sccsId = "@(#)cast_server.c 1.13\t7/28/92"; #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include + +#include #include #include #include -static void clean_addrq(); +LOCAL void clean_addrq(struct client *pclient); @@ -80,8 +90,7 @@ static void clean_addrq(); * service UDP messages * */ -void -cast_server() +int cast_server(void) { struct sockaddr_in sin; FAST int status; @@ -90,11 +99,19 @@ cast_server() int recv_addr_size; unsigned nchars; + taskwdInsert((int)taskIdCurrent,NULL,NULL); + recv_addr_size = sizeof(new_recv_addr); if( IOC_cast_sock!=0 && IOC_cast_sock!=ERROR ) if( (status = close(IOC_cast_sock)) == ERROR ) - logMsg("CAS: Unable to close master cast socket\n"); + logMsg("CAS: Unable to close master cast socket\n", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); /* * Open the socket. @@ -103,21 +120,33 @@ cast_server() */ if((IOC_cast_sock = socket (AF_INET, SOCK_DGRAM, 0)) == ERROR){ - logMsg("CAS: casts socket creation error\n"); - taskSuspend(0); + logMsg("CAS: casts socket creation error\n", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); + taskSuspend(taskIdSelf()); } /* Zero the sock_addr structure */ - bfill(&sin, sizeof(sin), 0); + bfill((char *)&sin, sizeof(sin), 0); sin.sin_family = AF_INET; sin.sin_addr.s_addr = INADDR_ANY; sin.sin_port = CA_SERVER_PORT; /* get server's Internet address */ - if( bind(IOC_cast_sock, &sin, sizeof (sin)) == ERROR){ - logMsg("CAS: cast bind error\n"); + if( bind(IOC_cast_sock, (struct sockaddr *)&sin, sizeof (sin)) == ERROR){ + logMsg("CAS: cast bind error\n", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); close (IOC_cast_sock); taskSuspend(0); } @@ -128,10 +157,26 @@ cast_server() CA_ONLINE_PRI, CA_ONLINE_OPT, CA_ONLINE_STACK, - (FUNCPTR)rsrv_online_notify_task); + rsrv_online_notify_task, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); if(status<0){ - logMsg("CAS: couldnt start up online notify task\n"); - printErrno(errnoGet ()); + logMsg("CAS: couldnt start up online notify task\n", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); + printErrno(errnoGet()); } @@ -156,25 +201,22 @@ cast_server() prsrv_cast_client->recv.buf, sizeof(prsrv_cast_client->recv.buf), NULL, - &new_recv_addr, + (struct sockaddr *)&new_recv_addr, &recv_addr_size); if(status<0){ logMsg("CAS: UDP recv error (errno=%d)\n", - errnoGet(taskIdSelf())); + errnoGet(), + NULL, + NULL, + NULL, + NULL, + NULL); taskSuspend(0); } prsrv_cast_client->recv.cnt = status; prsrv_cast_client->recv.stk = 0; prsrv_cast_client->ticks_at_last_io = tickGet(); -/* - * - * keeping an eye on the socket library - * - */ -if(sizeof(prsrv_cast_client->addr) != recv_addr_size){ - printf("cast server: addr size has changed?\n"); -} /* * If we are talking to a new client flush the old one @@ -182,8 +224,8 @@ if(sizeof(prsrv_cast_client->addr) != recv_addr_size){ * see if the next message is for this same client. */ status = bcmp( - &prsrv_cast_client->addr, - &new_recv_addr, + (char *)&prsrv_cast_client->addr, + (char *)&new_recv_addr, recv_addr_size); if(status){ /* @@ -195,10 +237,19 @@ if(sizeof(prsrv_cast_client->addr) != recv_addr_size){ if(CASDEBUG>1){ logMsg( "CAS: cast server msg of %d bytes\n", - prsrv_cast_client->recv.cnt); + prsrv_cast_client->recv.cnt, + NULL, + NULL, + NULL, + NULL, + NULL); logMsg( "CAS: from addr %x, port %x \n", - prsrv_cast_client->addr.sin_addr, - prsrv_cast_client->addr.sin_port); + prsrv_cast_client->addr.sin_addr.s_addr, + prsrv_cast_client->addr.sin_port, + NULL, + NULL, + NULL, + NULL); } if(CASDEBUG>2) @@ -213,7 +264,12 @@ if(sizeof(prsrv_cast_client->addr) != recv_addr_size){ logMsg( "CAS: partial UDP msg of %d bytes ?\n", prsrv_cast_client->recv.cnt- - prsrv_cast_client->recv.stk); + prsrv_cast_client->recv.stk, + NULL, + NULL, + NULL, + NULL, + NULL); } } @@ -221,14 +277,18 @@ if(sizeof(prsrv_cast_client->addr) != recv_addr_size){ if(CASDEBUG>2){ logMsg( "CAS: Fnd %d name matches (%d tot)\n", prsrv_cast_client->addrq.count-count, - prsrv_cast_client->addrq.count); + prsrv_cast_client->addrq.count, + NULL, + NULL, + NULL, + NULL); } } /* * allow message to batch up if more are comming */ - status = ioctl(IOC_cast_sock, FIONREAD, &nchars); + status = ioctl(IOC_cast_sock, FIONREAD, (int) &nchars); if(status == ERROR){ taskSuspend(0); } @@ -248,9 +308,8 @@ if(sizeof(prsrv_cast_client->addr) != recv_addr_size){ */ #define TIMEOUT 60 /* sec */ -static void -clean_addrq(pclient) -struct client *pclient; +LOCAL void +clean_addrq(struct client *pclient) { struct channel_in_use *pciu; struct channel_in_use *pnextciu; @@ -289,7 +348,11 @@ struct client *pclient; #ifdef DEBUG logMsg( "CAS: %d CA channels have expired after %d sec\n", ndelete, - maxdelay / sysClkRateGet()); + maxdelay / sysClkRateGet(), + NULL, + NULL, + NULL, + NULL); #endif } } @@ -300,9 +363,7 @@ struct client *pclient; * * */ -struct client -*create_udp_client(sock) -unsigned sock; +struct client *create_udp_client(unsigned sock) { struct client *client; @@ -313,13 +374,25 @@ unsigned sock; if(!client){ client = (struct client *)malloc(sizeof(struct client)); if(!client){ - logMsg("CAS: no mem for new client\n"); + logMsg("CAS: no mem for new client\n", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); return NULL; } } if(CASDEBUG>2) - logMsg( "CAS: Creating new udp client\n"); + logMsg( "CAS: Creating new udp client\n", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); /* * The following inits to zero done instead of a bfill since the send @@ -329,7 +402,7 @@ unsigned sock; */ lstInit(&client->addrq); - bfill(&client->addr, sizeof(client->addr), 0); + bfill((char *)&client->addr, sizeof(client->addr), 0); client->tid = taskIdSelf(); client->send.stk = 0; client->send.cnt = 0; @@ -359,13 +432,21 @@ unsigned sock; * send lock must be applied * */ -int udp_to_tcp(client,sock) -struct client *client; -unsigned sock; +int udp_to_tcp( +struct client *client, +unsigned sock +) { - if(CASDEBUG>2) - logMsg("CAS: converting udp client to tcp\n"); + if(CASDEBUG>2){ + logMsg("CAS: converting udp client to tcp\n", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); + } client->proto = IPPROTO_TCP; client->send.maxstk = MAX_TCP; diff --git a/src/rsrv/online_notify.c b/src/rsrv/online_notify.c index 3a4ac09ea..21e368f79 100644 --- a/src/rsrv/online_notify.c +++ b/src/rsrv/online_notify.c @@ -40,16 +40,22 @@ static char *sccsId = "$Id$\t$Date$"; */ #include #include +#include #include +#include +#include #include +#include +#include /* * EPICS includes */ +#include #include #include -#define abort(A) taskSuspend(0) +#define abort(A) taskSuspend((int)taskIdCurrent) /* @@ -58,7 +64,7 @@ static char *sccsId = "$Id$\t$Date$"; * * */ -void rsrv_online_notify_task() +int rsrv_online_notify_task() { /* * 1 sec init delay @@ -76,7 +82,8 @@ void rsrv_online_notify_task() int sock; struct sockaddr_in lcl; int true = TRUE; - int i; + + taskwdInsert((int)taskIdCurrent,NULL,NULL); /* * Open the socket. @@ -84,59 +91,81 @@ void rsrv_online_notify_task() * Format described in . */ if((sock = socket (AF_INET, SOCK_DGRAM, 0)) == ERROR){ - logMsg("CAS: online socket creation error\n"); + logMsg("CAS: online socket creation error\n", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); abort(0); } status = local_addr(sock, &lcl); if(status<0){ - logMsg("CAS: online notify: Network interface unavailable\n"); + logMsg("CAS: online notify: Network interface unavailable\n", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); abort(0); } status = setsockopt( sock, SOL_SOCKET, SO_BROADCAST, - &true, + (char *)&true, sizeof(true)); if(status<0){ abort(0); } - bfill(&recv_addr, sizeof recv_addr, 0); + bfill((char *)&recv_addr, sizeof recv_addr, 0); recv_addr.sin_family = AF_INET; recv_addr.sin_addr.s_addr = htonl(INADDR_ANY); /* let slib pick lcl addr */ recv_addr.sin_port = htons(0); /* let slib pick port */ - status = bind(sock, &recv_addr, sizeof recv_addr); + status = bind(sock, (struct sockaddr *)&recv_addr, sizeof recv_addr); if(status<0) abort(0); - bfill(&msg, sizeof msg, NULL); + bfill((char *)&msg, sizeof msg, NULL); msg.m_cmmd = htons(IOC_RSRV_IS_UP); msg.m_available = lcl.sin_addr.s_addr; /* Zero the sock_addr structure */ - bfill(&send_addr, sizeof send_addr, 0); + bfill((char *)&send_addr, sizeof send_addr, 0); send_addr.sin_family = AF_INET; send_addr.sin_port = htons(CA_CLIENT_PORT); status = broadcast_addr(&send_addr.sin_addr); if(status<0){ - logMsg("CAS: online notify - no interface to broadcast on\n"); + logMsg("CAS: online notify - no interface to broadcast on\n", + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); abort(0); } while(TRUE){ status = sendto( sock, - &msg, + (char *)&msg, sizeof msg, 0, - &send_addr, + (struct sockaddr *)&send_addr, sizeof send_addr); if(status != sizeof msg){ logMsg( "%s: Socket send error was %d\n", - __FILE__, - errnoGet(taskIdSelf()) ); + (int)__FILE__, + errnoGet(), + NULL, + NULL, + NULL, + NULL); } taskDelay(delay); diff --git a/src/rsrv/rsrv_init.c b/src/rsrv/rsrv_init.c index fb938dea7..a7badd88a 100644 --- a/src/rsrv/rsrv_init.c +++ b/src/rsrv/rsrv_init.c @@ -27,6 +27,7 @@ * * Modification Log: * ----------------- + * .01 073093 Added task spawn args for 5.1 vxworks */ static char *sccsId = "@(#)rsrv_init.c 1.7\t7/28/92"; @@ -37,6 +38,9 @@ static char *sccsId = "@(#)rsrv_init.c 1.7\t7/28/92"; #include #include #include +#include +#include + #include #include #include @@ -51,10 +55,8 @@ if(errnoOfTaskGet(TID)!=ERROR)td(TID); * * */ -rsrv_init() +int rsrv_init() { - FAST struct client *client; - FASTLOCKINIT(&rsrv_free_addrq_lck); FASTLOCKINIT(&rsrv_free_eventq_lck); FASTLOCKINIT(&clientQlock); @@ -73,11 +75,33 @@ rsrv_init() REQ_SRVR_PRI, REQ_SRVR_OPT, REQ_SRVR_STACK, - req_server); + req_server, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); taskSpawn(CAST_SRVR_NAME, CAST_SRVR_PRI, CAST_SRVR_OPT, CAST_SRVR_STACK, - cast_server); + cast_server, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); + + return OK; } diff --git a/src/rsrv/server.h b/src/rsrv/server.h index 9262c67c9..775fb185e 100644 --- a/src/rsrv/server.h +++ b/src/rsrv/server.h @@ -42,24 +42,16 @@ #ifndef INCLserverh #define INCLserverh -static char *serverhSccsId = "@(#)server.h 1.10\t7/28/92"; +static char *serverhSccsId = "$Id$\t$Date$"; -#ifndef INCLfast_lockh -#include -#endif - -#ifndef INCLdb_accessh -#include -#endif - -#ifndef INClstLibh +#include #include -#endif +#include -#ifndef __IOCMSG__ +#include +#include +#include #include -#endif - struct message_buffer{ unsigned stk; @@ -122,7 +114,6 @@ char get; /* T: get F: monitor */ # define GLBLTYPE extern # define GLBLTYPE_INIT(A) #endif -LOCAL keyed; GLBLTYPE int IOC_sock; GLBLTYPE int IOC_cast_sock; @@ -162,14 +153,27 @@ FASTUNLOCK(&(CLIENT)->lock); #define UNLOCK_CLIENTQ FASTUNLOCK(&clientQlock) struct client *existing_client(); -void camsgtask(); -void req_server(); -void cast_server(); +int camsgtask(); void cas_send_msg(); struct extmsg *cas_alloc_msg(); -void rsrv_online_notify_task(); -struct client *create_udp_client(); +int rsrv_online_notify_task(); void cac_send_heartbeat(); +int client_stat(void); +int req_server(void); +int cast_server(void); +int free_client(struct client *client); +struct client *create_udp_client(unsigned sock); +int udp_to_tcp(struct client *client, unsigned sock); + +int camessage( +struct client *client, +struct message_buffer *recv +); + +void cas_send_heartbeat( +struct client *pc +); + #endif INCLserverh