changed: updated to the new ezc api, this with O(1) when looking for a specific ezc function

changed: sessions are deleted at the end of a request (and only a few sessions)
         other sessions will be deleted after a next request


git-svn-id: svn://ttmath.org/publicrep/winix/trunk@684 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2010-11-25 22:42:24 +00:00
parent 933c8841ff
commit 08e53919e2
25 changed files with 753 additions and 634 deletions

View File

@@ -12,10 +12,10 @@ app.o: mount.h mountparser.h users.h ugcontainer.h lastcontainer.h groups.h
app.o: group.h loadavg.h sessionmanager.h sessioncontainer.h notify.h
app.o: ../templatesnotify/templatesnotify.h ../../ezc/src/ezc.h
app.o: ../../ezc/src/utf8.h ../../ezc/src/generator.h ../../ezc/src/pattern.h
app.o: ../../ezc/src/stringconv.h ../../ezc/src/functions.h
app.o: ../../ezc/src/funinfo.h ../core/mount.h ../core/config.h
app.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h
app.o: ../../ezc/src/stringconv.h ../core/mount.h ../core/config.h
app.o: ../templates/misc.h ../templates/localefilter.h ../templates/locale.h
app.o: ../core/confparser.h ../templates/htmltextstream.h
app.o: ../core/confparser.h ../templates/htmltextstream.h ../core/log.h
app.o: ../functions/functions.h ../functions/functionbase.h ../core/request.h
app.o: ../core/system.h ../core/notify.h ../functions/functionparser.h
app.o: ../functions/adduser.h ../functions/cat.h ../functions/chmod.h
@@ -64,8 +64,8 @@ config.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h
config.o: ../functions/uptime.h ../functions/who.h ../functions/vim.h
config.o: ../core/htmlfilter.h ../templates/templates.h ../../ezc/src/ezc.h
config.o: ../../ezc/src/generator.h ../../ezc/src/pattern.h
config.o: ../../ezc/src/stringconv.h ../../ezc/src/functions.h
config.o: ../../ezc/src/funinfo.h ../templates/patterncacher.h
config.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h
config.o: ../../ezc/src/stringconv.h ../templates/patterncacher.h
config.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h
config.o: ../core/log.h ../templates/indexpatterns.h
config.o: ../templates/localefilter.h ../templates/locale.h
@@ -82,12 +82,13 @@ dirs.o: session.h error.h user.h plugindata.h rebus.h config.h confparser.h
dirs.o: htmlfilter.h ../templates/htmltextstream.h notify.h
dirs.o: ../templatesnotify/templatesnotify.h ../../ezc/src/ezc.h
dirs.o: ../../ezc/src/utf8.h ../../ezc/src/generator.h
dirs.o: ../../ezc/src/pattern.h ../../ezc/src/stringconv.h
dirs.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h ../core/mount.h
dirs.o: ../../ezc/src/pattern.h ../../ezc/src/functions.h
dirs.o: ../../ezc/src/funinfo.h ../../ezc/src/stringconv.h ../core/mount.h
dirs.o: ../core/config.h ../templates/misc.h ../templates/localefilter.h
dirs.o: ../templates/locale.h ../core/confparser.h
dirs.o: ../templates/htmltextstream.h system.h mounts.h mount.h mountparser.h
dirs.o: users.h ugcontainer.h lastcontainer.h groups.h group.h loadavg.h
dirs.o: ../templates/htmltextstream.h ../core/log.h system.h mounts.h mount.h
dirs.o: mountparser.h users.h ugcontainer.h lastcontainer.h groups.h group.h
dirs.o: loadavg.h
groups.o: groups.h group.h ugcontainer.h ../db/db.h ../db/dbbase.h
groups.o: ../db/dbconn.h ../db/dbtextstream.h ../core/textstream.h misc.h
groups.o: item.h ../core/error.h log.h textstream.h ../db/dbitemquery.h
@@ -101,8 +102,8 @@ loadavg.o: loadavg.h log.h textstream.h
log.o: log.h textstream.h ../../ezc/src/utf8.h
misc.o: misc.h item.h log.h textstream.h ../templates/templates.h
misc.o: ../../ezc/src/ezc.h ../../ezc/src/utf8.h ../../ezc/src/generator.h
misc.o: ../../ezc/src/pattern.h ../../ezc/src/stringconv.h
misc.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h
misc.o: ../../ezc/src/pattern.h ../../ezc/src/functions.h
misc.o: ../../ezc/src/funinfo.h ../../ezc/src/stringconv.h
misc.o: ../templates/patterncacher.h ../core/item.h
misc.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h
misc.o: ../core/log.h ../templates/indexpatterns.h
@@ -150,8 +151,8 @@ mounts.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h
mounts.o: ../functions/uptime.h ../functions/who.h ../functions/vim.h
mounts.o: ../core/htmlfilter.h ../templates/templates.h ../../ezc/src/ezc.h
mounts.o: ../../ezc/src/generator.h ../../ezc/src/pattern.h
mounts.o: ../../ezc/src/stringconv.h ../../ezc/src/functions.h
mounts.o: ../../ezc/src/funinfo.h ../templates/patterncacher.h
mounts.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h
mounts.o: ../../ezc/src/stringconv.h ../templates/patterncacher.h
mounts.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h
mounts.o: ../core/log.h ../templates/indexpatterns.h
mounts.o: ../templates/localefilter.h ../templates/locale.h
@@ -159,13 +160,13 @@ mounts.o: ../core/confparser.h ../templates/htmltextstream.h
mounts.o: ../core/sessionmanager.h
notify.o: log.h textstream.h notify.h ../templatesnotify/templatesnotify.h
notify.o: ../../ezc/src/ezc.h ../../ezc/src/utf8.h ../../ezc/src/generator.h
notify.o: ../../ezc/src/pattern.h item.h ../../ezc/src/stringconv.h
notify.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h ../core/mount.h
notify.o: ../../ezc/src/pattern.h item.h ../../ezc/src/functions.h
notify.o: ../../ezc/src/funinfo.h ../../ezc/src/stringconv.h ../core/mount.h
notify.o: ../core/config.h ../core/textstream.h misc.h ../templates/misc.h
notify.o: ../templates/localefilter.h ../templates/locale.h
notify.o: ../core/confparser.h ../templates/htmltextstream.h ../core/user.h
notify.o: request.h requesttypes.h session.h error.h user.h plugindata.h
notify.o: rebus.h config.h confparser.h htmlfilter.h
notify.o: ../core/log.h request.h requesttypes.h session.h error.h user.h
notify.o: plugindata.h rebus.h config.h confparser.h htmlfilter.h
notify.o: ../templates/htmltextstream.h system.h dirs.h dircontainer.h
notify.o: ../db/db.h ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h
notify.o: ../core/error.h ../db/dbitemquery.h ../core/item.h
@@ -200,8 +201,8 @@ plugin.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h
plugin.o: ../functions/uptime.h ../functions/who.h ../functions/vim.h
plugin.o: ../core/htmlfilter.h ../templates/templates.h ../../ezc/src/ezc.h
plugin.o: ../../ezc/src/generator.h ../../ezc/src/pattern.h
plugin.o: ../../ezc/src/stringconv.h ../../ezc/src/functions.h
plugin.o: ../../ezc/src/funinfo.h ../templates/patterncacher.h
plugin.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h
plugin.o: ../../ezc/src/stringconv.h ../templates/patterncacher.h
plugin.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h
plugin.o: ../core/log.h ../templates/indexpatterns.h
plugin.o: ../templates/localefilter.h ../templates/locale.h
@@ -236,8 +237,8 @@ plugindata.o: ../functions/uname.h ../functions/upload.h
plugindata.o: ../functions/uptime.h ../functions/who.h ../functions/vim.h
plugindata.o: ../core/htmlfilter.h ../templates/templates.h
plugindata.o: ../../ezc/src/ezc.h ../../ezc/src/generator.h
plugindata.o: ../../ezc/src/pattern.h ../../ezc/src/stringconv.h
plugindata.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h
plugindata.o: ../../ezc/src/pattern.h ../../ezc/src/functions.h
plugindata.o: ../../ezc/src/funinfo.h ../../ezc/src/stringconv.h
plugindata.o: ../templates/patterncacher.h ../templates/ckeditorgetparser.h
plugindata.o: ../core/httpsimpleparser.h ../core/log.h
plugindata.o: ../templates/indexpatterns.h ../templates/localefilter.h
@@ -276,8 +277,8 @@ request.o: ../functions/tinymce.h ../functions/uname.h ../functions/upload.h
request.o: ../functions/uptime.h ../functions/who.h ../functions/vim.h
request.o: ../core/htmlfilter.h ../templates/templates.h ../../ezc/src/ezc.h
request.o: ../../ezc/src/generator.h ../../ezc/src/pattern.h
request.o: ../../ezc/src/stringconv.h ../../ezc/src/functions.h
request.o: ../../ezc/src/funinfo.h ../templates/patterncacher.h
request.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h
request.o: ../../ezc/src/stringconv.h ../templates/patterncacher.h
request.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h
request.o: ../core/log.h ../templates/indexpatterns.h
request.o: ../templates/localefilter.h ../templates/locale.h
@@ -321,8 +322,8 @@ sessionmanager.o: ../functions/uname.h ../functions/upload.h
sessionmanager.o: ../functions/uptime.h ../functions/who.h ../functions/vim.h
sessionmanager.o: ../core/htmlfilter.h ../templates/templates.h
sessionmanager.o: ../../ezc/src/ezc.h ../../ezc/src/generator.h
sessionmanager.o: ../../ezc/src/pattern.h ../../ezc/src/stringconv.h
sessionmanager.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h
sessionmanager.o: ../../ezc/src/pattern.h ../../ezc/src/functions.h
sessionmanager.o: ../../ezc/src/funinfo.h ../../ezc/src/stringconv.h
sessionmanager.o: ../templates/patterncacher.h
sessionmanager.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h
sessionmanager.o: ../core/log.h ../templates/indexpatterns.h
@@ -350,15 +351,15 @@ system.o: ../templates/htmltextstream.h mounts.h mount.h mountparser.h
system.o: users.h ugcontainer.h lastcontainer.h groups.h group.h loadavg.h
system.o: notify.h ../templatesnotify/templatesnotify.h ../../ezc/src/ezc.h
system.o: ../../ezc/src/utf8.h ../../ezc/src/generator.h
system.o: ../../ezc/src/pattern.h ../../ezc/src/stringconv.h
system.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h ../core/mount.h
system.o: ../../ezc/src/pattern.h ../../ezc/src/functions.h
system.o: ../../ezc/src/funinfo.h ../../ezc/src/stringconv.h ../core/mount.h
system.o: ../core/config.h ../templates/misc.h ../templates/localefilter.h
system.o: ../templates/locale.h ../core/confparser.h
system.o: ../templates/htmltextstream.h ../templates/templates.h
system.o: ../templates/patterncacher.h ../templates/ckeditorgetparser.h
system.o: ../core/httpsimpleparser.h ../core/log.h
system.o: ../templates/indexpatterns.h ../core/request.h ../core/system.h
system.o: ../core/sessionmanager.h
system.o: ../templates/htmltextstream.h ../core/log.h
system.o: ../templates/templates.h ../templates/patterncacher.h
system.o: ../templates/ckeditorgetparser.h ../core/httpsimpleparser.h
system.o: ../core/log.h ../templates/indexpatterns.h ../core/request.h
system.o: ../core/system.h ../core/sessionmanager.h
textstream.o: textstream.h misc.h item.h
users.o: users.h user.h ugcontainer.h lastcontainer.h request.h
users.o: requesttypes.h session.h item.h error.h plugindata.h rebus.h

View File

@@ -150,9 +150,10 @@ bool App::Init()
// init templates after functions are created
templates.CreateFunctions(); // create functions first (functions will be cached by patterns)
templates.ReadIndexFileNames();
templates.ReadTemplates();
templates.CreateFunctions();
session_manager.LoadSessions();
plugin.Call(WINIX_PLUGIN_INIT);
@@ -213,8 +214,9 @@ void App::ProcessRequestThrow()
// and then BaseUrlRedirect() will be called (for performance)
if( !BaseUrlRedirect() )
{
session_manager.DeleteOldSessions();
session_manager.SetSession(); // set request.session as well
// !! dac zeby zwracalo wskaznik (zawsze prawidlowy) na sesje
// i tutaj przypisanie do request.session
// !! tutaj dodac to ustawianie request.session
@@ -227,6 +229,10 @@ void App::ProcessRequestThrow()
SendAnswer();
notify.ItemChanged(request.notify_code);
// it's better to remove sessions at the end of a request
// as it can take a little time
session_manager.DeleteOldSessions();
}
@@ -258,6 +264,8 @@ void App::Start()
if( was_stop_signal )
break;
// !! tu bedzie lock.WorkStart()
system.load_avg.StartRequest();
log << log2 << config.log_delimiter << logend;
@@ -270,6 +278,8 @@ void App::Start()
request.Clear();
system.load_avg.StopRequest();
log << logsave;
// !! tu bedzie lock.WorkStop();
}
}
@@ -323,6 +333,7 @@ bool sent = false;
// zmienic nazwe np na ProcessRequest
// !! ta nazwa chyba juz zajeta...
void App::Make()
{
if( request.dir_tab.empty() )

View File

@@ -186,6 +186,9 @@ void Notify::ReadTemplates()
bool Notify::Init()
{
templates_notify->CreateFunctions();
// CreateFunctions() should be called before ReadTemplates()
// because the patterns will cache the functions
ReadTemplates();
int t = pthread_create(&thread, 0, ThreadRoutine, (void*)this);

View File

@@ -119,16 +119,17 @@ return i->second;
void SessionContainer::DelFirstByTimeInterval(time_t interval, bool skip_remember_flag)
size_t SessionContainer::DelFirstByTimeInterval(time_t interval, size_t how_many_max, bool skip_remember_flag)
{
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;
while( i != index_time.end() && i->second->last_time < limit )
while( i != index_time.end() && i->second->last_time < limit && deleted < how_many_max )
{
long id = i->second->id;
//long id = i->second->id; // !! for logs (not used now)
iold = i;
++i; // incrementing before deleting old one
@@ -147,15 +148,22 @@ Session * old_session = request->session;
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;
//log << log3 << "SC: deleted index_time for session id: " << id << logend;
//log << log3 << "SC: deleted session, id: " << id << logend;
}
request->session = old_session;
return deleted;
}
void SessionContainer::DelFromIdIndex(SessionContainer::Iterator iter)
{
IndexId::iterator i;
@@ -165,7 +173,7 @@ IndexId::iterator i;
if( i->second == iter )
{
index_id.erase(i);
log << log3 << "SC: deleted index_id for session id: " << iter->id << logend;
//log << log3 << "SC: deleted index_id for session id: " << iter->id << logend;
break;
}
@@ -190,7 +198,8 @@ void SessionContainer::UpdateLastTime(SessionContainer::Iterator iter, time_t ne
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 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;
}

View File

@@ -70,7 +70,7 @@ public:
bool PushBack(const Session & session);
Iterator FindById(long);
void DelFirstByTimeInterval(time_t interval, bool skip_remember_flag = true);
size_t DelFirstByTimeInterval(time_t interval, size_t how_many_max, bool skip_remember_flag = true);
void UpdateLastTime(Iterator iter, time_t new_time);

View File

@@ -227,16 +227,21 @@ SessionContainer::Iterator SessionManager::SessionEnd()
void SessionManager::DeleteOldSessions()
{
session_tab.DelFirstByTimeInterval(config->session_max_idle);
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;
//log << log3 << "SM: checking sessions which have 'remember me' flag set" << logend;
session_checker = 0;
session_tab.DelFirstByTimeInterval(config->session_remember_max_idle, false);
deleted += session_tab.DelFirstByTimeInterval(config->session_remember_max_idle, 100, false);
}
if( deleted > 0 )
log << log3 << "SM: deleted " << deleted << " outdated sessions" << logend;
}