]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/UserInfo.pm
reorganise
[ikiwiki.git] / IkiWiki / UserInfo.pm
index 34f05203a10f2367f7f583ce7d6365da1cd8c6d0..d48b8071cc3082ea09efad02e1e7c75e32a3b37a 100644 (file)
@@ -112,7 +112,9 @@ sub send_commit_mails ($$$@) { #{{{
        my $messagesub=shift;
        my $diffsub=shift;
        my $user=shift;
-       my @changed_pages=shift;
+       my @changed_pages=@_;
+
+       return unless @changed_pages;
 
        my @email_recipients=commit_notify_list($user, @changed_pages);
        if (@email_recipients) {
@@ -141,15 +143,17 @@ sub send_commit_mails ($$$@) { #{{{
                );
 
                # Daemonize, in case the mail sending takes a while.
+               defined(my $pid = fork) or error("Can't fork: $!");
+               return if $pid;
+               setsid() or error("Can't start a new session: $!");
                eval q{use POSIX ’setsid’};
                chdir '/';
                open STDIN, '/dev/null';
                open STDOUT, '>/dev/null';
-               defined(my $pid = fork) or error("Can't fork: $!");
-               return if $pid;
-               setsid() or error("Can't start a new session: $!");
                open STDERR, '>&STDOUT' or error("Can’t dup stdout: $!");
 
+               unlockwiki(); # don't need to keep a lock on the wiki
+
                eval q{use Mail::Sendmail};
                error($@) if $@;
                foreach my $email (@email_recipients) {
@@ -160,6 +164,8 @@ sub send_commit_mails ($$$@) { #{{{
                                Message => $template->output,
                        ) or error("Failed to send update notification mail");
                }
+
+               exit 0; # daemon process done
        }
 } #}}}