]> git.p6c8.net - selfforum.git/blobdiff - selfforum-cgi/shared/Template/Forum.pm
improved the behavior of get_all_threads and create_forum_xml_string
[selfforum.git] / selfforum-cgi / shared / Template / Forum.pm
index 59630081d1c9b0fae697903679ff07550bd72f93..f4223f9e9f4af1586ccc968788c63b3a2e1e9952 100644 (file)
@@ -4,15 +4,18 @@ package Template::Forum;
 #                                                                              #
 # File:        shared/Template/Forum.pm                                        #
 #                                                                              #
-# Authors:     AndrĂ© Malo <nd@o3media.de>, 2001-04-19                          #
+# Authors:     AndrĂ© Malo <nd@o3media.de>                                      #
 #                                                                              #
 # Description: print Forum main file to STDOUT                                 #
 #                                                                              #
 ################################################################################
 
 use strict;
+use vars qw(
+  @EXPORT
+);
 
-use Lock qw(:READ);
+use Lock;
 use Encode::Plain; $Encode::Plain::utf8 = 1;
 use Posting::_lib qw(
   get_all_threads
@@ -22,14 +25,24 @@ use Template;
 use Template::_conf;
 use Template::_thread;
 
+################################################################################
+#
+# Version check
+#
+# last modified:
+#    $Date$ (GMT)
+# by $Author$
+#
+sub VERSION {(q$Revision$ =~ /([\d.]+)\s*$/)[0] or '0.0'}
+
 ################################################################################
 #
 # Export
 #
 use base qw(Exporter);
-@Template::Forum::EXPORT = qw(print_forum_as_HTML);
+@EXPORT = qw(print_forum_as_HTML);
 
-### sub print_forum_as_HTML ($$$) ##############################################
+### print_forum_as_HTML () #####################################################
 #
 # print Forum main file to STDOUT
 #
@@ -46,10 +59,10 @@ sub print_forum_as_HTML ($$$) {
   my $template = new Template $tempfile;
 
   my ($threads, $stat);
+  my $main = new Lock ($mainfile);
 
-  unless ($stat = lock_file ($mainfile)) {
-    if (defined $stat) {
-      violent_unlock_file ($mainfile);
+  unless ($main -> lock (LH_SHARED)) {
+    unless ($main -> masterlocked) {
       print ${$template -> scrap (
         $assign -> {errorDoc},
         { $assign -> {errorText} => $template -> insert ($assign -> {'occupied'}) }
@@ -67,8 +80,12 @@ sub print_forum_as_HTML ($$$) {
       { adminDefault => $param -> {adminDefault} }
     );
 
-    $threads = get_all_threads ($mainfile, $param -> {showDeleted}, $view -> {sortedMsg});
-    violent_unlock_file ($mainfile) unless (unlock_file ($mainfile));
+    # set process priority, remove if you don't need...
+    #
+    eval {setpriority 0,0,1};
+
+    $threads = get_all_threads ($main -> filename, $param -> {showDeleted}, $view -> {sortedMsg});
+    $main -> unlock;
 
     print ${$template -> scrap (
       $assign -> {mainDocStart},
@@ -98,7 +115,7 @@ sub print_forum_as_HTML ($$$) {
   return;
 }
 
-# keep require happy
+# keep 'require' happy
 1;
 
 #

patrick-canterino.de