From 2af98c33c9848c225026d493adfbe8d9ade557d3 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Wed, 8 Nov 2017 09:21:32 -0600 Subject: [PATCH 1/4] std/rec: aSub handle INAM changing outputs Allow EFLG="On Change" to work with INAM. --- src/rec/aSubRecord.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/rec/aSubRecord.c b/src/rec/aSubRecord.c index e3983ed96..ee7f80876 100644 --- a/src/rec/aSubRecord.c +++ b/src/rec/aSubRecord.c @@ -207,6 +207,12 @@ static long init_record(aSubRecord *prec, int pass) } strcpy(prec->onam, prec->snam); prec->oval = prec->val; + for (i = 0; i < NUM_ARGS; i++) { + (&prec->onva)[i] = (&prec->nova)[i]; + memcpy((&prec->ovla)[i], + (&prec->vala)[i], + (&prec->nova)[i]); + } return 0; } From e794639e31559c0b4054ce5c31f46194d93325f1 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Wed, 8 Nov 2017 13:51:08 -0600 Subject: [PATCH 2/4] ioc/db: avoid possible race in db_close_events() lp:1730982 --- src/ioc/db/dbEvent.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/ioc/db/dbEvent.c b/src/ioc/db/dbEvent.c index 5e386dd5c..fb1f3a168 100644 --- a/src/ioc/db/dbEvent.c +++ b/src/ioc/db/dbEvent.c @@ -117,6 +117,8 @@ static char *EVENT_PEND_NAME = "eventTask"; static struct evSubscrip canceledEvent; +static epicsMutexId stopSync; + static unsigned short ringSpace ( const struct event_que *pevq ) { if ( pevq->evque[pevq->putix] == EVENTQEMPTY ) { @@ -258,6 +260,10 @@ dbEventCtx db_init_events (void) { struct event_user * evUser; + if (!stopSync) { + stopSync = epicsMutexMustCreate(); + } + if (!dbevEventUserFreeList) { freeListInitPvt(&dbevEventUserFreeList, sizeof(struct event_user),8); @@ -321,6 +327,8 @@ fail: return NULL; } + + /* intentionally leak stopSync to avoid possible shutdown races */ /* * DB_CLOSE_EVENTS() * @@ -356,11 +364,15 @@ void db_close_events (dbEventCtx ctx) epicsMutexUnlock ( evUser->lock ); + epicsMutexMustLock (stopSync); + epicsEventDestroy(evUser->pexitsem); epicsEventDestroy(evUser->ppendsem); epicsEventDestroy(evUser->pflush_sem); epicsMutexDestroy(evUser->lock); + epicsMutexUnlock (stopSync); + freeListFree(dbevEventUserFreeList, evUser); } @@ -1043,8 +1055,15 @@ static void event_task (void *pParm) taskwdRemove(epicsThreadGetIdSelf()); + /* use stopSync to ensure pexitsem is not destroy'd + * until epicsEventSignal() has returned. + */ + epicsMutexMustLock (stopSync); + epicsEventSignal(evUser->pexitsem); + epicsMutexUnlock(stopSync); + return; } From 52787995757c2f9ec4906cbb6092f1cc4ae0520b Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Wed, 15 Nov 2017 20:59:06 -0600 Subject: [PATCH 3/4] aSubRecord: Copy the right amount of data Initialize OVLx from VALx with NEVx elements, size from FTVx --- src/rec/aSubRecord.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/rec/aSubRecord.c b/src/rec/aSubRecord.c index ee7f80876..087b35d25 100644 --- a/src/rec/aSubRecord.c +++ b/src/rec/aSubRecord.c @@ -208,10 +208,12 @@ static long init_record(aSubRecord *prec, int pass) strcpy(prec->onam, prec->snam); prec->oval = prec->val; for (i = 0; i < NUM_ARGS; i++) { - (&prec->onva)[i] = (&prec->nova)[i]; - memcpy((&prec->ovla)[i], - (&prec->vala)[i], - (&prec->nova)[i]); + epicsUInt32 nev = (&prec->neva)[i]; + + (&prec->onva)[i] = nev; + if (nev) + memcpy((&prec->ovla)[i], (&prec->vala)[i], + dbValueSize((&prec->ftva)[i]) * nev); } return 0; } From db005ac3fe2c1f8755981b6d2576dd7acf2ac6ee Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 17 Nov 2017 14:55:50 -0600 Subject: [PATCH 4/4] RULES_TARGET: Define $(lib)_DIR before it is needed TESTLIBRARY products were being installed, because an executable that was linked to one added a dependency assuming it would be in the INSTALL_LIB directory. The $(lib)_DIR was being set too late for test libraries, so the fallback location was used instead. This fix sets $(lib)_DIR for test libraries before any rules use it. --- configure/RULES_TARGET | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/configure/RULES_TARGET b/configure/RULES_TARGET index f8e44db76..4e9cb6e05 100644 --- a/configure/RULES_TARGET +++ b/configure/RULES_TARGET @@ -38,6 +38,17 @@ $(foreach target, $(PROD) $(TESTPROD), \ #----------------------------------------------------------------------- +# These must be done before PROD2_template +define TESTLIBRARY_template +$(1)_DIR = . +TESTBUILD_LIBRARY += $$(if $$(strip $$($(1)_OBJSNAME) $$(LIBRARY_OBJS)),$(1),) +endef + +$(foreach target, $(TESTLIBRARY), \ + $(eval $(call TESTLIBRARY_template,$(strip $(target))))) + +#----------------------------------------------------------------------- + define TARGET2_template $(1)_LDLIBS += $$($(1)_LIBS) $(1)_LDLIBS += $$(if $$(strip $$($(1)_LIBS_$(OS_CLASS))), \ @@ -123,16 +134,6 @@ $(foreach target, $(LIBRARY), \ #----------------------------------------------------------------------- -define LIBRARY3_template -$(1)_DIR = . -TESTBUILD_LIBRARY += $$(if $$(strip $$($(1)_OBJSNAME) $$(LIBRARY_OBJS)),$(1),) -endef - -$(foreach target, $(TESTLIBRARY), \ - $(eval $(call LIBRARY3_template,$(strip $(target))))) - -#----------------------------------------------------------------------- - define LOADABLE_LIBRARY_template LOADABLE_BUILD_LIBRARY += $$(if $$(strip $$($(1)_OBJSNAME) $$(LIBRARY_OBJS)),$(1),)