/* * printChannelAccessAddressList () */ extern "C" void epicsShareAPI printChannelAccessAddressList ( const ELLLIST *pList ) { osiSockAddrNode *pNode; ::printf ( "Channel Access Address List\n" ); pNode = (osiSockAddrNode *) ellFirst ( pList ); // X aCC 749 while (pNode) { char buf[64]; ipAddrToA ( &pNode->addr.ia, buf, sizeof ( buf ) ); ::printf ( "%s\n", buf ); pNode = (osiSockAddrNode *) ellNext ( &pNode->node ); // X aCC 749 } }
/* * acceptNewClient() * */ static void acceptNewClient ( void *pParam ) { struct ioc_log_server *pserver = (struct ioc_log_server *) pParam; struct iocLogClient *pclient; osiSocklen_t addrSize; struct sockaddr_in addr; int status; osiSockIoctl_t optval; pclient = ( struct iocLogClient * ) malloc ( sizeof ( *pclient ) ); if ( ! pclient ) { return; } addrSize = sizeof ( addr ); pclient->insock = epicsSocketAccept ( pserver->sock, (struct sockaddr *)&addr, &addrSize ); if ( pclient->insock==INVALID_SOCKET || addrSize < sizeof (addr) ) { static unsigned acceptErrCount; static int lastErrno; int thisErrno; free ( pclient ); if ( SOCKERRNO == SOCK_EWOULDBLOCK || SOCKERRNO == SOCK_EINTR ) { return; } thisErrno = SOCKERRNO; if ( acceptErrCount % 1000 || lastErrno != thisErrno ) { fprintf ( stderr, "Accept Error %d\n", SOCKERRNO ); } acceptErrCount++; lastErrno = thisErrno; return; } /* * Set non blocking IO * to prevent dead locks */ optval = TRUE; status = socket_ioctl( pclient->insock, FIONBIO, &optval); if(status<0){ char sockErrBuf[64]; epicsSocketConvertErrnoToString ( sockErrBuf, sizeof ( sockErrBuf ) ); fprintf(stderr, "%s:%d ioctl FBIO client er %s\n", __FILE__, __LINE__, sockErrBuf); epicsSocketDestroy ( pclient->insock ); free(pclient); return; } pclient->pserver = pserver; pclient->nChar = 0u; ipAddrToA (&addr, pclient->name, sizeof(pclient->name)); logTime(pclient); #if 0 status = fprintf( pclient->pserver->poutfile, "%s %s ----- Client Connect -----\n", pclient->name, pclient->ascii_time); if(status<0){ handleLogFileError(); } #endif /* * turn on KEEPALIVE so if the client crashes * this task will find out and exit */ { long true = 1; status = setsockopt( pclient->insock, SOL_SOCKET, SO_KEEPALIVE, (char *)&true, sizeof(true) ); if(status<0){ fprintf(stderr, "Keepalive option set failed\n"); } } status = shutdown(pclient->insock, SHUT_WR); if(status<0){ char sockErrBuf[64]; epicsSocketConvertErrnoToString ( sockErrBuf, sizeof ( sockErrBuf ) ); fprintf (stderr, "%s:%d shutdown err %s\n", __FILE__, __LINE__, sockErrBuf); epicsSocketDestroy ( pclient->insock ); free(pclient); return; } status = fdmgr_add_callback( pserver->pfdctx, pclient->insock, fdi_read, readFromClient, pclient); if (status<0) { epicsSocketDestroy ( pclient->insock ); free(pclient); fprintf(stderr, "%s:%d client fdmgr_add_callback() failed\n", __FILE__, __LINE__); return; } }
int epicsShareAPI logAlarmsReport ( int interest ) { char inetAddr[32]; int serverId; if (!initialized) { printf ("logAlarms utility is not initialized! Use logAlarmsInit.\n"); return OK; } printf ("logAlarmsReport! use level parameter of [0..4]\n"); printf ("\n%d servers are configured\n", numServersConfigured); printf ("%d messages have been lost\n", msgLost); if (serverSelected >= 0) printf ("\nThe server number %d is selected\n", serverSelected); else printf ("\nNo server is selected\n"); if (interest > 0 && numServersConfigured > 0) { if (numServersConfigured > 0) printf ("\nConfigured Servers\n"); for (serverId=0; serverId < numServersConfigured; serverId++) { ipAddrToA (&msgServerAddr[serverId], inetAddr, 32); printf ("Server %d: %s ", serverId, inetAddr); if (serverId == serverSelected) printf ("selected + "); if (serverStatus[serverId].up) printf ("online\n"); else printf ("offline\n"); } printf ("\nMessage port: %d Command port: %d\n", msg_port, cmd_port); } if (interest > 1) { printf ("\nRing buffer size is %d messages\n", ringSize); printf ("Ring base area is %d messages, extention is %d\n", ringHighWater, ringSize - ringHighWater); } printf ("\nRing buffer usage: %ld messages are waiting in the ring buffer\n", (long)RINGPOS(pRingWrite)); if (interest > 3) { printf ("\nRing address is 0x%lx\n", (unsigned long)pRingBottom); printf ("Read pointer: 0x%lx Write pointer: 0x%lx\n", (unsigned long)pRingRead, (unsigned long)pRingWrite); printf ("\nTiming: Initial wait time: %ld ticks\n", tickInitWait); printf (" Max time between beacons: %ld ticks\n", tickMaxSilent); printf (" Timeout waiting for message replies: %ld ticks\n", tickMessageReplyTmo); printf (" Timeout waiting for beacon replies: %ld ticks\n", tickBeaconReplyTmo); } if (interest > 2) { printf ("\nThe hash facility to find messages in the ring buffer:\n"); if (pbuck) bucketShow (pbuck); else printf ("Hash table not created\n"); } return OK; }