- now the mess with threads has gone away

- we have a class BaseThread -- this is a base class -- we can inherit from it when
  creating a new thread
- others treads are correctly stopped (when signal comes) -- pthread_join
- we have a special thread only for signals



git-svn-id: svn://ttmath.org/publicrep/winix/trunk@685 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
Tomasz Sowa 2010-12-02 01:02:02 +00:00
parent 08e53919e2
commit 35efed9fef
52 changed files with 2464 additions and 1825 deletions

View File

@ -7,34 +7,37 @@ app.o: ../db/dbtextstream.h ../core/textstream.h misc.h ../core/error.h log.h
app.o: textstream.h ../db/dbitemquery.h ../core/item.h ../db/dbitemcolumns.h
app.o: ../core/user.h ../core/group.h ../core/thread.h ../core/dircontainer.h
app.o: ../core/ugcontainer.h request.h requesttypes.h session.h error.h
app.o: user.h plugindata.h rebus.h ../templates/htmltextstream.h mounts.h
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: user.h plugindata.h rebus.h ../templates/htmltextstream.h
app.o: ../templatesnotify/notify.h ../templatesnotify/notifypool.h
app.o: ../templates/locale.h ../core/confparser.h ../templates/misc.h
app.o: ../templates/localefilter.h ../templates/locale.h ../../ezc/src/ezc.h
app.o: ../../ezc/src/utf8.h ../../ezc/src/generator.h ../../ezc/src/pattern.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 ../core/log.h
app.o: ../../ezc/src/stringconv.h ../templates/htmltextstream.h
app.o: ../templatesnotify/notifythread.h ../core/basethread.h synchro.h
app.o: ../templatesnotify/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/notify.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: ../core/system.h ../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
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
@ -45,11 +48,18 @@ config.o: ../db/db.h ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h
config.o: ../core/error.h ../db/dbitemquery.h ../core/item.h
config.o: ../db/dbitemcolumns.h ../core/user.h ../core/group.h
config.o: ../core/thread.h ../core/dircontainer.h ../core/ugcontainer.h
config.o: mounts.h mount.h mountparser.h users.h ugcontainer.h
config.o: lastcontainer.h groups.h group.h loadavg.h sessionmanager.h
config.o: sessioncontainer.h ../functions/functions.h
config.o: ../functions/functionbase.h ../core/request.h ../core/config.h
config.o: ../core/system.h ../core/notify.h ../../ezc/src/utf8.h
config.o: ../templatesnotify/notify.h ../templatesnotify/notifypool.h
config.o: ../templates/locale.h ../core/confparser.h ../templates/misc.h
config.o: ../templates/localefilter.h ../templates/locale.h
config.o: ../../ezc/src/ezc.h ../../ezc/src/utf8.h ../../ezc/src/generator.h
config.o: ../../ezc/src/pattern.h ../../ezc/src/functions.h
config.o: ../../ezc/src/funinfo.h ../../ezc/src/stringconv.h
config.o: ../templates/htmltextstream.h ../templatesnotify/notifythread.h
config.o: ../core/basethread.h synchro.h ../templatesnotify/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: ../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
@ -62,15 +72,10 @@ config.o: ../functions/run.h ../functions/stat.h ../functions/subject.h
config.o: ../functions/funthread.h ../functions/template.h
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/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
config.o: ../core/confparser.h ../templates/htmltextstream.h
config.o: ../core/sessionmanager.h
config.o: ../core/htmlfilter.h ../templates/templates.h
config.o: ../templates/patterncacher.h ../templates/ckeditorgetparser.h
config.o: ../core/httpsimpleparser.h ../core/log.h
config.o: ../templates/indexpatterns.h ../core/sessionmanager.h
confparser.o: confparser.h misc.h item.h ../../ezc/src/utf8.h
dircontainer.o: dircontainer.h item.h log.h textstream.h
dirs.o: dirs.h item.h dircontainer.h ../db/db.h ../db/dbbase.h ../db/dbconn.h
@ -79,16 +84,16 @@ dirs.o: log.h textstream.h ../db/dbitemquery.h ../core/item.h
dirs.o: ../db/dbitemcolumns.h ../core/user.h ../core/group.h ../core/thread.h
dirs.o: ../core/dircontainer.h ../core/ugcontainer.h request.h requesttypes.h
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: htmlfilter.h ../templates/htmltextstream.h
dirs.o: ../templatesnotify/notify.h ../templatesnotify/notifypool.h
dirs.o: ../templates/locale.h ../core/confparser.h ../templates/misc.h
dirs.o: ../templates/localefilter.h ../templates/locale.h ../../ezc/src/ezc.h
dirs.o: ../../ezc/src/utf8.h ../../ezc/src/generator.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 ../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
dirs.o: ../../ezc/src/funinfo.h ../../ezc/src/stringconv.h
dirs.o: ../templates/htmltextstream.h ../templatesnotify/notifythread.h
dirs.o: ../core/basethread.h synchro.h ../templatesnotify/templatesnotify.h
dirs.o: ../core/config.h ../core/users.h ugcontainer.h lastcontainer.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
@ -107,11 +112,10 @@ 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
misc.o: ../templates/localefilter.h ../templates/locale.h
misc.o: ../core/confparser.h ../core/config.h ../db/db.h ../db/dbbase.h
misc.o: ../db/dbconn.h ../db/dbtextstream.h ../core/textstream.h
misc.o: ../core/error.h ../db/dbitemquery.h ../db/dbitemcolumns.h
misc.o: ../core/user.h ../core/group.h ../core/thread.h
misc.o: ../templates/localefilter.h ../templates/locale.h ../core/config.h
misc.o: ../db/db.h ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h
misc.o: ../core/textstream.h ../core/error.h ../db/dbitemquery.h
misc.o: ../db/dbitemcolumns.h ../core/user.h ../core/group.h ../core/thread.h
misc.o: ../core/dircontainer.h ../core/ugcontainer.h
misc.o: ../templates/htmltextstream.h ../core/request.h ../core/system.h
misc.o: ../core/sessionmanager.h
@ -124,6 +128,16 @@ mountparser.o: ../core/user.h ../core/group.h ../core/thread.h
mountparser.o: ../core/dircontainer.h ../core/ugcontainer.h request.h
mountparser.o: requesttypes.h session.h user.h plugindata.h rebus.h config.h
mountparser.o: confparser.h htmlfilter.h ../templates/htmltextstream.h
mountparser.o: ../templatesnotify/notify.h ../templatesnotify/notifypool.h
mountparser.o: ../templates/locale.h ../core/confparser.h ../templates/misc.h
mountparser.o: ../templates/localefilter.h ../templates/locale.h
mountparser.o: ../../ezc/src/ezc.h ../../ezc/src/utf8.h
mountparser.o: ../../ezc/src/generator.h ../../ezc/src/pattern.h
mountparser.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h
mountparser.o: ../../ezc/src/stringconv.h ../templates/htmltextstream.h
mountparser.o: ../templatesnotify/notifythread.h ../core/basethread.h
mountparser.o: synchro.h ../templatesnotify/templatesnotify.h
mountparser.o: ../core/config.h ../core/users.h ugcontainer.h lastcontainer.h
mounts.o: mounts.h mount.h error.h dirs.h item.h dircontainer.h ../db/db.h
mounts.o: ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h
mounts.o: ../core/textstream.h misc.h ../core/error.h log.h textstream.h
@ -132,14 +146,22 @@ mounts.o: ../core/user.h ../core/group.h ../core/thread.h
mounts.o: ../core/dircontainer.h ../core/ugcontainer.h request.h
mounts.o: requesttypes.h session.h user.h plugindata.h rebus.h config.h
mounts.o: confparser.h htmlfilter.h ../templates/htmltextstream.h
mounts.o: mountparser.h plugin.h pluginmsg.h system.h users.h ugcontainer.h
mounts.o: lastcontainer.h groups.h group.h loadavg.h sessionmanager.h
mounts.o: sessioncontainer.h ../functions/functions.h
mounts.o: ../functions/functionbase.h ../core/request.h ../core/config.h
mounts.o: ../core/system.h ../core/notify.h ../../ezc/src/utf8.h
mounts.o: ../functions/functionparser.h ../functions/adduser.h
mounts.o: ../functions/cat.h ../functions/chmod.h ../functions/privchanger.h
mounts.o: ../functions/chown.h ../functions/ckeditor.h ../functions/cp.h
mounts.o: ../templatesnotify/notify.h ../templatesnotify/notifypool.h
mounts.o: ../templates/locale.h ../core/confparser.h ../templates/misc.h
mounts.o: ../templates/localefilter.h ../templates/locale.h
mounts.o: ../../ezc/src/ezc.h ../../ezc/src/utf8.h ../../ezc/src/generator.h
mounts.o: ../../ezc/src/pattern.h ../../ezc/src/functions.h
mounts.o: ../../ezc/src/funinfo.h ../../ezc/src/stringconv.h
mounts.o: ../templates/htmltextstream.h ../templatesnotify/notifythread.h
mounts.o: ../core/basethread.h synchro.h ../templatesnotify/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: ../functions/functions.h ../functions/functionbase.h
mounts.o: ../core/request.h ../core/system.h ../functions/functionparser.h
mounts.o: ../functions/adduser.h ../functions/cat.h ../functions/chmod.h
mounts.o: ../functions/privchanger.h ../functions/chown.h
mounts.o: ../functions/ckeditor.h ../functions/cp.h
mounts.o: ../functions/createthread.h ../functions/default.h
mounts.o: ../functions/download.h ../functions/emacs.h ../functions/last.h
mounts.o: ../functions/login.h ../functions/logout.h ../functions/ls.h
@ -149,31 +171,10 @@ mounts.o: ../functions/run.h ../functions/stat.h ../functions/subject.h
mounts.o: ../functions/funthread.h ../functions/template.h
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/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
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/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: ../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
notify.o: ../db/dbitemcolumns.h ../core/group.h ../core/thread.h
notify.o: ../core/dircontainer.h ../core/ugcontainer.h mounts.h mount.h
notify.o: mountparser.h users.h ugcontainer.h lastcontainer.h groups.h
notify.o: group.h loadavg.h
mounts.o: ../core/htmlfilter.h ../templates/templates.h
mounts.o: ../templates/patterncacher.h ../templates/ckeditorgetparser.h
mounts.o: ../core/httpsimpleparser.h ../core/log.h
mounts.o: ../templates/indexpatterns.h ../core/sessionmanager.h
plugin.o: plugin.h pluginmsg.h log.h textstream.h plugindata.h config.h
plugin.o: confparser.h htmlfilter.h request.h requesttypes.h session.h item.h
plugin.o: error.h user.h rebus.h ../templates/htmltextstream.h
@ -182,11 +183,18 @@ plugin.o: ../db/db.h ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h
plugin.o: ../core/error.h ../db/dbitemquery.h ../core/item.h
plugin.o: ../db/dbitemcolumns.h ../core/user.h ../core/group.h
plugin.o: ../core/thread.h ../core/dircontainer.h ../core/ugcontainer.h
plugin.o: mounts.h mount.h mountparser.h users.h ugcontainer.h
plugin.o: lastcontainer.h groups.h group.h loadavg.h sessionmanager.h
plugin.o: sessioncontainer.h ../functions/functions.h
plugin.o: ../functions/functionbase.h ../core/request.h ../core/config.h
plugin.o: ../core/system.h ../core/notify.h ../../ezc/src/utf8.h
plugin.o: ../templatesnotify/notify.h ../templatesnotify/notifypool.h
plugin.o: ../templates/locale.h ../core/confparser.h ../templates/misc.h
plugin.o: ../templates/localefilter.h ../templates/locale.h
plugin.o: ../../ezc/src/ezc.h ../../ezc/src/utf8.h ../../ezc/src/generator.h
plugin.o: ../../ezc/src/pattern.h ../../ezc/src/functions.h
plugin.o: ../../ezc/src/funinfo.h ../../ezc/src/stringconv.h
plugin.o: ../templates/htmltextstream.h ../templatesnotify/notifythread.h
plugin.o: ../core/basethread.h synchro.h ../templatesnotify/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: ../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
@ -199,15 +207,10 @@ plugin.o: ../functions/run.h ../functions/stat.h ../functions/subject.h
plugin.o: ../functions/funthread.h ../functions/template.h
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/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
plugin.o: ../core/confparser.h ../templates/htmltextstream.h
plugin.o: ../core/sessionmanager.h
plugin.o: ../core/htmlfilter.h ../templates/templates.h
plugin.o: ../templates/patterncacher.h ../templates/ckeditorgetparser.h
plugin.o: ../core/httpsimpleparser.h ../core/log.h
plugin.o: ../templates/indexpatterns.h ../core/sessionmanager.h
plugindata.o: plugindata.h plugin.h pluginmsg.h log.h textstream.h config.h
plugindata.o: confparser.h htmlfilter.h request.h requesttypes.h session.h
plugindata.o: item.h error.h user.h rebus.h ../templates/htmltextstream.h
@ -216,11 +219,19 @@ plugindata.o: ../db/db.h ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h
plugindata.o: ../core/error.h ../db/dbitemquery.h ../core/item.h
plugindata.o: ../db/dbitemcolumns.h ../core/user.h ../core/group.h
plugindata.o: ../core/thread.h ../core/dircontainer.h ../core/ugcontainer.h
plugindata.o: mounts.h mount.h mountparser.h users.h ugcontainer.h
plugindata.o: lastcontainer.h groups.h group.h loadavg.h sessionmanager.h
plugindata.o: sessioncontainer.h ../functions/functions.h
plugindata.o: ../functions/functionbase.h ../core/request.h ../core/config.h
plugindata.o: ../core/system.h ../core/notify.h ../../ezc/src/utf8.h
plugindata.o: ../templatesnotify/notify.h ../templatesnotify/notifypool.h
plugindata.o: ../templates/locale.h ../core/confparser.h ../templates/misc.h
plugindata.o: ../templates/localefilter.h ../templates/locale.h
plugindata.o: ../../ezc/src/ezc.h ../../ezc/src/utf8.h
plugindata.o: ../../ezc/src/generator.h ../../ezc/src/pattern.h
plugindata.o: ../../ezc/src/functions.h ../../ezc/src/funinfo.h
plugindata.o: ../../ezc/src/stringconv.h ../templates/htmltextstream.h
plugindata.o: ../templatesnotify/notifythread.h ../core/basethread.h
plugindata.o: synchro.h ../templatesnotify/templatesnotify.h ../core/config.h
plugindata.o: ../core/users.h ugcontainer.h lastcontainer.h mounts.h mount.h
plugindata.o: mountparser.h users.h groups.h group.h loadavg.h
plugindata.o: sessionmanager.h sessioncontainer.h ../functions/functions.h
plugindata.o: ../functions/functionbase.h ../core/request.h ../core/system.h
plugindata.o: ../functions/functionparser.h ../functions/adduser.h
plugindata.o: ../functions/cat.h ../functions/chmod.h
plugindata.o: ../functions/privchanger.h ../functions/chown.h
@ -236,14 +247,9 @@ plugindata.o: ../functions/template.h ../functions/tinymce.h
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/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
plugindata.o: ../templates/locale.h ../core/confparser.h
plugindata.o: ../templates/htmltextstream.h ../core/sessionmanager.h
plugindata.o: ../templates/indexpatterns.h ../core/sessionmanager.h
postmultiparser.o: postmultiparser.h error.h requesttypes.h config.h
postmultiparser.o: confparser.h htmlfilter.h log.h textstream.h
postmultiparser.o: ../../ezc/src/utf8.h misc.h item.h
@ -258,11 +264,19 @@ request.o: ../db/db.h ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h
request.o: ../core/error.h ../db/dbitemquery.h ../core/item.h
request.o: ../db/dbitemcolumns.h ../core/user.h ../core/group.h
request.o: ../core/thread.h ../core/dircontainer.h ../core/ugcontainer.h
request.o: mounts.h mount.h mountparser.h users.h ugcontainer.h
request.o: lastcontainer.h groups.h group.h loadavg.h sessionmanager.h
request.o: ../templatesnotify/notify.h ../templatesnotify/notifypool.h
request.o: ../templates/locale.h ../core/confparser.h ../templates/misc.h
request.o: ../templates/localefilter.h ../templates/locale.h
request.o: ../../ezc/src/ezc.h ../../ezc/src/utf8.h ../../ezc/src/generator.h
request.o: ../../ezc/src/pattern.h ../../ezc/src/functions.h
request.o: ../../ezc/src/funinfo.h ../../ezc/src/stringconv.h
request.o: ../templates/htmltextstream.h ../templatesnotify/notifythread.h
request.o: ../core/basethread.h synchro.h
request.o: ../templatesnotify/templatesnotify.h ../core/config.h
request.o: ../core/users.h ugcontainer.h lastcontainer.h mounts.h mount.h
request.o: mountparser.h users.h groups.h group.h loadavg.h sessionmanager.h
request.o: sessioncontainer.h ../functions/functions.h
request.o: ../functions/functionbase.h ../core/request.h ../core/config.h
request.o: ../core/system.h ../core/notify.h ../../ezc/src/utf8.h
request.o: ../functions/functionbase.h ../core/request.h ../core/system.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
@ -275,15 +289,10 @@ request.o: ../functions/run.h ../functions/stat.h ../functions/subject.h
request.o: ../functions/funthread.h ../functions/template.h
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/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
request.o: ../core/confparser.h ../templates/htmltextstream.h
request.o: ../core/sessionmanager.h
request.o: ../core/htmlfilter.h ../templates/templates.h
request.o: ../templates/patterncacher.h ../templates/ckeditorgetparser.h
request.o: ../core/httpsimpleparser.h ../core/log.h
request.o: ../templates/indexpatterns.h ../core/sessionmanager.h
session.o: session.h item.h error.h user.h plugindata.h rebus.h misc.h
sessioncontainer.o: sessioncontainer.h session.h item.h error.h user.h
sessioncontainer.o: plugindata.h rebus.h lastcontainer.h request.h
@ -299,12 +308,22 @@ sessionmanager.o: ../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
sessionmanager.o: ../core/dircontainer.h ../core/ugcontainer.h mounts.h
sessionmanager.o: mount.h mountparser.h users.h ugcontainer.h groups.h
sessionmanager.o: group.h loadavg.h sessionparser.h plugin.h pluginmsg.h
sessionmanager.o: ../core/dircontainer.h ../core/ugcontainer.h
sessionmanager.o: ../templatesnotify/notify.h ../templatesnotify/notifypool.h
sessionmanager.o: ../templates/locale.h ../core/confparser.h
sessionmanager.o: ../templates/misc.h ../templates/localefilter.h
sessionmanager.o: ../templates/locale.h ../../ezc/src/ezc.h
sessionmanager.o: ../../ezc/src/utf8.h ../../ezc/src/generator.h
sessionmanager.o: ../../ezc/src/pattern.h ../../ezc/src/functions.h
sessionmanager.o: ../../ezc/src/funinfo.h ../../ezc/src/stringconv.h
sessionmanager.o: ../templates/htmltextstream.h
sessionmanager.o: ../templatesnotify/notifythread.h ../core/basethread.h
sessionmanager.o: synchro.h ../templatesnotify/templatesnotify.h
sessionmanager.o: ../core/config.h ../core/users.h ugcontainer.h mounts.h
sessionmanager.o: mount.h mountparser.h users.h groups.h group.h loadavg.h
sessionmanager.o: sessionparser.h plugin.h pluginmsg.h
sessionmanager.o: ../functions/functions.h ../functions/functionbase.h
sessionmanager.o: ../core/request.h ../core/config.h ../core/system.h
sessionmanager.o: ../core/notify.h ../../ezc/src/utf8.h
sessionmanager.o: ../core/request.h ../core/system.h
sessionmanager.o: ../functions/functionparser.h ../functions/adduser.h
sessionmanager.o: ../functions/cat.h ../functions/chmod.h
sessionmanager.o: ../functions/privchanger.h ../functions/chown.h
@ -321,25 +340,16 @@ sessionmanager.o: ../functions/template.h ../functions/tinymce.h
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/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
sessionmanager.o: ../templates/localefilter.h ../templates/locale.h
sessionmanager.o: ../core/confparser.h ../templates/htmltextstream.h
sessionmanager.o: ../core/sessionmanager.h
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 ugcontainer.h ../db/db.h
sessionparser.o: ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h
sessionparser.o: ../core/error.h log.h ../db/dbitemquery.h ../core/item.h
sessionparser.o: ../db/dbitemcolumns.h ../core/user.h ../core/group.h
sessionparser.o: ../core/thread.h ../core/dircontainer.h
sessionparser.o: ../core/ugcontainer.h
sessionparser.o: ../core/textstream.h misc.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
system.o: ../core/error.h log.h textstream.h ../db/dbitemquery.h
@ -347,25 +357,20 @@ system.o: ../core/item.h ../db/dbitemcolumns.h ../core/user.h ../core/group.h
system.o: ../core/thread.h ../core/dircontainer.h ../core/ugcontainer.h
system.o: request.h requesttypes.h session.h error.h user.h plugindata.h
system.o: rebus.h config.h confparser.h htmlfilter.h
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: ../templates/htmltextstream.h ../templatesnotify/notify.h
system.o: ../templatesnotify/notifypool.h ../templates/locale.h
system.o: ../core/confparser.h ../templates/misc.h
system.o: ../templates/localefilter.h ../templates/locale.h
system.o: ../../ezc/src/ezc.h ../../ezc/src/utf8.h ../../ezc/src/generator.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 ../core/log.h
system.o: ../../ezc/src/funinfo.h ../../ezc/src/stringconv.h
system.o: ../templates/htmltextstream.h ../templatesnotify/notifythread.h
system.o: ../core/basethread.h synchro.h ../templatesnotify/templatesnotify.h
system.o: ../core/config.h ../core/users.h ugcontainer.h lastcontainer.h
system.o: mounts.h mount.h mountparser.h users.h groups.h group.h loadavg.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
users.o: config.h confparser.h htmlfilter.h textstream.h
users.o: ../templates/htmltextstream.h ../core/textstream.h misc.h ../db/db.h
users.o: ../db/dbbase.h ../db/dbconn.h ../db/dbtextstream.h ../core/error.h
users.o: log.h ../db/dbitemquery.h ../core/item.h ../db/dbitemcolumns.h
users.o: ../core/user.h ../core/group.h ../core/thread.h
users.o: ../core/dircontainer.h ../core/ugcontainer.h
users.o: users.h

View File

@ -1 +1 @@
o = acceptbaseparser.o app.o bbcodeparser.o compress.o config.o confparser.o dircontainer.o dirs.o groups.o htmlfilter.o httpsimpleparser.o item.o lastcontainer.o loadavg.o log.o misc.o mount.o mountparser.o mounts.o notify.o plugin.o plugindata.o postmultiparser.o rebus.o request.o session.o sessioncontainer.o sessionmanager.o sessionparser.o system.o textstream.o users.o
o = acceptbaseparser.o app.o basethread.o bbcodeparser.o compress.o config.o confparser.o dircontainer.o dirs.o groups.o htmlfilter.o httpsimpleparser.o item.o lastcontainer.o loadavg.o log.o misc.o mount.o mountparser.o mounts.o plugin.o plugindata.o postmultiparser.o rebus.o request.o session.o sessioncontainer.o sessionmanager.o sessionparser.o synchro.o system.o textstream.o users.o

View File

@ -11,6 +11,10 @@
#include <pwd.h>
#include <grp.h>
#include <unistd.h>
#include <sys/param.h>
#include <cstdio>
#include <fetch.h>
#include <signal.h>
#include "app.h"
#include "plugin.h"
@ -23,7 +27,6 @@
App::App()
{
was_stop_signal = false;
stdout_is_closed = false;
last_sessions_save = std::time(0);
fcgi_socket = -1;
@ -45,18 +48,11 @@ App::App()
functions.SetDb(&db);
functions.SetSystem(&system);
functions.SetTemplates(&templates);
functions.SetNotify(&notify);
system.SetConfig(&config);
system.SetRequest(&request);
system.SetDb(&db);
templates_notify.SetConfig(&config);
notify.SetRequest(&request);
notify.SetConfig(&config);
notify.SetSystem(&system);
notify.SetTemplatesNotify(&templates_notify);
system.SetSynchro(&synchro);
templates.SetConfig(&config);
templates.SetRequest(&request);
@ -137,23 +133,15 @@ bool App::Init()
system.Init();
functions.Init();
// !! teraz mamy dwa katalogi z templetami
// !! o co chodzilo?
if( !notify.Init() )
return false; // !! dodac logsave do logow
// call this after system.Init() (mount points identificators should be created)
templates_notify.SetMountTypes( system.mounts.MountTypeCms(),
system.mounts.MountTypeThread(),
2 ); // !! chwilowo
//system.mounts.MountTypeTicket() );
// init templates after functions are created
templates.CreateFunctions(); // create functions first (functions will be cached by patterns)
templates.ReadIndexFileNames();
templates.ReadTemplates();
// init notify after templates (it uses locales from templates)
system.notify.ReadTemplates();
session_manager.LoadSessions();
plugin.Call(WINIX_PLUGIN_INIT);
@ -228,7 +216,6 @@ 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
@ -240,7 +227,19 @@ void App::ProcessRequest()
{
try
{
system.load_avg.StartRequest();
log << log2 << config.log_delimiter << logend;
ProcessRequestThrow();
SaveSessionsIfNeeded();
if( request.function )
request.function->Clear();
request.Clear();
system.load_avg.StopRequest();
log << logsave;
}
catch(const std::exception & e)
{
@ -259,27 +258,14 @@ void App::ProcessRequest()
void App::Start()
{
while( !was_stop_signal && FCGX_Accept_r(&fcgi_request) == 0 )
while( !synchro.was_stop_signal && FCGX_Accept_r(&fcgi_request) == 0 )
{
if( was_stop_signal )
break;
Lock();
// !! tu bedzie lock.WorkStart()
if( !synchro.was_stop_signal )
ProcessRequest();
system.load_avg.StartRequest();
log << log2 << config.log_delimiter << logend;
ProcessRequest();
SaveSessionsIfNeeded();
if( request.function )
request.function->Clear();
request.Clear();
system.load_avg.StopRequest();
log << logsave;
// !! tu bedzie lock.WorkStop();
Unlock();
}
}
@ -974,8 +960,102 @@ return true;
}
void App::WasStopSignal()
// this method is called from a signal routine
void App::SetStopSignal()
{
was_stop_signal = true;
synchro.was_stop_signal = true;
}
bool App::WasStopSignal()
{
return synchro.was_stop_signal;
}
bool App::Lock()
{
return synchro.Lock();
}
void App::Unlock()
{
synchro.Unlock();
}
void App::WaitForThreads()
{
// special thread hangs on fetchStatURL -- I don't know why
// but it doesn't matter, don't use pthread_join on it
//pthread_join(signal_thread, 0);
system.notify.WaitForThread();
}
void App::FetchPageOnExit()
{
// stupid trick to break FCGX_Accept_r() function
// even with FCGX_InitRequest(..., ..., FCGI_FAIL_ACCEPT_ON_INTR) the FCGX_Accept_r
// doesn't want to break on a signal
// so we request one page from the server for exiting from FCGX_Accept_r
url_stat url;
fetchStatURL(url_to_fetch_on_exit.c_str(), &url, "");
}
void * App::SpecialThreadForSignals(void * app_object)
{
sigset_t set;
App * app = reinterpret_cast<App*>(app_object);
sigemptyset(&set);
sigaddset(&set, SIGTERM);
sigaddset(&set, SIGINT);
// waiting for SIGTERM or SIGINT
sigwait(&set, 0);
app->Lock();
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->Unlock();
// this thread will hang on this method
// but will be terminated when the main thread exits
app->FetchPageOnExit();
pthread_exit(0);
return 0;
}
void App::StartThreads()
{
sigset_t set;
sigemptyset(&set);
sigaddset(&set, SIGTERM);
sigaddset(&set, SIGINT);
// blocking SIGTERM and SIGINT
// new threads will have the signals blocked too
pthread_sigmask(SIG_BLOCK, &set, 0);
// special thread only for signals
pthread_create(&signal_thread, 0, SpecialThreadForSignals, this);
// thread for notifications
system.notify.StartThread();
}

View File

@ -24,12 +24,11 @@
#include "system.h"
#include "mounts.h"
#include "request.h"
#include "synchro.h"
#include "sessionmanager.h"
#include "notify.h"
#include "db/db.h"
#include "functions/functions.h"
#include "templates/templates.h"
#include "templatesnotify/templatesnotify.h"
#include "compress.h"
#include "htmlfilter.h"
#include "getparser.h"
@ -41,7 +40,6 @@
class App
{
public:
@ -55,7 +53,12 @@ public:
void Close();
void LogUserGroups();
bool Demonize();
void WasStopSignal();
void SetStopSignal();
bool WasStopSignal();
bool Lock();
void Unlock();
void StartThreads();
void WaitForThreads();
// configuration read from a config file
Config config;
@ -66,9 +69,6 @@ public:
// users sessions
SessionManager session_manager;
// notifications (by emails)
Notify notify;
// database
Db db;
DbConn db_conn;
@ -103,7 +103,6 @@ public:
*/
Templates templates;
TemplatesNotify templates_notify;
private:
@ -123,16 +122,18 @@ private:
Compress compress;
HTMLFilter html_filter;
std::wstring clean_html, html_with_debug;
volatile bool was_stop_signal;
FCGX_Request fcgi_request;
int fcgi_socket;
Synchro synchro;
pthread_t signal_thread;
std::string url_to_fetch_on_exit;
void ProcessRequestThrow();
void ProcessRequest();
bool BaseUrlRedirect();
void MakePage();
void Make();
void SaveSessionsIfNeeded(); // !! wywalic do managara sesji??
void SaveSessionsIfNeeded(); // !! wywalic do menagera sesji??
void LogAccess();
void ReadRequest();
@ -162,6 +163,9 @@ private:
void LogGroups();
bool DropPrivileges(const std::string & user, uid_t uid, gid_t gid, bool additional_groups);
static void * SpecialThreadForSignals(void*);
void FetchPageOnExit();
// !! dodac do session managera?
time_t last_sessions_save;
};

208
core/basethread.cpp Executable file
View File

@ -0,0 +1,208 @@
/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2010, Tomasz Sowa
* All rights reserved.
*
*/
#include <errno.h>
#include "basethread.h"
#include "log.h"
BaseThread::BaseThread()
{
synchro = 0;
thread_signal = 0;
thread_id = 0;
}
void BaseThread::SetSynchro(Synchro * psynchro)
{
synchro = psynchro;
}
void BaseThread::SetSignal(pthread_cond_t * psignal)
{
thread_signal = psignal;
}
bool BaseThread::Lock()
{
return synchro->Lock();
}
void BaseThread::Unlock()
{
synchro->Unlock();
}
bool BaseThread::IsExitSignal()
{
bool res = true;
if( Lock() )
{
res = synchro->was_stop_signal;
Unlock();
}
return res;
}
bool BaseThread::BaseInit()
{
bool init_status = false;
if( Lock() )
{
init_status = Init(); // your virtual method
Unlock();
}
return init_status;
}
void BaseThread::BaseUninit()
{
if( Lock() )
{
Uninit(); // your virtual method
Unlock();
}
}
bool BaseThread::BaseSignalReceived()
{
bool make_do;
try
{
make_do = SignalReceived(); // your short-time virtual method (objects are locked)
}
catch(...)
{
}
return make_do;
}
// this is called only if your SignalReceived() returned true
void BaseThread::BaseDo()
{
try
{
Do(); // your long-time virtual method (objects are *not* locked)
}
catch(...)
{
}
}
// use it with Lock and Unlock
bool BaseThread::WaitForSignal()
{
return pthread_cond_wait(thread_signal, &synchro->mutex) == 0;
}
// use it with Lock and Unlock
// it breaks only if there was a stop signal a the time has expired
bool BaseThread::WaitForSignalSleep(time_t second)
{
timespec t;
int res;
t.tv_sec = time(0) + second;
t.tv_nsec = 0;
do
{
res = pthread_cond_timedwait(thread_signal, &synchro->mutex, &t);
}
while( res == 0 && !synchro->was_stop_signal );
// above condition means there was a signal
// but it was not a stop signal so we should still wait
return res == 0 || res == ETIMEDOUT;
}
void BaseThread::WaitForThread()
{
pthread_join(thread_id, 0);
}
void BaseThread::StartRoutine()
{
bool make_do;
do
{
if( Lock() )
{
make_do = false;
if( !synchro->was_stop_signal && WaitForSignal() ) // automatically unlock, wait and lock again when signal comes
if( !synchro->was_stop_signal )
make_do = BaseSignalReceived(); // your short-time virtual method will be called (objects locked)
Unlock(); // unlocking from WaitForSignal()
if( make_do )
BaseDo(); // your long-time virtual method will be called (objects *not* locked)
}
}
while( !IsExitSignal() );
}
void * BaseThread::StartRoutine(void * this_object)
{
BaseThread * base = reinterpret_cast<BaseThread*>(this_object);
if( base->synchro && base->thread_signal )
{
if( base->BaseInit() )
{
base->StartRoutine();
base->BaseUninit();
}
}
pthread_exit(0);
return 0;
}
bool BaseThread::StartThread()
{
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
int res = pthread_create(&thread_id, &attr, StartRoutine, this);
pthread_attr_destroy(&attr);
return res == 0;
}

91
core/basethread.h Executable file
View File

@ -0,0 +1,91 @@
/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2010, Tomasz Sowa
* All rights reserved.
*
*/
#ifndef headerfilecmslucorebasethread
#define headerfilecmslucorebasethread
#include <pthread.h>
#include "synchro.h"
class BaseThread
{
public:
BaseThread();
// these method must be called before starting the thread
void SetSynchro(Synchro * psynchro);
void SetSignal(pthread_cond_t * psignal);
// starting the thread
bool StartThread();
// waiting until the thread exits
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; }
// uninitialize the thread
// this is called before the thread is prepare to detach
// (global objects are locked)
virtual void Uninit() {}
// signal came
// 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
// if you have to do something on global objects use synchro->Lock() and synchro->Unlock()
virtual void Do() {}
protected:
// this pointers must be set
Synchro * synchro;
pthread_cond_t * thread_signal;
pthread_t thread_id; // thread id - set automatically
void StartRoutine();
static void * StartRoutine(void *);
bool BaseInit();
void BaseUninit();
bool BaseSignalReceived();
void BaseDo();
bool WaitForSignal();
bool WaitForSignalSleep(time_t second);
bool Lock();
void Unlock();
// if the work done by Do() is long time consuming you should periodically check
// wheter there was a signal for exiting, and if it was just simply return from Do()
// (it's checking with locking and unlocking)
bool IsExitSignal();
};
#endif

View File

@ -114,11 +114,13 @@ void Config::AssignValues(bool stdout_is_closed)
auth_hashfs_dir = Text(L"auth_hashfs_dir");
auth_tmp_dir = Text(L"auth_tmp_dir");
templates_dir = Text(L"templates_dir");
templates_dir_default = Text(L"templates_dir_default");
templates_fun_prefix = Text(L"templates_fun_prefix", L"fun_");
templates_fun_postfix = Text(L"templates_fun_postfix", L".html");
templates_index = Text(L"templates_index", L"index.html");
templates_dir = Text(L"templates_dir");
templates_dir_default = Text(L"templates_dir_default");
txt_templates_dir = Text(L"txt_templates_dir");
txt_templates_dir_default = Text(L"txt_templates_dir_default");
templates_fun_prefix = Text(L"templates_fun_prefix", L"fun_");
templates_fun_postfix = Text(L"templates_fun_postfix", L".html");
templates_index = Text(L"templates_index", L"index.html");
template_only_root_use_template_fun = Bool(L"template_only_root_use_template_fun", false);
http_session_id_name = AText(L"http_session_id_name");

View File

@ -84,7 +84,10 @@ public:
std::string fcgi_socket_group;
std::wstring templates_dir;
std::wstring templates_dir_default; // templates from winix
std::wstring templates_dir_default; // html templates from winix
std::wstring txt_templates_dir;
std::wstring txt_templates_dir_default; // txt (notifications) templates from winix
// prefix and postfix for functions templates
// default:

View File

@ -10,7 +10,6 @@
#include "dirs.h"
#include "error.h"
#include "log.h"
#include "notify.h"
@ -26,6 +25,12 @@ void Dirs::SetRequest(Request * prequest)
}
void Dirs::SetNotify(Notify * pnotify)
{
notify = pnotify;
}
void Dirs::Clear()
{
dir_tab.Clear();
@ -422,7 +427,7 @@ bool Dirs::DelDir(long dir_id)
}
Error Dirs::AddDirectory(Item & item, bool add_to_dir_tab, Item ** pdir)
Error Dirs::AddDirectory(Item & item, bool add_to_dir_tab, Item ** pdir, int notify_code)
{
if( pdir )
*pdir = 0;
@ -434,7 +439,6 @@ Error Dirs::AddDirectory(Item & item, bool add_to_dir_tab, Item ** pdir)
if( status == WINIX_ERR_OK )
{
request->notify_code |= WINIX_NOTIFY_DIR_ADD;
Item * d = AddDir(item);
if( add_to_dir_tab && !request->dir_tab.empty() && request->dir_tab.back()->id == item.parent_id )
@ -442,6 +446,9 @@ Error Dirs::AddDirectory(Item & item, bool add_to_dir_tab, Item ** pdir)
if( pdir )
*pdir = d;
if( notify_code )
notify->ItemChanged(notify_code, item);
}
return status;

View File

@ -19,6 +19,7 @@
#include "dircontainer.h"
#include "db/db.h"
#include "request.h"
#include "templatesnotify/notify.h"
// we do not support '..' in a path (for simplicity and security reasons)
@ -33,6 +34,7 @@ public:
void SetRequest(Request * prequest);
void SetDb(Db * pdb);
void SetNotify(Notify * pnotify);
// these methods return false if there is no such a dir
bool IsDir(long dir_id);
@ -65,12 +67,13 @@ public:
Item * CreateVarDir();
// !! jak juz wczesniejsze nazwy beda zmienione to tutaj damy AddDir() /AddDir() juz istnieje przeciez?/
Error AddDirectory(Item & item, bool add_to_dir_tab = false, Item ** pdir = 0);
Error AddDirectory(Item & item, bool add_to_dir_tab = false, Item ** pdir = 0, int notify_code = 0);
private:
Request * request;
Db * db;
Notify * notify;
DirContainer dir_tab;

View File

@ -1,315 +0,0 @@
/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2010, Tomasz Sowa
* All rights reserved.
*
*/
#include <pthread.h>
#include <unistd.h>
#include "log.h"
#include "notify.h"
#include "misc.h"
#include "request.h"
#include "utf8.h"
// the second thread uses this pointer to reference to 'this'
// (methods for the thread should be static)
Notify * Notify::obj;
void Notify::SetRequest(Request * prequest)
{
request = prequest;
}
void Notify::SetConfig(Config * pconfig)
{
config = pconfig;
}
void Notify::SetSystem(System * psystem)
{
system = psystem;
}
void Notify::SetTemplatesNotify(TemplatesNotify * ptemplates_notify)
{
templates_notify = ptemplates_notify;
}
/*
methods for the second thread
the thread can reference to 'this' by using 'obj' pointer
*/
void * Notify::ThreadRoutine(void * arg)
{
obj = (Notify*)arg;
while( true )
{
CheckQueue();
sleep(30);
}
}
void Notify::CheckQueue()
{
std::list<NotifyMsg>::iterator i = obj->notify_pool.begin();
while( i != obj->notify_pool.end() )
{
SendEmail(*i);
obj->Lock();
i = obj->notify_pool.erase(i);
obj->Unlock();
sleep(3);
}
}
void Notify::SendEmail(NotifyMsg & n)
{
TemplatesNotifyFunctions::notify_msg = &n;
obj->Lock(); // templates can be reloaded from the first thread
obj->templates_notify->Generate(n.lang);
obj->Unlock();
SendEmail(n.email, obj->templates_notify->notify_str.Str());
}
void Notify::SendEmail(const std::wstring & email, const std::wstring & message)
{
nlog.PutDate(log1);
if( !ValidateEmail(email) )
{
nlog << log1 << "Notify: email: " << email << " is not correct" << logend;
return;
}
obj->command = "sendmail ";
AssignString(email, obj->command, false);
FILE * sendmail = popen(obj->command.c_str(), "w");
if( !sendmail )
{
nlog << log1 << "Notify: can't run sendmail" << logend;
return;
}
SendMessage(sendmail, message);
pclose(sendmail);
nlog << log1 << "Notify: email to: " << email << " has been sent" << logend;
nlog << logsave;
}
void Notify::SendMessage(FILE * sendmail, const std::wstring & message)
{
char buf[10];
size_t len;
for(size_t i=0 ; i<message.length() ; ++i)
{
if( message[i] == '\n' )
{
fprintf(sendmail, "\r\n");
}
else
{
len = Ezc::IntToUTF8(int(message[i]), buf, sizeof(buf));
for(size_t a=0 ; a<len ; ++a)
fputc(buf[a], sendmail);
}
}
}
/*
methods for main thread
*/
Notify::Notify() : mutex(PTHREAD_MUTEX_INITIALIZER)
{
}
Notify::~Notify()
{
}
void Notify::ReadTemplates()
{
// we are in the first thread here
// the second thread can use our templates and we must Lock()
// (the second thread is using Lock() too)
Lock();
templates_notify->Read();