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 2025 | 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 2025 |
<== Date ==> | <== Thread ==> |
---|
Subject: | RE: BASE 7.0.x@Windows_64 - Channel Access Context in shared library - "ca_context_destroy bug" |
From: | Freddie Akeroyd - UKRI STFC via Tech-talk <tech-talk at aps.anl.gov> |
To: | Carsten Winkler <carsten.winkler at helmholtz-berlin.de>, "Heesterman, Peter J" <Peter.Heesterman at ukaea.uk>, "Johnson, Andrew N." <anj at anl.gov>, "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov> |
Date: | Mon, 25 May 2020 14:30:55 +0000 |
Hi Carsten, Glad to hear you now have a working solution on Windows. When dlclose() is called on Linux it decrements an internal reference counter on the library, and when the counter reaches zero the library is unloaded. So if you were to call dlopen(“path
to my library”) from within your library to create an additional reference to it, then when LabVIEW calls dlclose() the library should remain loaded as the reference count will still be above zero. There appears to be a RTLD_NODELETE flag that has been available
since glibc 2.2 and can be passed to dlopen() to keep the library loaded after a dlclose(), it may be worth adding that too if the flag is available, but I would have thought a single dlopen() to increase the reference count would be enough. The reference counting principle also applies on windows, so the GET_MODULE_HANDLE_EX_FLAG_PIN flag may not be needed as the call to GetModuleHandleEx() will have increased the internal
reference count on the library by one. If you wanted to have an (optional for the user) way to unload channel access without terminating labview then the following might work: -
In your library call GetModuleHandleEx() in DLL_PROCESS_ATTACH to increase the reference count as currently, but without GET_MODULE_HANDLE_EX_FLAG_PIN. This additional module
reference should be stored in a global variable. -
In the disconnect.vi call a separate function in your DLL that calls ca_context_destroy() directly (as Peter describes below) but which also then calls FreeLibrary() on the
previous stored GetModuleHandleEx () reference. Regards, Freddie From: Carsten Winkler <carsten.winkler at helmholtz-berlin.de>
Hi there, up to now "caLabDisconnect.vi" is optional. The success of the CA Lab is the simple black box concept. You can use "caLabGet.vi" whenever you want without any separate "connect.vi" nor "disconnect.vi". I would like to retain this concept. Therefore, the
additional function with "ca_task_exit()" is no solution in the CA Lab case. Thanks to the hint from Michael and the friendly request from Freddi, I followed up the concept GetModuleHandleEx() with GET_MODULE_HANDLE_EX_FLAG_PIN. And this seems to be the key. Is there a similar solution (prevent unload library) for Linux? Best regards Am 21.05.20 um 11:56 schrieb Heesterman, Peter J:
This email and any attachments are intended solely for the use of the named recipients. If you are not the intended recipient you must not use, disclose, copy or distribute this email or any of its attachments and should notify the sender immediately and delete this email from your system. UK Research and Innovation (UKRI) has taken every reasonable precaution to minimise risk of this email or any attachments containing viruses or malware but the recipient should carry out its own virus and malware checks before opening the attachments. UKRI does not accept any liability for any losses or damages which the recipient may sustain due to presence of any viruses. Opinions, conclusions or other information in this message and attachments that are not related directly to UKRI business are solely those of the author and do not represent the views of UKRI. |