Skip to content

Commit

Permalink
iocsh dbLoadGroup() not immediate
Browse files Browse the repository at this point in the history
and enforce ordering wrt. iocInit() and iocShutdown()
  • Loading branch information
mdavidsaver committed Dec 11, 2024
1 parent 28817ae commit 8502f91
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions ioc/groupsourcehooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include <iocsh.h>

#include <initHooks.h>
#include <iocInit.h>
#include <dbAccess.h>

#include <pvxs/source.h>
#include <pvxs/iochooks.h>
Expand All @@ -28,6 +30,9 @@
#if EPICS_VERSION_INT < VERSION_INT(7, 0, 3, 1)
# define iocshSetError(ret) do { (void)ret; }while(0)
#endif
#ifndef ERL_ERROR
# define ERL_ERROR "ERROR"
#endif

// include last to avoid clash of #define printf with other headers
#include <epicsStdio.h>
Expand Down Expand Up @@ -95,6 +100,24 @@ const auto dbLoadGroupMsg =

long dbLoadGroup(const char* jsonFilename, const char* macros) {
try {
/* getIocState() introduced to the 3.15 branch in R3.15.8
* 7.0 branch in R7.0.4
*/
#if EPICS_VERSION_INT >= VERSION_INT(7, 0, 4, 0) \
|| (EPICS_VERSION_INT < VERSION_INT(7, 0, 0, 0) && EPICS_VERSION_INT >= VERSION_INT(3, 15, 8, 0))
if(getIocState() != iocVoid)
#else
if(interruptAccept)
#endif
{
fprintf(stderr,
ERL_ERROR " dbLoadGroup() not allowed in current IOC state (%d).\n"
" Hint: Move before iocInit()\n",
getIocState()
);
return 1;
}

if (!jsonFilename || !jsonFilename[0]) {
fprintf(stderr, "%s\n"
"Error: Missing required JSON filename\n", dbLoadGroupMsg);
Expand Down

0 comments on commit 8502f91

Please sign in to comment.