Experimental Physics and Industrial Control System
Hi Steve,
> I changed caget to caput :)
>
> The value was not written to my ioc
> int main (int argc, char *argv[])
> {
> double data=86;
> chid mychid;
> SEVCHK(ca_create_channel(argv[1], NULL, NULL, 10,
> &mychid),"failure");
> SEVCHK(ca_pend_io(10.0),"failure");
> SEVCHK(ca_array_put(DBR_DOUBLE, 1, mychid, &data),"failure");
> SEVCHK(ca_pend_io(10.0),"failure");
> }
It's true that ca_pend_io causes an implicit flush to occur (i.e the
equivalent of a call to ca_flush_io).
A call to ca_flush_io is analogous to placing a letter in the mail box.
We know now that the problem of delivery is out of our hands and has been
entrusted to the postal service. So far so good, but the problem in
the above program is that a bomb has been dropped on our local postal
service before the letter can been delivered.
When your program exits from main without calling ca_context_destroy
then the ca client library's send threads are very ungracefully
terminated before they have been given a chance to deliver any
message that they might have in their work queues to TCP. Furthermore,
it is very OS dependent what might happen to any undelivered TCP messages
lingering in the local IP kernel if you exit from main without given the
CA client library an opportunity to close its TCP sockets; we end up
with undefined behavior.
In contrast, if the program calls ca_context_destroy before exiting
from main then the CA client library will gracefully shut down its
worker threads delivering all outstanding messages to the IP kernel
before they exit, and also gracefully close all of its sockets;
now we expect defined behavior.
There is a (very brief) discussion of this issue in the troubleshooting
section of the CA reference manual - which perhaps could be expanded.
The bottom line is if you shouldn’t terminate the local postal service
unless you provide also some additional funding for a close out :-)
Jeff
> -----Original Message-----
> From: [email protected] [mailto:[email protected]]
> On Behalf Of Steve Hunt
> Sent: Tuesday, June 26, 2012 7:49 AM
> To: [email protected]
> Subject: pend_io
>
> I have a problem running a trivial (too trivial it seems) ca client
> program.
>
> I fact I just generated the ca example using makeBaseApp.
>
> I changed caget to caput :)
>
> The value was not written to my ioc
>
> I am running 3.14.12.2, on linux_x86_64 but the behavior seems the same
> in older versions (at least 3.14.9(
>
> I am sending this to core-talk rather than tech-talk as this seems to be
> a real ca problem
>
>
> ##########################################################################
> #######3
> #include <stddef.h>
> #include <stdlib.h>
> #include <stdio.h>
> #include <string.h>
>
> #include <cadef.h>
>
> int main (int argc, char *argv[])
> {
> double data=86;
> chid mychid;
>
> SEVCHK(ca_create_channel(argv[1], NULL, NULL, 10,
> &mychid),"failure");
> SEVCHK(ca_pend_io(10.0),"failure");
>
> SEVCHK(ca_array_put(DBR_DOUBLE, 1, mychid, &data),"failure");
> SEVCHK(ca_pend_io(10.0),"failure");
> // SEVCHK(ca_array_get(DBR_DOUBLE, 1, mychid, &data),"failure");
> // SEVCHK(ca_pend_io(10.0),"failure");
> // SEVCHK(ca_flush_io(),"failure");
> // SEVCHK(ca_poll(),"failure");
>
> // sleep(10);
> // ca_context_destroy();
>
> // return result;
> }
>
>
> When I un-comment ca_poll, ca_context_destroy, ca_get (plus its
> pend_io), or sleep!!! it works!!!
>
> so a ca_poll, a ca_context_destroy, or a ca_pend_io AFTER a ca_get,
> seems to flush the send buffer - but just ca_pend_io, nor ca_flush_io
> seem not to do so.
>
> At least the client example generated from makebaseApp should have a
> ca_put added, and made to work without the ca_get, but perhaps this
> could be considered a bug.
>
>
>
>
>
- Replies:
- Re: pend_io Ernest L. Williams Jr.
- Re: pend_io steve hunt
- References:
- pend_io Steve Hunt
- Navigate by Date:
- Prev:
pend_io Steve Hunt
- Next:
Re: pend_io Ernest L. Williams Jr.
- Index:
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:
pend_io Steve Hunt
- Next:
Re: pend_io Ernest L. Williams Jr.
- Index:
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
<2012>
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024