From c3a29b133b51aed46b9539e53d21ce11df827fa1 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Tue, 30 Oct 2001 00:01:13 +0000 Subject: [PATCH] added warning about direct access to fields in the channel structure --- src/ca/CAref.html | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/ca/CAref.html b/src/ca/CAref.html index 95957f585..bc41a9604 100644 --- a/src/ca/CAref.html +++ b/src/ca/CAref.html @@ -687,7 +687,35 @@ page 24 for more information on this topic.

if ( status != ECA_NORMAL ) { 
        printf("The requested ca_XXXX() operation didn't complete successfully because \"%s\"\n",
                ca_message ( status ) ); 
-
}
+
}
+
+
+ +

In the embryonic stages of EPICS it was a common practice to examine a +channel's connection state, its native type, and its native element count by +directly accessing fields in a structure using a pointer stored in type +chid. Likewise, a user private pointer in the per channel +structure was also commonly set by directly accessing fields in the channel +structure. A number of difficulties arise from this practice, which has long +since been deprecated. For example, in release R3.13 it was recognized that +transient changes in certain private fields in the per channel structure +would make it difficult to reliably test the channels connection state using +these private fields directly. Therefore, in release 3.13 of EPICS the names +of certain fields were changed to discourage the practice of directly +accessing them in application code. In R3.14 codes written this way will not +compile. Be advised that if your CA client tool is touching the fields in the +channel structure directly then portability and robustness will be +compromised. The probability of EPICS minor release upgrade recompilation +dependency will also increase. Codes intending to maintain the highest degree +of portability over a wide range of EPICS versions should be especially +careful. For example such codes should replace all instances of +"channel_id->type" with ca_element_count(channel_id)". This approach +should be reliable on all versions of EPICS in use today. The construct +"ca_puser(chid) = xxxx" is particularly problematic. The best mechanisms for +setting the per channel private pointer will be to pass the user private +pointer in when creating the channel. This approach is implemented on all +versions. Otherwise, you can also use "ca_set_puser(CHID,PUSER), but this +will work only on post beta releases of R3.13 and on R3.14.

Function Call Reference

@@ -709,7 +737,7 @@ channel access calls.

callbacks might be called when the thread that calls this routine is not executing in the CA client library. Programmers who are unfamiliar with mutual exclusion locking in a multi-threaded environment should - specify ca_disable_preemptive_callback.

+ specify ca_disable_preemptive_callback.