dbLink: Clarify meaning of lset isConstant and isVolatile flags

Modify dbIsLinkConnected() to check lset->isVolatile first.
This commit is contained in:
Andrew Johnson
2018-03-31 15:42:35 +01:00
parent 97ea68d40c
commit ca2003bb63
2 changed files with 14 additions and 3 deletions

View File

@@ -265,8 +265,19 @@ int dbIsLinkConnected(const struct link *plink)
{
lset *plset = plink->lset;
if (!plset || !plset->isConnected)
if (!plset)
return FALSE;
if (!plset->isVolatile)
return TRUE;
if (!plset->isConnected) {
struct dbCommon *precord = plink->precord;
errlogPrintf("dbLink: Link type for '%s.%s' is volatile but has no"
" lset::isConnected() method\n",
precord->name, link_field_name(plink));
return FALSE;
}
return plset->isConnected(plink);
}

View File

@@ -31,8 +31,8 @@ typedef long (*dbLinkUserCallback)(struct link *plink, void *priv);
typedef struct lset {
/* Characteristics of the link type */
const unsigned isConstant:1;
const unsigned isVolatile:1;
const unsigned isConstant:1; /* 1 means value doesn't change */
const unsigned isVolatile:1; /* 0 means link always connected */
/* Activation */
void (*openLink)(struct link *plink);