Hi Michael,
On 2013-04-19 [email protected] wrote:
> I've just discovered that calling ca_context_create(1) after iocInit()
> appears to succeed (it returns ECA_NORMAL) ... but the resulting context
> is not very healthy! In my particular case I find that
> ca_array_get_callback delivers zero length data, but I expect other deeper
> problems are to be found.
Is your code running in the main thread, or its own private thread? If this
is a private thread then Mark's comment applies — you must ensure that the
thread does not call any other CA functions before ca_context_create() is run.
If this code is running in the IOC's main thread then that's a different
issue; I'm not sure what context the main IOC thread belongs to, if any, but
you probably can't assume that code running after iocInit is the first routine
to create a CA context for the main thread.
> I understand that I need to call ca_context_create() a good deal earlier,
> but I don't really understand why it appears to succeed -- is it possible
> for an error code to be returned instead, please? (In some future version
> of EPICS, I'm testing this on 3.14.11.)
It does return a status, but it is not a failure to have multiple contexts
running in a process at the same time. I'm guessing that the API can't
distinguish your case from a more advanced user, so it's quite happy to do
what you asked.
> Alternatively, is there some reliable way I can test whether it has
> succeeded? I don't have full control over when my library is initialised,
> so detecting an error immediately would be more friendly to the user.
You can use ca_current_context() to find out if there is context set for the
current thread yet. This returns a NULL pointer if no context has been
created yet. If the result is not NULL you may be able to use the
undocumented (and mis-spelled) routine (with a prototype in cadef.h)
int ca_preemtive_callback_is_enabled(void);
to find out whether that context is preemptive or not.
HTH,
- Andrew
--
It is difficult to get a man to understand something, when his salary
depends upon his not understanding it. -- Upton Sinclair
- Replies:
- RE: Calling ca_context_create(1) too late michael.abbott
- RE: Calling ca_context_create(1) too late michael.abbott
- References:
- Calling ca_context_create(1) too late michael.abbott
- Navigate by Date:
- Prev:
RE: Calling ca_context_create(1) too late Mark Rivers
- Next:
Re: Add choice to dbd file Andrew Johnson
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
<2013>
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
RE: Calling ca_context_create(1) too late michael.abbott
- Next:
RE: Calling ca_context_create(1) too late michael.abbott
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
<2013>
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
|