EPICS Controls 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  2018  2019  2020  2021  <20222023  2024  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  <20222023  2024 
<== Date ==> <== Thread ==>

Subject: Re: How to safely implement an asynPortDriver with SCAN records
From: Andrew Johnson via Tech-talk <tech-talk at aps.anl.gov>
To: Érico Nogueira Rolim <erico.rolim at lnls.br>, Mark Rivers <rivers at cars.uchicago.edu>
Cc: tech-talk <tech-talk at aps.anl.gov>
Date: Fri, 8 Jul 2022 12:43:02 -0500
On 7/8/22 12:27 PM, Érico Nogueira Rolim via Tech-talk wrote:
Thank you for the quick answer!

On 08/07/2022 12:23, Mark Rivers wrote:

Hi Érico,

 

The asynPort driver base class does not have an exit handler to destroy itself when the IOC is exiting, that is left to derived classes.  Does your derived class establish an exit handler with epicsAtExit?  

 

What leads you to believe that the asynPortDriver destructor is being called?


I'm sorry for the confusion, I meant to say that the destructor for our class that's derived from asynPortDriver is called. And indeed, we have its destructor registered with epicsAtExit (a bit ugly):


static void exitHandlerC(void *pPvt)    
{                                       
    drvFOFB *pdrvFOFB = (drvFOFB *)pPvt;
    pdrvFOFB->~drvFOFB();      
}                                      


We do this because the destructor is responsible for closing quite a few resources before we exit. I'm open to suggestions on better ways to do this.


Not sure if this is relevant, but when do you register that exit handler? The registered epicsAtExit() routines are called in the reverse order in which they were added, so to ensure that your shutdown routines are called before any that the IOC or asyn registers you should register yours afterwards. Calling epicsAtExit() from a static C++ constructor is likely to cause these kinds of problems, if that's where you put it try moving that to a routine which gets run from a command in your st.cmd file (in general a driver that needs one should register an exit routine for each device as it gets created by the associated st.cmd command).

HTH,

- Andrew

-- 
Complexity comes for free, Simplicity you have to work for.

Replies:
RE: How to safely implement an asynPortDriver with SCAN records Mark Rivers via Tech-talk
References:
How to safely implement an asynPortDriver with SCAN records Érico Nogueira Rolim via Tech-talk
RE: How to safely implement an asynPortDriver with SCAN records Mark Rivers via Tech-talk
Re: How to safely implement an asynPortDriver with SCAN records Érico Nogueira Rolim via Tech-talk

Navigate by Date:
Prev: Re: How to safely implement an asynPortDriver with SCAN records Érico Nogueira Rolim via Tech-talk
Next: RE: How to safely implement an asynPortDriver with SCAN records Mark Rivers via Tech-talk
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  <20222023  2024 
Navigate by Thread:
Prev: Re: How to safely implement an asynPortDriver with SCAN records Érico Nogueira Rolim via Tech-talk
Next: RE: How to safely implement an asynPortDriver with SCAN records Mark Rivers via Tech-talk
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  <20222023  2024 
ANJ, 14 Sep 2022 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·