×

INDI Library v2.0.6 is Released (02 Feb 2024)

Bi-monthly release with minor bug fixes and improvements

inditelescope.cpp left open files

  • Posts: 17
  • Thank you received: 0
I believe that this may affect all telescopes, as it is a base telescope class.

I'm pooling data from Indi each 10 seconds calling ind_getprop (without any parameters) on raspberry pi.
Each time ind_getprop runs, I noted that open files grows by 2. Few time later, I receive messages on Ekos that there's too many files open.

Using lsof, I could verify that the driver indi_ieq_telescope has 1024 open files: 3 pipes, 1 ttyUSB, sometimes few ParkData.xml and more then 1000 ScopeConfig.xml.

$ lsof -p $(ps -e|grep indi_ieq|awk '{print $1}')|egrep -v mem\|rtd\|txt\|cwd\|FD

Verifing inditelescope.cpp in GitHub I could check that there's certainly some places that the file ScopeConfig.xml is left open, but I'm not sure about ParkData.xml, I believe that this second file is ok.

Maybe need some fclose(FilePtr); in few places on inditelescope.cpp to solve this issue.

Thanks,
Mastria.
4 years 7 months ago #41892

Please Log in or Create an account to join the conversation.

  • Posts: 17
  • Thank you received: 0
I believe that this works for me:

diff --git a/libindi/libs/indibase/inditelescope.cpp b/libindi/libs/indibase/inditelescope.cpp
index 25e149bb..12b05bb4 100644
--- a/libindi/libs/indibase/inditelescope.cpp
+++ b/libindi/libs/indibase/inditelescope.cpp
@@ -1912,6 +1912,8 @@ const char *Telescope::LoadParkXML()
delXMLEle(ParkdataXmlRoot);

ParkdataXmlRoot = readXMLFile(fp, lp, errmsg);
+ fclose(fp);
+

delLilXML(lp);
if (!ParkdataXmlRoot)
@@ -2038,6 +2040,7 @@ bool Telescope::PurgeParkData()
delXMLEle(ParkdataXmlRoot);

ParkdataXmlRoot = readXMLFile(fp, lp, errmsg);
+ fclose(fp);

delLilXML(lp);
if (!ParkdataXmlRoot)
@@ -2555,6 +2558,7 @@ bool Telescope::LoadScopeConfig()
char ErrMsg[512];

RootXmlNode = readXMLFile(FilePtr, XmlHandle, ErrMsg);
+ fclose(FilePtr);
delLilXML(XmlHandle);
XmlHandle = nullptr;
if (!RootXmlNode)
@@ -2694,6 +2698,7 @@ bool Telescope::HasDefaultScopeConfig()
char ErrMsg[512];

RootXmlNode = readXMLFile(FilePtr, XmlHandle, ErrMsg);
+ fclose(FilePtr);
delLilXML(XmlHandle);
XmlHandle = nullptr;
if (!RootXmlNode)
4 years 7 months ago #41900

Please Log in or Create an account to join the conversation.

  • Posts: 472
  • Thank you received: 165
Thanks for the heads up, I also found a few similar cases in other places and submitted them as PR at github.com/indilib/indi/pull/997
The following user(s) said Thank You: Marco Mastria
4 years 7 months ago #41924

Please Log in or Create an account to join the conversation.

Thanks for the patch, it's merged now.
4 years 7 months ago #41943

Please Log in or Create an account to join the conversation.

Time to create page: 0.541 seconds