From b5a0657adca57556e1a6378a0ac555d76e8193d3 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 13 May 2016 13:30:55 -0500 Subject: [PATCH 1/2] Applied Till's fix for lp:1581212 --- documentation/RELEASE_NOTES.html | 14 ++++++++++++++ src/db/db_access.c | 9 ++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/documentation/RELEASE_NOTES.html b/documentation/RELEASE_NOTES.html index d6e89cc60..efec011ba 100644 --- a/documentation/RELEASE_NOTES.html +++ b/documentation/RELEASE_NOTES.html @@ -13,6 +13,20 @@ +

Making IOC ca_get operations atomic

+ +

When a CA client gets data from an IOC record using a compound data type such +as DBR_TIME_DOUBLE the value field is fetched from the database in a +separate call than the other metadata, without keeping the record locked. This +allows some other thread such as a periodic scan thread a chance to interrupt +the get operation and process the record in between. CA monitors have always +been atomic as long as the value data isn't a string or an array, but this race +condition in the CA get path has now been fixed so the record will stay locked +between the two fetch operations.

+ +

This fixes +Launchpad bug #1581212, thanks to Till Strauman and Dehong Zhang.

+

New CONFIG_SITE variable for running self-tests

The 'make runtests' and 'make tapfiles' build targets normally only run the diff --git a/src/db/db_access.c b/src/db/db_access.c index d9d0bc83f..07cce3fec 100644 --- a/src/db/db_access.c +++ b/src/db/db_access.c @@ -32,6 +32,7 @@ #include "dbCommon.h" #include "errMdef.h" #include "recSup.h" +#include "dbLock.h" #include "alarm.h" #define db_accessHFORdb_accessC #include "db_access.h" @@ -182,6 +183,8 @@ int epicsShareAPI db_get_field_and_count( * in the dbAccess.c dbGet() and getOptions() routines. */ + dbScanLock(paddr->precord); + switch(buffer_type) { case(oldDBR_STRING): status = dbGetField(paddr, DBR_STRING, pbuffer, &zero, nRequest, pfl); @@ -820,8 +823,12 @@ int epicsShareAPI db_get_field_and_count( } break; default: - return -1; + status = -1; + break; } + + dbScanUnlock(paddr->precord); + if (status) return -1; return 0; } From 6d35ee9c3c5921ba0094f207b334ea8188b73dc0 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 13 May 2016 13:40:37 -0500 Subject: [PATCH 2/2] Move dbLock.h *after* epicsExportSharedSymbols --- src/db/db_access.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/db/db_access.c b/src/db/db_access.c index 07cce3fec..f60696453 100644 --- a/src/db/db_access.c +++ b/src/db/db_access.c @@ -32,15 +32,16 @@ #include "dbCommon.h" #include "errMdef.h" #include "recSup.h" -#include "dbLock.h" #include "alarm.h" #define db_accessHFORdb_accessC #include "db_access.h" #undef db_accessHFORdb_accessC + #define epicsExportSharedSymbols #include "dbNotify.h" #include "dbAccessDefs.h" #include "dbEvent.h" +#include "dbLock.h" #include "db_access_routines.h" #ifndef NULL