From 7a6e11cae0f46cdb4da148c278aed3a6daeadb08 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Thu, 6 Feb 2025 15:32:08 -0800 Subject: [PATCH] make casStatsFetch() safe-ish when RSRV not initialized Maybe too early. Or maybe RSRV disabled via dbServer. --- modules/database/src/ioc/rsrv/camsgtask.c | 2 ++ modules/database/src/ioc/rsrv/caservertask.c | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/modules/database/src/ioc/rsrv/camsgtask.c b/modules/database/src/ioc/rsrv/camsgtask.c index 24df11d39..568adc7d4 100644 --- a/modules/database/src/ioc/rsrv/camsgtask.c +++ b/modules/database/src/ioc/rsrv/camsgtask.c @@ -163,6 +163,8 @@ void camsgtask ( void *pParm ) int casClientInitiatingCurrentThread ( char * pBuf, size_t bufSize ) { + if ( ! rsrvCurrentClient ) + return RSRV_ERROR; /* not yet initialized, or disabled via dbServer */ struct client * pClient = ( struct client * ) epicsThreadPrivateGet ( rsrvCurrentClient ); diff --git a/modules/database/src/ioc/rsrv/caservertask.c b/modules/database/src/ioc/rsrv/caservertask.c index f904d3268..a658c3796 100644 --- a/modules/database/src/ioc/rsrv/caservertask.c +++ b/modules/database/src/ioc/rsrv/caservertask.c @@ -1536,6 +1536,13 @@ struct client *create_tcp_client (SOCKET sock , const osiSockAddr *peerAddr) void casStatsFetch ( unsigned *pChanCount, unsigned *pCircuitCount ) { + if(!clientQlock) { /* not yet initialized, or disabled via dbServer */ + if(pChanCount) + *pChanCount = 0; + if(pCircuitCount) + *pCircuitCount = 0; + return; + } LOCK_CLIENTQ; { int circuitCount = ellCount ( &clientQ );