Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  <2017 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
<== Date ==> <== Thread ==>

Subject: Re: remnant errlog thread
From: "Johnson, Andrew N." <anj@aps.anl.gov>
To: Al Honey <ahoney@keck.hawaii.edu>
Cc: "tech-talk@aps.anl.gov" <tech-talk@aps.anl.gov>
Date: Fri, 11 Aug 2017 05:11:59 +0000
It sounds like you should be explicitly creating and saving your own client context pointer at the startup of that RPC program and then attaching to it from each operation which needs do to CA. See the CA Reference manual starting at http://www.aps.anl.gov/epics/base/R3-15/5-docs/CAref.html#Thread and linked routines. These APIs date back to early Base-3.14.

HTH,

- Andrew

-- 
Sent from my iPad

On Aug 11, 2017, at 1:06 AM, Al Honey <ahoney@keck.hawaii.edu> wrote:

Hi Andrew

The persistent task is an RPC program so it is inherently multi-threaded  – each client request is essentially a new RPC thread.

So, I have one persistent CA context alive in one thread to deal with asynchronous updates then, as each RPC request comes in, to read or write a channel, I open and close a new CA connection.

I have tried to simply have one CA context and then use that in each of the client RPC calls (threads) but ca_current_context() returns NULL.

Is there some other CA call that will return the existing context?

 

Al

 

 

From: Johnson, Andrew N. [mailto:anj@aps.anl.gov]
Sent: Thursday, August 10, 2017 1:52 PM
To: Al Honey
Cc: tech-talk@aps.anl.gov
Subject: Re: remnant errlog thread

 

Hi Al,

 

Have you tried keeping the CA context alive for the life of the persistent task? I don't see why you would want/need to repeatedly create and destroy the context, and it seems likely to me that's what is restarting the errlog thread, although I can't explain why (unless you are manually loading and unloading the libCom.so library as well). I think the CA library's IOC detection logic will work better if allowed to stay alive, as long as your network connection isn't going up and down as well.

 

HTH,

- Andrew

 

-- 

Sent from my iPad


On Aug 10, 2017, at 10:02 PM, Al Honey <ahoney@keck.hawaii.edu> wrote:

Hi

I have a persistent task, which opens and closes connections to various IOCs (other services as well) per client requests.

Seems that each open/close cycle causes another thread to be created and it never terminates – errlogThread.  I suspect there is one more step I need to perform when ‘closing’ a connection.

 

This the output from gdb for one of the remnant threads:

#0  0x00007f122a317705 in pthread_cond_wait@@GLIBC_2.3.2 ()

   from /lib64/libpthread.so.0

#1  0x00007f1227ee8099 in condWait (mutexId=0x12c6300, condId=0x12c6328)

    at ../../../src/libCom/osi/os/posix/osdEvent.c:75

#2  epicsEventWait (pevent=0x12c6300)

    at ../../../src/libCom/osi/os/posix/osdEvent.c:137

#3  0x00007f1227ed269e in errlogThread ()

    at ../../../src/libCom/error/errlog.c:491

#4  0x00007f1227ee5e6f in start_routine (arg=0x12ca420)

    at ../../../src/libCom/osi/os/posix/osdThread.c:385

#5  0x00007f122a313df5 in start_thread () from /lib64/libpthread.so.0

#6  0x00007f122950c1ad in clone () from /lib64/libc.so.6

 

Using R3.14.12.5

This is my process for opening a connection:

ca_context_create

ca_add_exception_event

ca_add_fd_registration

 

for each channel:

  ca_search_and_connect

  ca_add_masked_array_event

 

This is my process for closing a connection:

for each channel:

  ca_clear_event

  ca_clear_channel

 

ca_flush_io

ca_context_destroy

 

What did I miss?

 

Thanks for any help,

Al

 


References:
remnant errlog thread Al Honey
Re: remnant errlog thread Johnson, Andrew N.
RE: remnant errlog thread Al Honey

Navigate by Date:
Prev: RE: remnant errlog thread Al Honey
Next: Archive Dump on Change Only Hidas, Dean
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
Navigate by Thread:
Prev: RE: remnant errlog thread Al Honey
Next: Archive Dump on Change Only Hidas, Dean
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
ANJ, 13 Aug 2017 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·