×

INDI Library v1.8.0 is Released (27 Jul 2019)

INDI Library v1.8.0 is mostly a maintenance release to fix a few bugs in several drivers.

inditelescope.cpp left open files

  • Posts: 15
  • Thank you received: 0

inditelescope.cpp left open files was created by mastria

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.
1 week 5 days ago #41892

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

  • Posts: 15
  • Thank you received: 0

Replied by mastria on topic inditelescope.cpp left open files

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)
1 week 5 days ago #41900

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

  • Posts: 191
  • Karma: 5
  • Thank you received: 83

Replied by jpaana on topic inditelescope.cpp left open files

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
Remote observatory running Ubuntu 19.04 x64 with ScopeDome 2M, Skywatcher EQ8 and HEQ5, TS 8" RC, Atik 383L+, ASI178MC, ASI120MM-S, SX Lodestar X2, SX USB wheel with OAG, USB_Focus V3, Gemini SnapCap, USB_DewPoint, KomaHub
The following user(s) said Thank You: mastria
1 week 4 days ago #41924

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

Replied by knro on topic inditelescope.cpp left open files

Thanks for the patch, it's merged now.
Jasem Mutlaq
Support INDI & Ekos; Get StellarMate Astrophotography Gadget.
How to Submit Logs when you have problems?
Add your observatory info
1 week 3 days ago #41943

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

Time to create page: 0.469 seconds