rsrv: casr show multiple UDP clients

This commit is contained in:
Michael Davidsaver
2016-01-11 20:59:07 -05:00
parent e805abe971
commit cb965611ce
3 changed files with 39 additions and 8 deletions
+30 -6
View File
@@ -266,6 +266,7 @@ int rsrv_init (void)
clientQlock = epicsMutexMustCreate();
ellInit ( &clientQ );
ellInit ( &clientQudp );
freeListInitPvt ( &rsrvClientFreeList, sizeof(struct client), 8 );
freeListInitPvt ( &rsrvChanFreeList, sizeof(struct channel_in_use), 512 );
freeListInitPvt ( &rsrvEventFreeList, sizeof(struct event_ext), 512 );
@@ -498,13 +499,36 @@ void casr (unsigned level)
log_one_client(client, level);
client = (struct client *) ellNext(&client->node);
}
UNLOCK_CLIENTQ
/*
if (level>=2 && prsrv_cast_client) {
printf( "UDP Server:\n" );
log_one_client(prsrv_cast_client, level);
if (level>=2) {
client = (struct client *) ellNext ( &clientQudp.node );
while (client) {
struct sockaddr_in addr;
osiSocklen_t alen = sizeof(addr);
char buf[40];
if (!getsockname(client->udpRecv, (struct sockaddr*)&addr, &alen)) {
ipAddrToDottedIP (&addr, buf, sizeof(buf));
} else {
strcpy(buf, "<unknown>");
}
printf( "UDP Name Server: recvfrom %s", buf );
alen = sizeof(addr);
if (!getsockname(client->sock, (struct sockaddr*)&addr, &alen)) {
ipAddrToDottedIP (&addr, buf, sizeof(buf));
} else {
strcpy(buf, "<unknown>");
}
printf( " sendto %s\n", buf );
client = (struct client *) ellNext(&client->node);
}
}
*/
UNLOCK_CLIENTQ
if (level>=2u) {
bytes_reserved = 0u;
bytes_reserved += sizeof (struct client) *
+6
View File
@@ -195,6 +195,12 @@ void cast_server(void *pParm)
}
epicsThreadSleep(300.0);
}
client->udpRecv = recv_sock;
assert(client->node.next==NULL && client->node.previous==NULL);
LOCK_CLIENTQ;
ellAdd ( &clientQudp, &client->node );
UNLOCK_CLIENTQ;
casAttachThreadToClient ( client );
+3 -2
View File
@@ -88,7 +88,7 @@ typedef struct client {
char *pUserName;
char *pHostName;
epicsEventId blockSem; /* used whenever the client blocks */
SOCKET sock;
SOCKET sock, udpRecv;
int proto;
epicsThreadId tid;
unsigned minor_version_number;
@@ -166,7 +166,8 @@ enum ctl {ctlInit, ctlRun, ctlPause, ctlExit};
GLBLTYPE int CASDEBUG;
GLBLTYPE SOCKET IOC_sock;
GLBLTYPE unsigned short ca_server_port;
GLBLTYPE ELLLIST clientQ; /* locked by clientQlock */
GLBLTYPE ELLLIST clientQ; /* (TCP clients) locked by clientQlock */
GLBLTYPE ELLLIST clientQudp; /* locked by clientQlock */
GLBLTYPE ELLLIST beaconAddrList;
GLBLTYPE ELLLIST casIntfAddrList;
GLBLTYPE epicsMutexId clientQlock;