added: gc for sessions (another thread)
git-svn-id: svn://ttmath.org/publicrep/winix/trunk@693 e52654a7-88a9-db11-a3e9-0013d4bc506epull/3/head
parent
7f77b6e3ec
commit
0a9cdd2f15
|
@ -18,26 +18,27 @@ app.o: ../notify/notifythread.h ../core/basethread.h synchro.h
|
|||
app.o: ../notify/templatesnotify.h ../core/config.h ../core/users.h
|
||||
app.o: ugcontainer.h lastcontainer.h mounts.h mount.h mountparser.h users.h
|
||||
app.o: groups.h group.h loadavg.h sessionmanager.h sessioncontainer.h
|
||||
app.o: ../functions/functions.h ../functions/functionbase.h ../core/request.h
|
||||
app.o: ../core/system.h ../core/synchro.h ../functions/functionparser.h
|
||||
app.o: ../functions/adduser.h ../functions/cat.h ../functions/chmod.h
|
||||
app.o: ../functions/privchanger.h ../functions/chown.h
|
||||
app.o: ../functions/ckeditor.h ../functions/cp.h ../functions/createthread.h
|
||||
app.o: ../functions/default.h ../functions/download.h ../functions/emacs.h
|
||||
app.o: ../functions/last.h ../functions/login.h ../functions/logout.h
|
||||
app.o: ../functions/ls.h ../functions/mkdir.h ../functions/mv.h
|
||||
app.o: ../functions/node.h ../functions/priv.h ../functions/reload.h
|
||||
app.o: ../functions/rm.h ../functions/run.h ../functions/stat.h
|
||||
app.o: ../functions/subject.h ../functions/funthread.h
|
||||
app.o: ../functions/template.h ../functions/tinymce.h ../functions/uname.h
|
||||
app.o: ../functions/upload.h ../functions/uptime.h ../functions/who.h
|
||||
app.o: ../functions/vim.h ../core/htmlfilter.h ../templates/templates.h
|
||||
app.o: basethread.h ../functions/functions.h ../functions/functionbase.h
|
||||
app.o: ../core/request.h ../core/system.h ../core/synchro.h
|
||||
app.o: ../functions/functionparser.h ../functions/adduser.h
|
||||
app.o: ../functions/cat.h ../functions/chmod.h ../functions/privchanger.h
|
||||
app.o: ../functions/chown.h ../functions/ckeditor.h ../functions/cp.h
|
||||
app.o: ../functions/createthread.h ../functions/default.h
|
||||
app.o: ../functions/download.h ../functions/emacs.h ../functions/last.h
|
||||
app.o: ../functions/login.h ../functions/logout.h ../functions/ls.h
|
||||
app.o: ../functions/mkdir.h ../functions/mv.h ../functions/node.h
|
||||
app.o: ../functions/priv.h ../functions/reload.h ../functions/rm.h
|
||||
app.o: ../functions/run.h ../functions/stat.h ../functions/subject.h
|
||||
app.o: ../functions/funthread.h ../functions/template.h
|
||||
app.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h
|
||||
app.o: ../functions/uptime.h ../functions/who.h ../functions/vim.h
|
||||
app.o: ../core/htmlfilter.h ../templates/templates.h
|
||||
app.o: ../templates/patterncacher.h ../templates/ckeditorgetparser.h
|
||||
app.o: ../core/httpsimpleparser.h ../core/log.h ../templates/indexpatterns.h
|
||||
app.o: ../core/sessionmanager.h compress.h getparser.h httpsimpleparser.h
|
||||
app.o: postparser.h cookieparser.h postmultiparser.h acceptencodingparser.h
|
||||
app.o: acceptbaseparser.h plugin.h pluginmsg.h
|
||||
basethread.o: basethread.h synchro.h log.h textstream.h
|
||||
basethread.o: basethread.h log.h textstream.h
|
||||
bbcodeparser.o: bbcodeparser.h htmlfilter.h
|
||||
compress.o: compress.h log.h textstream.h
|
||||
config.o: config.h confparser.h htmlfilter.h log.h textstream.h plugin.h
|
||||
|
@ -58,12 +59,12 @@ config.o: ../templates/htmltextstream.h ../notify/notifythread.h
|
|||
config.o: ../core/basethread.h synchro.h ../notify/templatesnotify.h
|
||||
config.o: ../core/config.h ../core/users.h ugcontainer.h lastcontainer.h
|
||||
config.o: mounts.h mount.h mountparser.h users.h groups.h group.h loadavg.h
|
||||
config.o: sessionmanager.h sessioncontainer.h ../functions/functions.h
|
||||
config.o: ../functions/functionbase.h ../core/request.h ../core/system.h
|
||||
config.o: ../core/synchro.h ../functions/functionparser.h
|
||||
config.o: ../functions/adduser.h ../functions/cat.h ../functions/chmod.h
|
||||
config.o: ../functions/privchanger.h ../functions/chown.h
|
||||
config.o: ../functions/ckeditor.h ../functions/cp.h
|
||||
config.o: sessionmanager.h sessioncontainer.h basethread.h
|
||||
config.o: ../functions/functions.h ../functions/functionbase.h
|
||||
config.o: ../core/request.h ../core/system.h ../core/synchro.h
|
||||
config.o: ../functions/functionparser.h ../functions/adduser.h
|
||||
config.o: ../functions/cat.h ../functions/chmod.h ../functions/privchanger.h
|
||||
config.o: ../functions/chown.h ../functions/ckeditor.h ../functions/cp.h
|
||||
config.o: ../functions/createthread.h ../functions/default.h
|
||||
config.o: ../functions/download.h ../functions/emacs.h ../functions/last.h
|
||||
config.o: ../functions/login.h ../functions/logout.h ../functions/ls.h
|
||||
|
@ -156,7 +157,7 @@ mounts.o: ../templates/htmltextstream.h ../notify/notifythread.h
|
|||
mounts.o: ../core/basethread.h synchro.h ../notify/templatesnotify.h
|
||||
mounts.o: ../core/config.h ../core/users.h ugcontainer.h lastcontainer.h
|
||||
mounts.o: mountparser.h plugin.h pluginmsg.h system.h users.h groups.h
|
||||
mounts.o: group.h loadavg.h sessionmanager.h sessioncontainer.h
|
||||
mounts.o: group.h loadavg.h sessionmanager.h sessioncontainer.h basethread.h
|
||||
mounts.o: ../functions/functions.h ../functions/functionbase.h
|
||||
mounts.o: ../core/request.h ../core/system.h ../core/synchro.h
|
||||
mounts.o: ../functions/functionparser.h ../functions/adduser.h
|
||||
|
@ -193,12 +194,12 @@ plugin.o: ../templates/htmltextstream.h ../notify/notifythread.h
|
|||
plugin.o: ../core/basethread.h synchro.h ../notify/templatesnotify.h
|
||||
plugin.o: ../core/config.h ../core/users.h ugcontainer.h lastcontainer.h
|
||||
plugin.o: mounts.h mount.h mountparser.h users.h groups.h group.h loadavg.h
|
||||
plugin.o: sessionmanager.h sessioncontainer.h ../functions/functions.h
|
||||
plugin.o: ../functions/functionbase.h ../core/request.h ../core/system.h
|
||||
plugin.o: ../core/synchro.h ../functions/functionparser.h
|
||||
plugin.o: ../functions/adduser.h ../functions/cat.h ../functions/chmod.h
|
||||
plugin.o: ../functions/privchanger.h ../functions/chown.h
|
||||
plugin.o: ../functions/ckeditor.h ../functions/cp.h
|
||||
plugin.o: sessionmanager.h sessioncontainer.h basethread.h
|
||||
plugin.o: ../functions/functions.h ../functions/functionbase.h
|
||||
plugin.o: ../core/request.h ../core/system.h ../core/synchro.h
|
||||
plugin.o: ../functions/functionparser.h ../functions/adduser.h
|
||||
plugin.o: ../functions/cat.h ../functions/chmod.h ../functions/privchanger.h
|
||||
plugin.o: ../functions/chown.h ../functions/ckeditor.h ../functions/cp.h
|
||||
plugin.o: ../functions/createthread.h ../functions/default.h
|
||||
plugin.o: ../functions/download.h ../functions/emacs.h ../functions/last.h
|
||||
plugin.o: ../functions/login.h ../functions/logout.h ../functions/ls.h
|
||||
|
@ -231,7 +232,7 @@ plugindata.o: ../notify/notifythread.h ../core/basethread.h synchro.h
|
|||
plugindata.o: ../notify/templatesnotify.h ../core/config.h ../core/users.h
|
||||
plugindata.o: ugcontainer.h lastcontainer.h mounts.h mount.h mountparser.h
|
||||
plugindata.o: users.h groups.h group.h loadavg.h sessionmanager.h
|
||||
plugindata.o: sessioncontainer.h ../functions/functions.h
|
||||
plugindata.o: sessioncontainer.h basethread.h ../functions/functions.h
|
||||
plugindata.o: ../functions/functionbase.h ../core/request.h ../core/system.h
|
||||
plugindata.o: ../core/synchro.h ../functions/functionparser.h
|
||||
plugindata.o: ../functions/adduser.h ../functions/cat.h ../functions/chmod.h
|
||||
|
@ -275,12 +276,12 @@ request.o: ../templates/htmltextstream.h ../notify/notifythread.h
|
|||
request.o: ../core/basethread.h synchro.h ../notify/templatesnotify.h
|
||||
request.o: ../core/config.h ../core/users.h ugcontainer.h lastcontainer.h
|
||||
request.o: mounts.h mount.h mountparser.h users.h groups.h group.h loadavg.h
|
||||
request.o: sessionmanager.h sessioncontainer.h ../functions/functions.h
|
||||
request.o: ../functions/functionbase.h ../core/request.h ../core/system.h
|
||||
request.o: ../core/synchro.h ../functions/functionparser.h
|
||||
request.o: ../functions/adduser.h ../functions/cat.h ../functions/chmod.h
|
||||
request.o: ../functions/privchanger.h ../functions/chown.h
|
||||
request.o: ../functions/ckeditor.h ../functions/cp.h
|
||||
request.o: sessionmanager.h sessioncontainer.h basethread.h
|
||||
request.o: ../functions/functions.h ../functions/functionbase.h
|
||||
request.o: ../core/request.h ../core/system.h ../core/synchro.h
|
||||
request.o: ../functions/functionparser.h ../functions/adduser.h
|
||||
request.o: ../functions/cat.h ../functions/chmod.h ../functions/privchanger.h
|
||||
request.o: ../functions/chown.h ../functions/ckeditor.h ../functions/cp.h
|
||||
request.o: ../functions/createthread.h ../functions/default.h
|
||||
request.o: ../functions/download.h ../functions/emacs.h ../functions/last.h
|
||||
request.o: ../functions/login.h ../functions/logout.h ../functions/ls.h
|
||||
|
@ -299,13 +300,13 @@ sessioncontainer.o: sessioncontainer.h session.h item.h error.h user.h
|
|||
sessioncontainer.o: plugindata.h rebus.h lastcontainer.h request.h
|
||||
sessioncontainer.o: requesttypes.h config.h confparser.h htmlfilter.h
|
||||
sessioncontainer.o: textstream.h ../templates/htmltextstream.h
|
||||
sessioncontainer.o: ../core/textstream.h misc.h log.h
|
||||
sessioncontainer.o: ../core/textstream.h misc.h basethread.h log.h
|
||||
sessionmanager.o: sessionmanager.h sessioncontainer.h session.h item.h
|
||||
sessionmanager.o: error.h user.h plugindata.h rebus.h lastcontainer.h
|
||||
sessionmanager.o: request.h requesttypes.h config.h confparser.h htmlfilter.h
|
||||
sessionmanager.o: textstream.h ../templates/htmltextstream.h
|
||||
sessionmanager.o: ../core/textstream.h misc.h system.h dirs.h dircontainer.h
|
||||
sessionmanager.o: ../db/db.h ../db/dbbase.h ../db/dbconn.h
|
||||
sessionmanager.o: ../core/textstream.h misc.h basethread.h system.h dirs.h
|
||||
sessionmanager.o: dircontainer.h ../db/db.h ../db/dbbase.h ../db/dbconn.h
|
||||
sessionmanager.o: ../db/dbtextstream.h ../core/error.h log.h
|
||||
sessionmanager.o: ../db/dbitemquery.h ../core/item.h ../db/dbitemcolumns.h
|
||||
sessionmanager.o: ../core/user.h ../core/group.h ../core/thread.h
|
||||
|
@ -348,7 +349,7 @@ sessionparser.o: sessionparser.h session.h item.h error.h user.h plugindata.h
|
|||
sessionparser.o: rebus.h sessioncontainer.h lastcontainer.h request.h
|
||||
sessionparser.o: requesttypes.h config.h confparser.h htmlfilter.h
|
||||
sessionparser.o: textstream.h ../templates/htmltextstream.h
|
||||
sessionparser.o: ../core/textstream.h misc.h users.h log.h
|
||||
sessionparser.o: ../core/textstream.h misc.h basethread.h users.h log.h
|
||||
synchro.o: synchro.h
|
||||
system.o: system.h dirs.h item.h dircontainer.h ../db/db.h ../db/dbbase.h
|
||||
system.o: ../db/dbconn.h ../db/dbtextstream.h ../core/textstream.h misc.h
|
||||
|
|
12
core/app.cpp
12
core/app.cpp
|
@ -67,6 +67,7 @@ App::App()
|
|||
session_manager.SetConfig(&config);
|
||||
session_manager.SetRequest(&request);
|
||||
session_manager.SetSystem(&system);
|
||||
session_manager.SetSynchro(&synchro);
|
||||
|
||||
post_multi_parser.SetConfig(&config);
|
||||
}
|
||||
|
@ -218,10 +219,6 @@ void App::ProcessRequestThrow()
|
|||
}
|
||||
|
||||
SendAnswer();
|
||||
|
||||
// it's better to remove sessions at the end of a request
|
||||
// as it can take a little time
|
||||
session_manager.DeleteOldSessions();
|
||||
}
|
||||
|
||||
|
||||
|
@ -994,6 +991,7 @@ void App::WaitForThreads()
|
|||
//pthread_join(signal_thread, 0);
|
||||
|
||||
system.notify.WaitForThread();
|
||||
session_manager.WaitForGC();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1027,7 +1025,8 @@ sigset_t set;
|
|||
app->synchro.was_stop_signal = true;
|
||||
FCGX_ShutdownPending();
|
||||
Ezc::WideToUTF8(app->config.base_url, app->url_to_fetch_on_exit);
|
||||
app->system.notify.SendSignalToThread();
|
||||
app->system.notify.PrepareToStopThread();
|
||||
app->session_manager.PrepareToStopGC();
|
||||
app->Unlock();
|
||||
|
||||
// this thread will hang on this method
|
||||
|
@ -1057,6 +1056,9 @@ sigset_t set;
|
|||
|
||||
// thread for notifications
|
||||
system.notify.StartThread();
|
||||
|
||||
// gc for sessions
|
||||
session_manager.StartGC();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -12,11 +12,11 @@
|
|||
#include "log.h"
|
||||
|
||||
|
||||
BaseThread::BaseThread()
|
||||
BaseThread::BaseThread() : thread_signal(PTHREAD_COND_INITIALIZER)
|
||||
{
|
||||
synchro = 0;
|
||||
thread_signal = 0;
|
||||
thread_id = 0;
|
||||
work_mode = 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -25,9 +25,11 @@ void BaseThread::SetSynchro(Synchro * psynchro)
|
|||
synchro = psynchro;
|
||||
}
|
||||
|
||||
void BaseThread::SetSignal(pthread_cond_t * psignal)
|
||||
|
||||
|
||||
void BaseThread::Mode(int mode)
|
||||
{
|
||||
thread_signal = psignal;
|
||||
work_mode = mode;
|
||||
}
|
||||
|
||||
|
||||
|
@ -117,12 +119,19 @@ void BaseThread::BaseDo()
|
|||
// use it with Lock and Unlock
|
||||
bool BaseThread::WaitForSignal()
|
||||
{
|
||||
return pthread_cond_wait(thread_signal, &synchro->mutex) == 0;
|
||||
return pthread_cond_wait(&thread_signal, &synchro->mutex) == 0;
|
||||
}
|
||||
|
||||
|
||||
void BaseThread::WakeUpThread()
|
||||
{
|
||||
// you should use it with: synchro->Lock() and Unlock()
|
||||
pthread_cond_signal(&thread_signal);
|
||||
}
|
||||
|
||||
|
||||
// use it with Lock and Unlock
|
||||
// it breaks only if there was a stop signal a the time has expired
|
||||
// it breaks only if there was a stop signal or the time has expired
|
||||
bool BaseThread::WaitForSignalSleep(time_t second)
|
||||
{
|
||||
timespec t;
|
||||
|
@ -133,7 +142,7 @@ int res;
|
|||
|
||||
do
|
||||
{
|
||||
res = pthread_cond_timedwait(thread_signal, &synchro->mutex, &t);
|
||||
res = pthread_cond_timedwait(&thread_signal, &synchro->mutex, &t);
|
||||
}
|
||||
while( res == 0 && !synchro->was_stop_signal );
|
||||
// above condition means there was a signal
|
||||
|
@ -149,7 +158,7 @@ void BaseThread::WaitForThread()
|
|||
}
|
||||
|
||||
|
||||
void BaseThread::StartRoutine()
|
||||
void BaseThread::SignalLoop()
|
||||
{
|
||||
bool make_do;
|
||||
|
||||
|
@ -177,11 +186,15 @@ void * BaseThread::StartRoutine(void * this_object)
|
|||
{
|
||||
BaseThread * base = reinterpret_cast<BaseThread*>(this_object);
|
||||
|
||||
if( base->synchro && base->thread_signal )
|
||||
if( base->synchro )
|
||||
{
|
||||
if( base->BaseInit() )
|
||||
{
|
||||
base->StartRoutine();
|
||||
if( base->work_mode == 0 )
|
||||
base->SignalLoop();
|
||||
else
|
||||
base->Work();
|
||||
|
||||
base->BaseUninit();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,51 +21,74 @@ public:
|
|||
|
||||
BaseThread();
|
||||
|
||||
// these method must be called before starting the thread
|
||||
// synchro object (must be set)
|
||||
void SetSynchro(Synchro * psynchro);
|
||||
void SetSignal(pthread_cond_t * psignal);
|
||||
|
||||
// starting the thread
|
||||
// work mode
|
||||
// we have two modes:
|
||||
// 0 - there is a loop with SignalReceived() and Do()
|
||||
// if SignalReceived() returns true then Do() is called
|
||||
// 1 - only Work() method is called
|
||||
// the thread exits after Work() has finished
|
||||
// default: 0
|
||||
void Mode(int mode);
|
||||
|
||||
// starting the second thread
|
||||
bool StartThread();
|
||||
|
||||
// wake up the second thread
|
||||
// (if it waits for the signal)
|
||||
// you should use it with: synchro->Lock() and Unlock()
|
||||
// if the thread doesn't wait on a signal then nothing is done
|
||||
void WakeUpThread();
|
||||
|
||||
// waiting until the thread exits
|
||||
// you should call WakeUpThread() before
|
||||
void WaitForThread();
|
||||
|
||||
|
||||
|
||||
|
||||
// virtual methods which should/can be inherited by your class
|
||||
// the methods will be called from the other thread
|
||||
|
||||
// initialize the thread
|
||||
// (global objects are locked)
|
||||
// if it returns false then the thread immediately exists
|
||||
virtual bool Init() { return false; }
|
||||
// if it returns false then the thread immediately exits
|
||||
// default: true
|
||||
virtual bool Init() { return true; }
|
||||
|
||||
// uninitialize the thread
|
||||
// this is called before the thread is prepare to detach
|
||||
// (global objects are locked)
|
||||
// it's called only if Init() returned true
|
||||
virtual void Uninit() {}
|
||||
|
||||
// signal came
|
||||
// signal came (work mode = 0 - default)
|
||||
// signal comes when an other thread calls WakeUpThread() method
|
||||
// check specific job and return true to call Do() next
|
||||
// (global objects are locked -- copy some global objects to local variables)
|
||||
virtual bool SignalReceived() { return false; };
|
||||
|
||||
// if SignalReceived() returned true then this method is called
|
||||
// global object are *not* locked -- use only your local variables
|
||||
// global objects are *not* locked -- use only your local variables
|
||||
// if you have to do something on global objects use synchro->Lock() and synchro->Unlock()
|
||||
virtual void Do() {}
|
||||
|
||||
// this method is called after Init() when Mode(1) is used
|
||||
// this is for long-time job
|
||||
// this method is called only once
|
||||
// global objects are *not* locked
|
||||
virtual void Work() {}
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
// this pointers must be set
|
||||
Synchro * synchro;
|
||||
pthread_cond_t * thread_signal;
|
||||
pthread_t thread_id; // thread id - set by StartThread()
|
||||
pthread_cond_t thread_signal;
|
||||
int work_mode;
|
||||
|
||||
pthread_t thread_id; // thread id - set automatically
|
||||
|
||||
void StartRoutine();
|
||||
void SignalLoop();
|
||||
static void * StartRoutine(void *);
|
||||
bool BaseInit();
|
||||
void BaseUninit();
|
||||
|
|
|
@ -17,6 +17,7 @@ SessionContainer::SessionContainer()
|
|||
{
|
||||
request = 0;
|
||||
table_size = 0;
|
||||
work_mode = 1; // threading work mode
|
||||
}
|
||||
|
||||
|
||||
|
@ -28,27 +29,27 @@ void SessionContainer::SetRequest(Request * prequest)
|
|||
}
|
||||
|
||||
|
||||
void SessionContainer::SetConfig(Config * pconfig)
|
||||
{
|
||||
config = pconfig;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SessionContainer::Clear()
|
||||
{
|
||||
Table::iterator inext, i = table.begin();
|
||||
Table::iterator i = table.begin();
|
||||
|
||||
// don't use table.clear();
|
||||
// because plugins session data would not be erased
|
||||
while( i != table.end() )
|
||||
{
|
||||
inext = i;
|
||||
++inext;
|
||||
|
||||
request->session = &(*i);
|
||||
table.erase(i);
|
||||
|
||||
i = inext;
|
||||
table.erase(i++);
|
||||
}
|
||||
|
||||
// erasing all indexes
|
||||
// erasing indexes
|
||||
index_id.clear();
|
||||
index_time.clear();
|
||||
table_size = 0;
|
||||
request->session = 0;
|
||||
}
|
||||
|
@ -60,7 +61,7 @@ void SessionContainer::SetLastContainer(LastContainer * plast_container)
|
|||
}
|
||||
|
||||
|
||||
SessionContainer::TableSize SessionContainer::Size()
|
||||
size_t SessionContainer::Size()
|
||||
{
|
||||
// don't use table.size() as it has O(n) complexity on FreeBSD
|
||||
return table_size;
|
||||
|
@ -88,13 +89,16 @@ Session & SessionContainer::Back()
|
|||
|
||||
bool SessionContainer::PushBack(const Session & session)
|
||||
{
|
||||
if( index_id.find(session.id) != index_id.end() )
|
||||
// that element already exists
|
||||
std::pair<IndexId::iterator, bool> index_id_res = index_id.insert( std::make_pair(session.id, table.end()) );
|
||||
|
||||
if( !index_id_res.second )
|
||||
{
|
||||
// that element already exists (was not inserted now)
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
Iterator last = table.insert(table.end(), session);
|
||||
index_id.insert( std::make_pair(session.id, last) );
|
||||
index_time.insert( std::make_pair(session.last_time, last) );
|
||||
index_id_res.first->second = last;
|
||||
table_size += 1;
|
||||
|
||||
log << log3 << "SC: added session, id: " << session.id << logend;
|
||||
|
@ -119,93 +123,92 @@ return i->second;
|
|||
|
||||
|
||||
|
||||
size_t SessionContainer::DelFirstByTimeInterval(time_t interval, size_t how_many_max, bool skip_remember_flag)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
* sessions gc (another thread)
|
||||
*
|
||||
*
|
||||
*/
|
||||
void SessionContainer::Work()
|
||||
{
|
||||
IndexTime::iterator i = index_time.begin();
|
||||
IndexTime::iterator iold;
|
||||
time_t limit = std::time(0) - interval;
|
||||
Session * old_session = request->session;
|
||||
size_t deleted = 0;
|
||||
bool exit = false;
|
||||
IndexId::iterator i;
|
||||
|
||||
while( i != index_time.end() && i->second->last_time < limit && deleted < how_many_max )
|
||||
Lock();
|
||||
i = index_id.begin();
|
||||
Unlock();
|
||||
|
||||
while( !exit )
|
||||
{
|
||||
//long id = i->second->id; // !! for logs (not used now)
|
||||
iold = i;
|
||||
++i; // incrementing before deleting old one
|
||||
|
||||
if( skip_remember_flag && iold->second->puser && iold->second->remember_me )
|
||||
// don't delete sessions which have 'remember_me' flag (and a user is logged)
|
||||
continue;
|
||||
Lock();
|
||||
|
||||
if( iold->second->puser )
|
||||
last_container->UserLogout(iold->second->puser->id, iold->second->id);
|
||||
|
||||
// we're logging session.id (call this before table.erase())
|
||||
DelFromIdIndex(iold->second);
|
||||
if( i == index_id.end() )
|
||||
{
|
||||
i = index_id.begin();
|
||||
WaitForSignalSleep(30);
|
||||
}
|
||||
else
|
||||
{
|
||||
if( IsSessionOutdated(*i->second) )
|
||||
DeleteSession(i++);
|
||||
else
|
||||
++i;
|
||||
}
|
||||
|
||||
request->session = &(*iold->second);
|
||||
table.erase(iold->second);
|
||||
index_time.erase(iold);
|
||||
table_size -= 1;
|
||||
request->session = 0;
|
||||
deleted += 1;
|
||||
|
||||
//log << log3 << "SC: deleted index_time for session id: " << id << logend;
|
||||
//log << log3 << "SC: deleted session, id: " << id << logend;
|
||||
exit = synchro->was_stop_signal;
|
||||
Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// it's called from the other thread (with Lock and Unlock)
|
||||
bool SessionContainer::IsSessionOutdated(const Session & s) const
|
||||
{
|
||||
bool outdated;
|
||||
|
||||
if( s.remember_me )
|
||||
outdated = s.last_time < std::time(0) - config->session_remember_max_idle;
|
||||
else
|
||||
outdated = s.last_time < std::time(0) - config->session_max_idle;
|
||||
|
||||
return outdated;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// it's called from the other thread (with Lock and Unlock)
|
||||
void SessionContainer::DeleteSession(SessionContainer::IndexId::iterator i)
|
||||
{
|
||||
Session * old_session = request->session;
|
||||
|
||||
request->session = &(*i->second);
|
||||
|
||||
//log << log3 << "SessionContainer: deleting outdated session, id: " << i->second->id << logend;
|
||||
|
||||
if( i->second->puser )
|
||||
last_container->UserLogout(i->second->puser->id, i->second->id);
|
||||
|
||||
table.erase(i->second);
|
||||
index_id.erase(i);
|
||||
table_size -= 1;
|
||||
|
||||
request->session = old_session;
|
||||
|
||||
return deleted;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void SessionContainer::DelFromIdIndex(SessionContainer::Iterator iter)
|
||||
{
|
||||
IndexId::iterator i;
|
||||
|
||||
for(i = index_id.begin() ; i!=index_id.end() ; ++i)
|
||||
{
|
||||
if( i->second == iter )
|
||||
{
|
||||
index_id.erase(i);
|
||||
//log << log3 << "SC: deleted index_id for session id: " << iter->id << logend;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
*
|
||||
*
|
||||
* end of sessions gc
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
void SessionContainer::UpdateLastTime(SessionContainer::Iterator iter, time_t new_time)
|
||||
{
|
||||
IndexTime::iterator i = index_time.lower_bound(iter->last_time);
|
||||
bool found = false;
|
||||
|
||||
for( ; i != index_time.end() ; ++i)
|
||||
{
|
||||
if( i->second == iter )
|
||||
{
|
||||
index_time.erase(i);
|
||||
index_time.insert( std::make_pair(new_time, iter) );
|
||||
|
||||
iter->last_time = new_time;
|
||||
iter->tm_last_time = Time(new_time);
|
||||
|
||||
//log << log3 << "SC: last time and the time index for session id: " << iter->id << " updated" << logend;
|
||||
log << log3 << "SC: last time for session id: " << iter->id << " updated" << logend;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if( !found )
|
||||
log << log1 << "SC: cannot update the time, time index not found for session id: " << iter->id << logend;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#ifndef headerfilecmslucoresessioncontainer
|
||||
#define headerfilecmslucoresessioncontainer
|
||||
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <ctime>
|
||||
|
@ -18,62 +17,58 @@
|
|||
#include "session.h"
|
||||
#include "lastcontainer.h"
|
||||
#include "request.h"
|
||||
#include "basethread.h"
|
||||
#include "config.h"
|
||||
|
||||
|
||||
class SessionContainer
|
||||
|
||||
class SessionContainer : public BaseThread
|
||||
{
|
||||
public:
|
||||
|
||||
// when deleting Sessions you should set request.session into the session object
|
||||
// this allows to delete plugins session data
|
||||
// because a session object has plugin_data object
|
||||
// and in its destructor the plugin.Call(WINIX_SESSION_REMOVE) is called
|
||||
typedef std::list<Session> Table;
|
||||
typedef Table::iterator Iterator;
|
||||
typedef Table::size_type TableSize;
|
||||
|
||||
typedef std::list<Session> Table;
|
||||
typedef Table::iterator Iterator;
|
||||
typedef std::map<long, Iterator> IndexId;
|
||||
typedef std::multimap<time_t, Iterator> IndexTime;
|
||||
|
||||
|
||||
SessionContainer();
|
||||
|
||||
void SetRequest(Request * prequest);
|
||||
void SetConfig(Config * pconfig);
|
||||
void SetLastContainer(LastContainer * plast_container);
|
||||
|
||||
void Clear();
|
||||
|
||||
size_t Size();
|
||||
Iterator Begin();
|
||||
Iterator End();
|
||||
Session & Back();
|
||||
bool PushBack(const Session & session);
|
||||
Iterator FindById(long);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
LastContainer * last_container;
|
||||
|
||||
Table table;
|
||||
IndexId index_id;
|
||||
IndexTime index_time;
|
||||
|
||||
Request * request;
|
||||
void DelFromIdIndex(Iterator iter);
|
||||
Config * config;
|
||||
//void DelFromIdIndex(Iterator iter);
|
||||
virtual void Work();
|
||||
bool IsSessionOutdated(const Session & s) const;
|
||||
void DeleteSession(IndexId::iterator i);
|
||||
|
||||
// in FreeBSD implementation (GCC) list::size() has linear complexity
|
||||
// so we use our own table_size with O(1)
|
||||
size_t table_size;
|
||||
|
||||
public:
|
||||
|
||||
|
||||
SessionContainer();
|
||||
|
||||
void SetRequest(Request * prequest);
|
||||
|
||||
void Clear();
|
||||
|
||||
TableSize Size();
|
||||
|
||||
Iterator Begin();
|
||||
Iterator End();
|
||||
|
||||
Session & Back();
|
||||
|
||||
bool PushBack(const Session & session);
|
||||
Iterator FindById(long);
|
||||
|
||||
size_t DelFirstByTimeInterval(time_t interval, size_t how_many_max, bool skip_remember_flag = true);
|
||||
|
||||
void UpdateLastTime(Iterator iter, time_t new_time);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
SessionManager::SessionManager()
|
||||
{
|
||||
session_checker = 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -36,6 +35,7 @@ void SessionManager::SetRequest(Request * prequest)
|
|||
void SessionManager::SetConfig(Config * pconfig)
|
||||
{
|
||||
config = pconfig;
|
||||
session_tab.SetConfig(pconfig);
|
||||
}
|
||||
|
||||
|
||||
|
@ -50,6 +50,12 @@ void SessionManager::SetLastContainer(LastContainer * plast_container)
|
|||
}
|
||||
|
||||
|
||||
void SessionManager::SetSynchro(Synchro * psynchro)
|
||||
{
|
||||
session_tab.SetSynchro(psynchro);
|
||||
}
|
||||
|
||||
|
||||
size_t SessionManager::Size()
|
||||
{
|
||||
return session_tab.Size();
|
||||
|
@ -105,6 +111,7 @@ void SessionManager::CreateTemporarySession()
|
|||
{
|
||||
Session s;
|
||||
s.id = 0;
|
||||
s.new_session = true;
|
||||
|
||||
session_tab.PushBack(s);
|
||||
request->session = &session_tab.Back();
|
||||
|
@ -112,6 +119,7 @@ void SessionManager::CreateTemporarySession()
|
|||
else
|
||||
{
|
||||
request->session = &(*i);
|
||||
request->session->new_session = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -158,8 +166,9 @@ bool SessionManager::SetSessionFromCookie(const std::string & cookie)
|
|||
|
||||
// that session is in the table
|
||||
request->session = &(*s);
|
||||
request->session->new_session = false;
|
||||
session_tab.UpdateLastTime(s, std::time(0));
|
||||
request->session->new_session = false;
|
||||
request->session->last_time = std::time(0);
|
||||
request->session->tm_last_time = Time(request->session->last_time);
|
||||
|
||||
if( request->method == Request::get )
|
||||
request->session->last_time_get = request->session->last_time;
|
||||
|
@ -225,48 +234,11 @@ SessionContainer::Iterator SessionManager::SessionEnd()
|
|||
|
||||
|
||||
|
||||
void SessionManager::DeleteOldSessions()
|
||||
{
|
||||
size_t deleted;
|
||||
|
||||
deleted = session_tab.DelFirstByTimeInterval(config->session_max_idle, 100); // !! dodac do konfiga
|
||||
|
||||
if( ++session_checker > 1000 )
|
||||
{
|
||||
// we make the test after 1000 requests
|
||||
//log << log3 << "SM: checking sessions which have 'remember me' flag set" << logend;
|
||||
|
||||
session_checker = 0;
|
||||
deleted += session_tab.DelFirstByTimeInterval(config->session_remember_max_idle, 100, false);
|
||||
}
|
||||
|
||||
if( deleted > 0 )
|
||||
log << log3 << "SM: deleted " << deleted << " outdated sessions" << logend;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SessionManager::DeleteSessions()
|
||||
{
|
||||
// first we delete all plugins date
|
||||
/*
|
||||
SessionContainer::Iterator i = session_tab.Begin();
|
||||
|
||||
Session * old_session = request->session;
|
||||
|
||||
for( ; i!=session_tab.End() ; ++i )
|
||||
{
|
||||
request->session = &(*i);
|
||||
i->plugin_data.DeleteAll();
|
||||
}
|
||||
|
||||
request->session = old_session;
|
||||
*/
|
||||
// and now we delete all sessions
|
||||
|
||||
|
||||
session_tab.Clear();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -335,5 +307,24 @@ void SessionManager::SaveSessions()
|
|||
|
||||
|
||||
|
||||
void SessionManager::StartGC()
|
||||
{
|
||||
session_tab.StartThread();
|
||||
}
|
||||
|
||||
|
||||
// use it with Lock() and Unlock();
|
||||
void SessionManager::PrepareToStopGC()
|
||||
{
|
||||
session_tab.WakeUpThread();
|
||||
}
|
||||
|
||||
|
||||
void SessionManager::WaitForGC()
|
||||
{
|
||||
session_tab.WaitForThread();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "request.h"
|
||||
#include "lastcontainer.h"
|
||||
#include "system.h"
|
||||
#include "synchro.h"
|
||||
|
||||
|
||||
|
||||
|
@ -35,7 +36,6 @@ class SessionManager
|
|||
void CreateTemporarySession();
|
||||
void CreateSession();
|
||||
bool SetSessionFromCookie(const std::string & cookie);
|
||||
int session_checker;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -45,10 +45,13 @@ public:
|
|||
void SetConfig(Config * pconfig);
|
||||
void SetSystem(System * psystem);
|
||||
void SetLastContainer(LastContainer * plast_container);
|
||||
void SetSynchro(Synchro * psynchro);
|
||||
|
||||
void SetSession();
|
||||
void DeleteSessions(); // deleting all sessions
|
||||
void DeleteOldSessions();
|
||||
void StartGC();
|
||||
void PrepareToStopGC();
|
||||
void WaitForGC();
|
||||
|
||||
void LoadSessions();
|
||||
void SaveSessions();
|
||||
|
|
|
@ -270,7 +270,7 @@ emacs.o: ../core/synchro.h ../templates/templates.h
|
|||
emacs.o: ../templates/patterncacher.h ../templates/ckeditorgetparser.h
|
||||
emacs.o: ../core/httpsimpleparser.h ../core/log.h
|
||||
emacs.o: ../templates/indexpatterns.h ../core/sessionmanager.h
|
||||
emacs.o: ../core/sessioncontainer.h ../core/system.h
|
||||
emacs.o: ../core/sessioncontainer.h ../core/basethread.h ../core/system.h
|
||||
functionbase.o: functionbase.h ../core/item.h ../db/db.h ../db/dbbase.h
|
||||
functionbase.o: ../db/dbconn.h ../db/dbtextstream.h ../core/textstream.h
|
||||
functionbase.o: ../core/misc.h ../core/item.h ../core/error.h ../core/log.h
|
||||
|
@ -363,10 +363,11 @@ functions.o: template.h tinymce.h uname.h upload.h uptime.h who.h vim.h
|
|||
functions.o: ../core/htmlfilter.h ../core/log.h ../core/misc.h
|
||||
functions.o: ../core/plugin.h ../core/pluginmsg.h ../core/system.h
|
||||
functions.o: ../core/sessionmanager.h ../core/sessioncontainer.h
|
||||
functions.o: ../functions/functions.h ../templates/templates.h
|
||||
functions.o: ../templates/patterncacher.h ../templates/ckeditorgetparser.h
|
||||
functions.o: ../core/httpsimpleparser.h ../core/log.h
|
||||
functions.o: ../templates/indexpatterns.h ../core/sessionmanager.h
|
||||
functions.o: ../core/basethread.h ../functions/functions.h
|
||||
functions.o: ../templates/templates.h ../templates/patterncacher.h
|
||||
functions.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h
|
||||
functions.o: ../core/log.h ../templates/indexpatterns.h
|
||||
functions.o: ../core/sessionmanager.h
|
||||
funthread.o: ../core/misc.h funthread.h functionbase.h ../core/item.h
|
||||
funthread.o: ../db/db.h ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h
|
||||
funthread.o: ../core/textstream.h ../core/misc.h ../core/item.h
|
||||
|
@ -660,7 +661,7 @@ reload.o: ../core/synchro.h ../templates/templates.h
|
|||
reload.o: ../templates/patterncacher.h ../templates/ckeditorgetparser.h
|
||||
reload.o: ../core/httpsimpleparser.h ../core/log.h
|
||||
reload.o: ../templates/indexpatterns.h ../core/sessionmanager.h
|
||||
reload.o: ../core/sessioncontainer.h ../core/system.h
|
||||
reload.o: ../core/sessioncontainer.h ../core/basethread.h ../core/system.h
|
||||
rm.o: rm.h functionbase.h ../core/item.h ../db/db.h ../db/dbbase.h
|
||||
rm.o: ../db/dbconn.h ../db/dbtextstream.h ../core/textstream.h ../core/misc.h
|
||||
rm.o: ../core/item.h ../core/error.h ../core/log.h ../core/textstream.h
|
||||
|
@ -687,7 +688,7 @@ rm.o: ../core/mounts.h ../core/mount.h ../core/mountparser.h ../core/users.h
|
|||
rm.o: ../core/groups.h ../core/group.h ../core/loadavg.h ../core/synchro.h
|
||||
rm.o: ../core/plugin.h ../core/pluginmsg.h ../core/system.h
|
||||
rm.o: ../core/sessionmanager.h ../core/sessioncontainer.h
|
||||
rm.o: ../functions/functions.h ../templates/templates.h
|
||||
rm.o: ../core/basethread.h ../functions/functions.h ../templates/templates.h
|
||||
rm.o: ../templates/patterncacher.h ../templates/ckeditorgetparser.h
|
||||
rm.o: ../core/httpsimpleparser.h ../core/log.h ../templates/indexpatterns.h
|
||||
rm.o: ../core/sessionmanager.h ../core/misc.h
|
||||
|
|
|
@ -22,21 +22,22 @@ main.o: ../core/config.h ../core/users.h ../core/ugcontainer.h
|
|||
main.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h
|
||||
main.o: ../core/mountparser.h ../core/users.h ../core/groups.h
|
||||
main.o: ../core/group.h ../core/loadavg.h ../core/sessionmanager.h
|
||||
main.o: ../core/sessioncontainer.h ../functions/functions.h
|
||||
main.o: ../functions/functionbase.h ../core/request.h ../core/system.h
|
||||
main.o: ../core/synchro.h ../functions/functionparser.h
|
||||
main.o: ../functions/adduser.h ../functions/cat.h ../functions/chmod.h
|
||||
main.o: ../functions/privchanger.h ../functions/chown.h
|
||||
main.o: ../functions/ckeditor.h ../functions/cp.h ../functions/createthread.h
|
||||
main.o: ../functions/default.h ../functions/download.h ../functions/emacs.h
|
||||
main.o: ../functions/last.h ../functions/login.h ../functions/logout.h
|
||||
main.o: ../functions/ls.h ../functions/mkdir.h ../functions/mv.h
|
||||
main.o: ../functions/node.h ../functions/priv.h ../functions/reload.h
|
||||
main.o: ../functions/rm.h ../functions/run.h ../functions/stat.h
|
||||
main.o: ../functions/subject.h ../functions/funthread.h
|
||||
main.o: ../functions/template.h ../functions/tinymce.h ../functions/uname.h
|
||||
main.o: ../functions/upload.h ../functions/uptime.h ../functions/who.h
|
||||
main.o: ../functions/vim.h ../core/htmlfilter.h ../templates/templates.h
|
||||
main.o: ../core/sessioncontainer.h ../core/basethread.h
|
||||
main.o: ../functions/functions.h ../functions/functionbase.h
|
||||
main.o: ../core/request.h ../core/system.h ../core/synchro.h
|
||||
main.o: ../functions/functionparser.h ../functions/adduser.h
|
||||
main.o: ../functions/cat.h ../functions/chmod.h ../functions/privchanger.h
|
||||
main.o: ../functions/chown.h ../functions/ckeditor.h ../functions/cp.h
|
||||
main.o: ../functions/createthread.h ../functions/default.h
|
||||
main.o: ../functions/download.h ../functions/emacs.h ../functions/last.h
|
||||
main.o: ../functions/login.h ../functions/logout.h ../functions/ls.h
|
||||
main.o: ../functions/mkdir.h ../functions/mv.h ../functions/node.h
|
||||
main.o: ../functions/priv.h ../functions/reload.h ../functions/rm.h
|
||||
main.o: ../functions/run.h ../functions/stat.h ../functions/subject.h
|
||||
main.o: ../functions/funthread.h ../functions/template.h
|
||||
main.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h
|
||||
main.o: ../functions/uptime.h ../functions/who.h ../functions/vim.h
|
||||
main.o: ../core/htmlfilter.h ../templates/templates.h
|
||||
main.o: ../templates/patterncacher.h ../templates/ckeditorgetparser.h
|
||||
main.o: ../core/httpsimpleparser.h ../core/log.h ../templates/indexpatterns.h
|
||||
main.o: ../core/sessionmanager.h ../core/compress.h ../core/getparser.h
|
||||
|
|
|
@ -26,12 +26,13 @@ notify.o: ../core/dirs.h ../core/dircontainer.h ../notify/notify.h
|
|||
notify.o: ../core/mounts.h ../core/mount.h ../core/mountparser.h
|
||||
notify.o: ../core/users.h ../core/groups.h ../core/group.h ../core/loadavg.h
|
||||
notify.o: ../core/sessionmanager.h ../core/sessioncontainer.h
|
||||
notify.o: ../core/system.h ../core/dirs.h ../core/synchro.h ../core/plugin.h
|
||||
notify.o: ../core/pluginmsg.h ../core/sessionmanager.h
|
||||
notify.o: ../functions/functions.h ../functions/functionbase.h
|
||||
notify.o: ../functions/functionparser.h ../functions/adduser.h
|
||||
notify.o: ../functions/cat.h ../functions/chmod.h ../functions/privchanger.h
|
||||
notify.o: ../functions/chown.h ../functions/ckeditor.h ../functions/cp.h
|
||||
notify.o: ../core/basethread.h ../core/system.h ../core/dirs.h
|
||||
notify.o: ../core/synchro.h ../core/plugin.h ../core/pluginmsg.h
|
||||
notify.o: ../core/sessionmanager.h ../functions/functions.h
|
||||
notify.o: ../functions/functionbase.h ../functions/functionparser.h
|
||||
notify.o: ../functions/adduser.h ../functions/cat.h ../functions/chmod.h
|
||||
notify.o: ../functions/privchanger.h ../functions/chown.h
|
||||
notify.o: ../functions/ckeditor.h ../functions/cp.h
|
||||
notify.o: ../functions/createthread.h ../functions/default.h
|
||||
notify.o: ../functions/download.h ../functions/emacs.h ../functions/last.h
|
||||
notify.o: ../functions/login.h ../functions/logout.h ../functions/ls.h
|
||||
|
@ -108,4 +109,4 @@ templatesnotify.o: ../core/httpsimpleparser.h ../core/log.h
|
|||
templatesnotify.o: ../templates/indexpatterns.h ../templates/localefilter.h
|
||||
templatesnotify.o: ../templates/locale.h ../templates/htmltextstream.h
|
||||
templatesnotify.o: ../core/sessionmanager.h ../core/sessioncontainer.h
|
||||
templatesnotify.o: ../core/lastcontainer.h
|
||||
templatesnotify.o: ../core/lastcontainer.h ../core/basethread.h
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
|
||||
|
||||
Notify::Notify() : thread_signal(PTHREAD_COND_INITIALIZER)
|
||||
Notify::Notify()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -62,9 +62,7 @@ void Notify::Init()
|
|||
notify_thread.SetUsers(users);
|
||||
notify_thread.SetNotifyPool(¬ify_pool);
|
||||
notify_thread.SetPatterns(&patterns);
|
||||
|
||||
notify_thread.SetSynchro(synchro);
|
||||
notify_thread.SetSignal(&thread_signal);
|
||||
|
||||
notify_template_cms = AddTemplate(L"notify_email_cms.txt"); // !! do konfiga
|
||||
notify_template_thread = AddTemplate(L"notify_email_thread.txt");
|
||||
|
@ -133,7 +131,7 @@ void Notify::ItemChanged(int notify_code, const Item & item)
|
|||
void Notify::ItemChanged(const NotifyMsg & msg)
|
||||
{
|
||||
notify_pool.Add(msg);
|
||||
SendSignalToThread(); // we are in the first locked thread
|
||||
notify_thread.WakeUpThread(); // we are in the first locked thread
|
||||
}
|
||||
|
||||
|
||||
|
@ -145,6 +143,13 @@ void Notify::StartThread()
|
|||
}
|
||||
|
||||
|
||||
void Notify::PrepareToStopThread()
|
||||
{
|
||||
// synchro->was_stop_signal is true
|
||||
notify_thread.WakeUpThread();
|
||||
}
|
||||
|
||||
|
||||
void Notify::WaitForThread()
|
||||
{
|
||||
notify_thread.WaitForThread();
|
||||
|
@ -186,8 +191,3 @@ static std::wstring tmp_path;
|
|||
|
||||
|
||||
|
||||
void Notify::SendSignalToThread()
|
||||
{
|
||||
// you should use it with: synchro->Lock() and Unlock()
|
||||
pthread_cond_signal(&thread_signal);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
void Init();
|
||||
|
||||
void StartThread();
|
||||
void SendSignalToThread(); // use it in lock/unlock
|
||||
void PrepareToStopThread();
|
||||
void WaitForThread();
|
||||
|
||||
size_t AddTemplate(const std::wstring & file_name);
|
||||
|
@ -60,9 +60,6 @@ private:
|
|||
NotifyMsg msg;
|
||||
NotifyPool notify_pool;
|
||||
|
||||
// conditional variable
|
||||
pthread_cond_t thread_signal;
|
||||
|
||||
size_t notify_template_cms;
|
||||
size_t notify_template_thread;
|
||||
|
||||
|
|
|
@ -28,28 +28,28 @@ init.o: ../../core/ugcontainer.h ../../core/lastcontainer.h
|
|||
init.o: ../../core/mounts.h ../../core/mount.h ../../core/mountparser.h
|
||||
init.o: ../../core/users.h ../../core/groups.h ../../core/group.h
|
||||
init.o: ../../core/loadavg.h ../../core/sessionmanager.h
|
||||
init.o: ../../core/sessioncontainer.h ../../functions/functions.h
|
||||
init.o: ../../functions/functionbase.h ../../core/system.h
|
||||
init.o: ../../core/synchro.h ../../functions/functionparser.h
|
||||
init.o: ../../functions/adduser.h ../../functions/cat.h
|
||||
init.o: ../../functions/chmod.h ../../functions/privchanger.h
|
||||
init.o: ../../functions/chown.h ../../functions/ckeditor.h
|
||||
init.o: ../../functions/cp.h ../../functions/createthread.h
|
||||
init.o: ../../functions/default.h ../../functions/download.h
|
||||
init.o: ../../functions/emacs.h ../../functions/last.h
|
||||
init.o: ../../functions/login.h ../../functions/logout.h ../../functions/ls.h
|
||||
init.o: ../../functions/mkdir.h ../../functions/mv.h ../../functions/node.h
|
||||
init.o: ../../functions/priv.h ../../functions/reload.h ../../functions/rm.h
|
||||
init.o: ../../functions/run.h ../../functions/stat.h
|
||||
init.o: ../../functions/subject.h ../../functions/funthread.h
|
||||
init.o: ../../functions/template.h ../../functions/tinymce.h
|
||||
init.o: ../../functions/uname.h ../../functions/upload.h
|
||||
init.o: ../../functions/uptime.h ../../functions/who.h ../../functions/vim.h
|
||||
init.o: ../../core/htmlfilter.h ../../templates/templates.h
|
||||
init.o: ../../templates/patterncacher.h ../../templates/ckeditorgetparser.h
|
||||
init.o: ../../core/httpsimpleparser.h ../../core/log.h
|
||||
init.o: ../../templates/indexpatterns.h ../../core/sessionmanager.h
|
||||
init.o: statssession.h ../../core/plugindata.h
|
||||
init.o: ../../core/sessioncontainer.h ../../core/basethread.h
|
||||
init.o: ../../functions/functions.h ../../functions/functionbase.h
|
||||
init.o: ../../core/system.h ../../core/synchro.h
|
||||
init.o: ../../functions/functionparser.h ../../functions/adduser.h
|
||||
init.o: ../../functions/cat.h ../../functions/chmod.h
|
||||
init.o: ../../functions/privchanger.h ../../functions/chown.h
|
||||
init.o: ../../functions/ckeditor.h ../../functions/cp.h
|
||||
init.o: ../../functions/createthread.h ../../functions/default.h
|
||||
init.o: ../../functions/download.h ../../functions/emacs.h
|
||||
init.o: ../../functions/last.h ../../functions/login.h
|
||||
init.o: ../../functions/logout.h ../../functions/ls.h ../../functions/mkdir.h
|
||||
init.o: ../../functions/mv.h ../../functions/node.h ../../functions/priv.h
|
||||
init.o: ../../functions/reload.h ../../functions/rm.h ../../functions/run.h
|
||||
init.o: ../../functions/stat.h ../../functions/subject.h
|
||||
init.o: ../../functions/funthread.h ../../functions/template.h
|
||||
init.o: ../../functions/tinymce.h ../../functions/uname.h
|
||||
init.o: ../../functions/upload.h ../../functions/uptime.h
|
||||
init.o: ../../functions/who.h ../../functions/vim.h ../../core/htmlfilter.h
|
||||
init.o: ../../templates/templates.h ../../templates/patterncacher.h
|
||||
init.o: ../../templates/ckeditorgetparser.h ../../core/httpsimpleparser.h
|
||||
init.o: ../../core/log.h ../../templates/indexpatterns.h
|
||||
init.o: ../../core/sessionmanager.h statssession.h ../../core/plugindata.h
|
||||
stats.o: stats.h ../../core/config.h ../../core/log.h ../../core/textstream.h
|
||||
stats.o: ../../core/misc.h ../../core/item.h ../../../ezc/src/utf8.h
|
||||
templates.o: templates.h ../../core/plugin.h ../../core/pluginmsg.h
|
||||
|
@ -78,29 +78,30 @@ templates.o: ../../core/mounts.h ../../core/mount.h ../../core/error.h
|
|||
templates.o: ../../core/mountparser.h ../../core/users.h ../../core/groups.h
|
||||
templates.o: ../../core/group.h ../../core/rebus.h ../../core/loadavg.h
|
||||
templates.o: ../../core/sessionmanager.h ../../core/sessioncontainer.h
|
||||
templates.o: ../../core/session.h ../../functions/functions.h
|
||||
templates.o: ../../functions/functionbase.h ../../core/request.h
|
||||
templates.o: ../../core/requesttypes.h ../../core/textstream.h
|
||||
templates.o: ../../core/misc.h ../../templates/htmltextstream.h
|
||||
templates.o: ../../core/system.h ../../core/synchro.h
|
||||
templates.o: ../../functions/functionparser.h ../../functions/adduser.h
|
||||
templates.o: ../../functions/cat.h ../../functions/chmod.h
|
||||
templates.o: ../../functions/privchanger.h ../../functions/chown.h
|
||||
templates.o: ../../functions/ckeditor.h ../../functions/cp.h
|
||||
templates.o: ../../functions/createthread.h ../../functions/default.h
|
||||
templates.o: ../../functions/download.h ../../functions/emacs.h
|
||||
templates.o: ../../functions/last.h ../../functions/login.h
|
||||
templates.o: ../../functions/logout.h ../../functions/ls.h
|
||||
templates.o: ../../functions/mkdir.h ../../functions/mv.h
|
||||
templates.o: ../../functions/node.h ../../functions/priv.h
|
||||
templates.o: ../../functions/reload.h ../../functions/rm.h
|
||||
templates.o: ../../functions/run.h ../../functions/stat.h
|
||||
templates.o: ../../functions/subject.h ../../functions/funthread.h
|
||||
templates.o: ../../functions/template.h ../../functions/tinymce.h
|
||||
templates.o: ../../functions/uname.h ../../functions/upload.h
|
||||
templates.o: ../../functions/uptime.h ../../functions/who.h
|
||||
templates.o: ../../functions/vim.h ../../core/htmlfilter.h
|
||||
templates.o: ../../templates/templates.h ../../templates/patterncacher.h
|
||||
templates.o: ../../core/session.h ../../core/basethread.h
|
||||
templates.o: ../../functions/functions.h ../../functions/functionbase.h
|
||||
templates.o: ../../core/request.h ../../core/requesttypes.h
|
||||
templates.o: ../../core/textstream.h ../../core/misc.h
|
||||
templates.o: ../../templates/htmltextstream.h ../../core/system.h
|
||||
templates.o: ../../core/synchro.h ../../functions/functionparser.h
|
||||
templates.o: ../../functions/adduser.h ../../functions/cat.h
|
||||
templates.o: ../../functions/chmod.h ../../functions/privchanger.h
|
||||
templates.o: ../../functions/chown.h ../../functions/ckeditor.h
|
||||
templates.o: ../../functions/cp.h ../../functions/createthread.h
|
||||
templates.o: ../../functions/default.h ../../functions/download.h
|
||||
templates.o: ../../functions/emacs.h ../../functions/last.h
|
||||
templates.o: ../../functions/login.h ../../functions/logout.h
|
||||
templates.o: ../../functions/ls.h ../../functions/mkdir.h
|
||||
templates.o: ../../functions/mv.h ../../functions/node.h
|
||||
templates.o: ../../functions/priv.h ../../functions/reload.h
|
||||
templates.o: ../../functions/rm.h ../../functions/run.h
|
||||
templates.o: ../../functions/stat.h ../../functions/subject.h
|
||||
templates.o: ../../functions/funthread.h ../../functions/template.h
|
||||
templates.o: ../../functions/tinymce.h ../../functions/uname.h
|
||||
templates.o: ../../functions/upload.h ../../functions/uptime.h
|
||||
templates.o: ../../functions/who.h ../../functions/vim.h
|
||||
templates.o: ../../core/htmlfilter.h ../../templates/templates.h
|
||||
templates.o: ../../templates/patterncacher.h
|
||||
templates.o: ../../templates/ckeditorgetparser.h
|
||||
templates.o: ../../core/httpsimpleparser.h ../../core/log.h
|
||||
templates.o: ../../templates/indexpatterns.h ../../core/sessionmanager.h
|
||||
|
|
|
@ -157,26 +157,26 @@ init.o: ../../core/plugindata.h ../../templates/htmltextstream.h
|
|||
init.o: ../../core/synchro.h editticket.h createticket.h ../../core/log.h
|
||||
init.o: ../../core/plugin.h ../../core/pluginmsg.h ../../core/system.h
|
||||
init.o: ../../core/sessionmanager.h ../../core/sessioncontainer.h
|
||||
init.o: ../../functions/functions.h ../../functions/functionbase.h
|
||||
init.o: ../../functions/functionparser.h ../../functions/adduser.h
|
||||
init.o: ../../functions/cat.h ../../functions/chmod.h
|
||||
init.o: ../../functions/privchanger.h ../../functions/chown.h
|
||||
init.o: ../../functions/ckeditor.h ../../functions/cp.h
|
||||
init.o: ../../functions/createthread.h ../../functions/default.h
|
||||
init.o: ../../functions/download.h ../../functions/emacs.h
|
||||
init.o: ../../functions/last.h ../../functions/login.h
|
||||
init.o: ../../functions/logout.h ../../functions/ls.h ../../functions/mkdir.h
|
||||
init.o: ../../functions/mv.h ../../functions/node.h ../../functions/priv.h
|
||||
init.o: ../../functions/reload.h ../../functions/rm.h ../../functions/run.h
|
||||
init.o: ../../functions/stat.h ../../functions/subject.h
|
||||
init.o: ../../functions/funthread.h ../../functions/template.h
|
||||
init.o: ../../functions/tinymce.h ../../functions/uname.h
|
||||
init.o: ../../functions/upload.h ../../functions/uptime.h
|
||||
init.o: ../../functions/who.h ../../functions/vim.h ../../core/htmlfilter.h
|
||||
init.o: ../../templates/templates.h ../../templates/patterncacher.h
|
||||
init.o: ../../templates/ckeditorgetparser.h ../../core/httpsimpleparser.h
|
||||
init.o: ../../core/log.h ../../templates/indexpatterns.h
|
||||
init.o: ../../core/sessionmanager.h
|
||||
init.o: ../../core/basethread.h ../../functions/functions.h
|
||||
init.o: ../../functions/functionbase.h ../../functions/functionparser.h
|
||||
init.o: ../../functions/adduser.h ../../functions/cat.h
|
||||
init.o: ../../functions/chmod.h ../../functions/privchanger.h
|
||||
init.o: ../../functions/chown.h ../../functions/ckeditor.h
|
||||
init.o: ../../functions/cp.h ../../functions/createthread.h
|
||||
init.o: ../../functions/default.h ../../functions/download.h
|
||||
init.o: ../../functions/emacs.h ../../functions/last.h
|
||||
init.o: ../../functions/login.h ../../functions/logout.h ../../functions/ls.h
|
||||
init.o: ../../functions/mkdir.h ../../functions/mv.h ../../functions/node.h
|
||||
init.o: ../../functions/priv.h ../../functions/reload.h ../../functions/rm.h
|
||||
init.o: ../../functions/run.h ../../functions/stat.h
|
||||
init.o: ../../functions/subject.h ../../functions/funthread.h
|
||||
init.o: ../../functions/template.h ../../functions/tinymce.h
|
||||
init.o: ../../functions/uname.h ../../functions/upload.h
|
||||
init.o: ../../functions/uptime.h ../../functions/who.h ../../functions/vim.h
|
||||
init.o: ../../core/htmlfilter.h ../../templates/templates.h
|
||||
init.o: ../../templates/patterncacher.h ../../templates/ckeditorgetparser.h
|
||||
init.o: ../../core/httpsimpleparser.h ../../core/log.h
|
||||
init.o: ../../templates/indexpatterns.h ../../core/sessionmanager.h
|
||||
tdb.o: tdb.h ticket.h ../../db/dbbase.h ../../db/dbconn.h
|
||||
tdb.o: ../../db/dbtextstream.h ../../core/textstream.h ../../core/misc.h
|
||||
tdb.o: ../../core/item.h ../../core/error.h ../../core/log.h
|
||||
|
@ -213,25 +213,26 @@ templates.o: ../../templates/htmltextstream.h ../../core/synchro.h
|
|||
templates.o: createticket.h ../../core/misc.h ../../core/plugin.h
|
||||
templates.o: ../../core/pluginmsg.h ../../core/system.h
|
||||
templates.o: ../../core/sessionmanager.h ../../core/sessioncontainer.h
|
||||
templates.o: ../../functions/functions.h ../../functions/functionbase.h
|
||||
templates.o: ../../functions/functionparser.h ../../functions/adduser.h
|
||||
templates.o: ../../functions/cat.h ../../functions/chmod.h
|
||||
templates.o: ../../functions/privchanger.h ../../functions/chown.h
|
||||
templates.o: ../../functions/ckeditor.h ../../functions/cp.h
|
||||
templates.o: ../../functions/createthread.h ../../functions/default.h
|
||||
templates.o: ../../functions/download.h ../../functions/emacs.h
|
||||
templates.o: ../../functions/last.h ../../functions/login.h
|
||||
templates.o: ../../functions/logout.h ../../functions/ls.h
|
||||
templates.o: ../../functions/mkdir.h ../../functions/mv.h
|
||||
templates.o: ../../functions/node.h ../../functions/priv.h
|
||||
templates.o: ../../functions/reload.h ../../functions/rm.h
|
||||
templates.o: ../../functions/run.h ../../functions/stat.h
|
||||
templates.o: ../../functions/subject.h ../../functions/funthread.h
|
||||
templates.o: ../../functions/template.h ../../functions/tinymce.h
|
||||
templates.o: ../../functions/uname.h ../../functions/upload.h
|
||||
templates.o: ../../functions/uptime.h ../../functions/who.h
|
||||
templates.o: ../../functions/vim.h ../../core/htmlfilter.h
|
||||
templates.o: ../../templates/templates.h ../../templates/patterncacher.h
|
||||
templates.o: ../../core/basethread.h ../../functions/functions.h
|
||||
templates.o: ../../functions/functionbase.h ../../functions/functionparser.h
|
||||
templates.o: ../../functions/adduser.h ../../functions/cat.h
|
||||
templates.o: ../../functions/chmod.h ../../functions/privchanger.h
|
||||
templates.o: ../../functions/chown.h ../../functions/ckeditor.h
|
||||
templates.o: ../../functions/cp.h ../../functions/createthread.h
|
||||
templates.o: ../../functions/default.h ../../functions/download.h
|
||||
templates.o: ../../functions/emacs.h ../../functions/last.h
|
||||
templates.o: ../../functions/login.h ../../functions/logout.h
|
||||
templates.o: ../../functions/ls.h ../../functions/mkdir.h
|
||||
templates.o: ../../functions/mv.h ../../functions/node.h
|
||||
templates.o: ../../functions/priv.h ../../functions/reload.h
|
||||
templates.o: ../../functions/rm.h ../../functions/run.h
|
||||
templates.o: ../../functions/stat.h ../../functions/subject.h
|
||||
templates.o: ../../functions/funthread.h ../../functions/template.h
|
||||
templates.o: ../../functions/tinymce.h ../../functions/uname.h
|
||||
templates.o: ../../functions/upload.h ../../functions/uptime.h
|
||||
templates.o: ../../functions/who.h ../../functions/vim.h
|
||||
templates.o: ../../core/htmlfilter.h ../../templates/templates.h
|
||||
templates.o: ../../templates/patterncacher.h
|
||||
templates.o: ../../templates/ckeditorgetparser.h
|
||||
templates.o: ../../core/httpsimpleparser.h ../../core/log.h
|
||||
templates.o: ../../templates/indexpatterns.h ../../core/sessionmanager.h
|
||||
|
|
|
@ -23,7 +23,7 @@ adduser.o: ../notify/templatesnotify.h ../core/users.h ../core/ugcontainer.h
|
|||
adduser.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h
|
||||
adduser.o: ../core/mountparser.h ../core/users.h ../core/groups.h
|
||||
adduser.o: ../core/group.h ../core/loadavg.h ../core/sessionmanager.h
|
||||
adduser.o: ../core/sessioncontainer.h ../core/system.h
|
||||
adduser.o: ../core/sessioncontainer.h ../core/basethread.h ../core/system.h
|
||||
dir.o: templates.h ../../ezc/src/ezc.h ../../ezc/src/utf8.h
|
||||
dir.o: ../../ezc/src/generator.h ../../ezc/src/pattern.h ../../ezc/src/item.h
|
||||
dir.o: ../../ezc/src/funinfo.h ../../ezc/src/functions.h
|
||||
|
@ -46,8 +46,8 @@ dir.o: ../notify/templatesnotify.h ../core/users.h ../core/ugcontainer.h
|
|||
dir.o: ../core/lastcontainer.h ../core/mounts.h ../core/mount.h
|
||||
dir.o: ../core/mountparser.h ../core/users.h ../core/groups.h ../core/group.h
|
||||
dir.o: ../core/loadavg.h ../core/sessionmanager.h ../core/sessioncontainer.h
|
||||
dir.o: ../core/system.h ../core/misc.h ../functions/functions.h
|
||||
dir.o: ../functions/functionbase.h ../core/synchro.h
|
||||
dir.o: ../core/basethread.h ../core/system.h ../core/misc.h
|
||||
dir.o: ../functions/functions.h ../functions/functionbase.h ../core/synchro.h
|
||||
dir.o: ../functions/functionparser.h ../functions/adduser.h
|
||||
dir.o: ../functions/cat.h ../functions/chmod.h ../functions/privchanger.h
|
||||
dir.o: ../functions/chown.h ../ |