Re: [Cppcms-users] Destroying all sessions on application exit
Brought to you by:
artyom-beilis
|
From: Artyom B. <art...@ya...> - 2013-01-21 10:25:19
|
The obvious would be to cleanup the storage in the factory destructor. If the applications shuts down properly (using SIGTERM for example) than the destructor should be called. Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ >________________________________ > From: Christian Gmeiner <chr...@gm...> >To: cpp...@li... >Sent: Monday, January 21, 2013 12:19 PM >Subject: [Cppcms-users] Destroying all sessions on application exit > >Hi. > >I am using a custom session_storage, which creates a temporary folder >for each user-session at a defined path - e.g. /media/session_storage. > > >namespace cppcms { >namespace sessions { > > class session_memory_ext_storage_factory; > > class CPPCMS_API session_memory_ext_storage : public session_storage { > public: > session_memory_ext_storage(std::string const &base) : base_(base) {} > virtual ~session_memory_ext_storage() {} > > virtual void save(std::string const &key,time_t to,std::string >const &value); > virtual bool load(std::string const &key,time_t &to,std::string &value); > virtual void remove(std::string const &key); > virtual bool is_blocking(); > > private: > void gc(); > bool removeRecursively(const QString &path); > > typedef std::multimap<time_t,std::string> timeout_type; > struct _data { > time_t timeout; > std::string info; > std::string path; > timeout_type::iterator timeout_ptr; > }; > typedef boost::unordered_map<std::string,_data> map_type; > map_type map_; > timeout_type timeout_; > booster::shared_mutex mutex_; > > std::string base_; > > friend class session_memory_ext_storage_factory; > }; > > class CPPCMS_API session_memory_ext_storage_factory : public >session_storage_factory { > public: > session_memory_ext_storage_factory(std::string const &base); > virtual booster::shared_ptr<session_storage> get(); > virtual bool requires_gc(); > virtual void gc_job(); > virtual ~session_memory_ext_storage_factory(); > private: > booster::shared_ptr<session_memory_ext_storage> storage_; > }; > >} // sessions >} // cppcms > > >If i kill the cppcms based application some session folders are still >existent. Is there a way to clean-up all sessions on application exit? > >thanks >-- >Christian Gmeiner, MSc > >------------------------------------------------------------------------------ >Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, >MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current >with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft >MVPs and experts. SALE $99.99 this month only -- learn more at: >http://p.sf.net/sfu/learnmore_122412 >_______________________________________________ >Cppcms-users mailing list >Cpp...@li... >https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > |