Protect casStatsFetch() if called before rsrv_init()
Also ensures clientQ is initialized before creating clientQlock. Fixes LP: #1694966
This commit is contained in:
@@ -241,7 +241,6 @@ int rsrv_init (void)
|
||||
|
||||
clientQlock = epicsMutexMustCreate();
|
||||
|
||||
ellInit ( &clientQ );
|
||||
freeListInitPvt ( &rsrvClientFreeList, sizeof(struct client), 8 );
|
||||
freeListInitPvt ( &rsrvChanFreeList, sizeof(struct channel_in_use), 512 );
|
||||
freeListInitPvt ( &rsrvEventFreeList, sizeof(struct event_ext), 512 );
|
||||
@@ -951,16 +950,22 @@ struct client *create_tcp_client ( SOCKET sock )
|
||||
|
||||
void casStatsFetch ( unsigned *pChanCount, unsigned *pCircuitCount )
|
||||
{
|
||||
LOCK_CLIENTQ;
|
||||
if ( ! clientQlock ) {
|
||||
*pCircuitCount = 0;
|
||||
*pChanCount = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
LOCK_CLIENTQ;
|
||||
{
|
||||
int circuitCount = ellCount ( &clientQ );
|
||||
if ( circuitCount < 0 ) {
|
||||
*pCircuitCount = 0;
|
||||
*pCircuitCount = 0;
|
||||
}
|
||||
else {
|
||||
*pCircuitCount = (unsigned) circuitCount;
|
||||
*pCircuitCount = (unsigned) circuitCount;
|
||||
}
|
||||
*pChanCount = rsrvChannelCount;
|
||||
}
|
||||
UNLOCK_CLIENTQ;
|
||||
UNLOCK_CLIENTQ;
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ enum ctl {ctlInit, ctlRun, ctlPause, ctlExit};
|
||||
/* NOTE: external used so they remember the state across loads */
|
||||
#ifdef GLBLSOURCE
|
||||
# define GLBLTYPE
|
||||
# define GLBLTYPE_INIT(A)
|
||||
# define GLBLTYPE_INIT(A) = A
|
||||
#else
|
||||
# define GLBLTYPE extern
|
||||
# define GLBLTYPE_INIT(A)
|
||||
@@ -176,7 +176,7 @@ GLBLTYPE int CASDEBUG;
|
||||
GLBLTYPE SOCKET IOC_sock;
|
||||
GLBLTYPE SOCKET IOC_cast_sock;
|
||||
GLBLTYPE unsigned short ca_server_port;
|
||||
GLBLTYPE ELLLIST clientQ; /* locked by clientQlock */
|
||||
GLBLTYPE ELLLIST clientQ GLBLTYPE_INIT(ELLLIST_INIT);
|
||||
GLBLTYPE ELLLIST beaconAddrList;
|
||||
GLBLTYPE epicsMutexId clientQlock;
|
||||
GLBLTYPE struct client *prsrv_cast_client;
|
||||
|
||||
Reference in New Issue
Block a user