×
INDI Library v1.8.1 Released (09 Sep 2019)

Monthly maintenance release INDI v1.8.1

inditelescope.cpp left open files

2 months 6 days ago
mastria
Fresh Boarder
Fresh Boarder
Posts: 15
More
Topic Author
inditelescope.cpp left open files #41892
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.

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

2 months 5 days ago
mastria
Fresh Boarder
Fresh Boarder
Posts: 15
More
Topic Author
inditelescope.cpp left open files #41900
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)

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

2 months 5 days ago
jpaana
Gold Boarder
Gold Boarder
Posts: 205
Karma: 5
More
inditelescope.cpp left open files #41924
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, ZWO EAF, USB_Focus V3, Gemini SnapCap, USB_DewPoint, KomaHub
The following user(s) said Thank You mastria

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

2 months 4 days ago
knro
Administrator
Administrator
Posts: 7280
Karma: 51
inditelescope.cpp left open files #41943
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

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

Time to create page: 0.536 seconds