From: Maxim Mamontov Date: Thu, 9 Dec 2010 12:58:32 +0000 (+0200) Subject: Исправлена утечка ресурса (файловый дескриптор) в плагине store_files. X-Git-Tag: 2.407-rc3~295 X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/3b56895a961ab712e2dacd85636baec808c1ac8d?ds=sidebyside Исправлена утечка ресурса (файловый дескриптор) в плагине store_files. Утечка происходила при возникновении ошибки, по этому никогда не проявлялась --- diff --git a/projects/stargazer/plugins/store/files/file_store.cpp b/projects/stargazer/plugins/store/files/file_store.cpp index fe5ed230..57f825d6 100644 --- a/projects/stargazer/plugins/store/files/file_store.cpp +++ b/projects/stargazer/plugins/store/files/file_store.cpp @@ -1921,6 +1921,7 @@ while (stIter != statTree.end()) errorStr += strerror(errno); errorStr += "'"; printfd(__FILE__, "FILES_STORE::WriteDetailStat - fprintf failed. Message: '%s'\n", strerror(errno)); + fclose(statFile); return -1; } #else @@ -1936,6 +1937,7 @@ while (stIter != statTree.end()) errorStr += strerror(errno); errorStr += "'"; printfd(__FILE__, "FILES_STORE::WriteDetailStat - fprintf failed. Message: '%s'\n", strerror(errno)); + fclose(statFile); return -1; } #endif diff --git a/projects/stargazer/plugins/store/files/file_store.h b/projects/stargazer/plugins/store/files/file_store.h index 13c3a3fa..bf9fbf00 100644 --- a/projects/stargazer/plugins/store/files/file_store.h +++ b/projects/stargazer/plugins/store/files/file_store.h @@ -28,9 +28,10 @@ #ifndef FILE_STORE_H #define FILE_STORE_H -#include #include +#include + #include "base_settings.h" #include "base_store.h" #include "conffiles.h" @@ -80,6 +81,7 @@ private: int ParseGroup(const vector & moduleParams, const string & group, uid_t * uid); int ParseMode(const vector & moduleParams, const string & modeStr, mode_t * mode); int ParseYesNo(const string & value, bool * val); + string errorStr; string workDir; @@ -181,8 +183,8 @@ public: virtual int DelService(const string &) const {return 0;}; //virtual BASE_SETTINGS * GetStoreSettings(); - virtual void SetSettings(const MODULE_SETTINGS & s); - virtual int ParseSettings(); + virtual void SetSettings(const MODULE_SETTINGS & s); + virtual int ParseSettings(); virtual const string & GetVersion() const; private: @@ -191,12 +193,13 @@ private: virtual int WriteLogString(const string & str, const string & login) const; virtual int WriteLog2String(const string & str, const string & login) const; - int RemoveDir(const char * path) const; - int GetFilesList(vector * filesList, const string & directory, mode_t mode, const string & ext) const; - mutable string errorStr; - string version; - FILES_STORE_SETTINGS storeSettings; - MODULE_SETTINGS settings; + int RemoveDir(const char * path) const; + int GetFilesList(vector * filesList, const string & directory, mode_t mode, const string & ext) const; + + mutable string errorStr; + string version; + FILES_STORE_SETTINGS storeSettings; + MODULE_SETTINGS settings; mutable pthread_mutex_t mutex; }; //-----------------------------------------------------------------------------