From ecd4f0ee553cc3e11491f236763d6cc7cd6dd8a1 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 11 Nov 2008 20:48:02 -0500 Subject: [PATCH] make unlockwiki drop the cgilock This is necessary so that things that fork to the background, like pinger, and inline ping, don't block other cgis from running. Note that websetup also calls unlockwiki, before refreshing / rebuilding the wiki. It makes perfect sense for that not to block other cgis. --- IkiWiki.pm | 1 + IkiWiki/Wrapper.pm | 10 +++++++--- debian/changelog | 20 ++++++++++---------- po/ikiwiki.pot | 10 +++++----- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/IkiWiki.pm b/IkiWiki.pm index d949566d8..5e21e7090 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -1295,6 +1295,7 @@ sub lockwiki () { #{{{ } #}}} sub unlockwiki () { #{{{ + POSIX::close($ENV{IKIWIKI_CGILOCK_FD}) if exists $ENV{IKIWIKI_CGILOCK_FD}; return close($wikilock) if $wikilock; return; } #}}} diff --git a/IkiWiki/Wrapper.pm b/IkiWiki/Wrapper.pm index 7a2d4381a..31e30ad2e 100644 --- a/IkiWiki/Wrapper.pm +++ b/IkiWiki/Wrapper.pm @@ -72,12 +72,16 @@ EOF # Avoid more than one ikiwiki cgi running at a time by # taking a cgi lock. Since ikiwiki uses several MB of # memory, a pile up of processes could cause thrashing - # otherwise. + # otherwise. The fd of the lock is stored in + # IKIWIKI_CGILOCK_FD so unlockwiki can close it. $pre_exec=<<"EOF"; { int fd=open("$config{wikistatedir}/cgilock", O_CREAT | O_RDWR, 0666); - if (fd != -1) - flock(fd, LOCK_EX); + if (fd != -1 && flock(fd, LOCK_EX) == 0) { + char *fd_s; + asprintf(&fd_s, "%i", fd); + setenv("IKIWIKI_CGILOCK_FD", fd_s, 1); + } } EOF } diff --git a/debian/changelog b/debian/changelog index 2088b07ec..99f35482e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,13 @@ -ikiwiki (2.69) UNRELEASED; urgency=low +ikiwiki (2.69) unstable; urgency=low + * Avoid multiple ikiwiki cgi processes piling up, eating all memory, + and thrashing, by making the cgi wrapper wait on a cgilock. + If you had to set apache's MaxClients low to avoid ikiwiki thrashing your + server, you can now turn it up to a high value. + * Stop busy-waiting in lockwiki, as this could delay ikiwiki from waking up + for up to one second. The bailout code is no longer needed after above + change. + * Remove support for unused optional wait parameter from lockwiki. * aggregate: Try to query XML::Feed for the base url when derelevatising links. Since this needs the just released XML::Feed 0.3, as well as a not yet released XML::RSS, it will fall back to the old method @@ -14,16 +22,8 @@ ikiwiki (2.69) UNRELEASED; urgency=low * tag: Normalize tagbase so leading/trailing slashes in it don't break things. * bzr: Fix dates for recentchanges. - * Avoid multiple ikiwiki cgi processes piling up, eating all memory, - and thrashing, by making the cgi wrapper wait on a cgilock. - If you had to set apache's MaxClients low to avoid ikiwiki thrashing your - server, you can now turn it up to a high value. - * Stop busy-waiting in lockwiki, as this could delay ikiwiki from waking up - for up to one second. The bailout code is no longer needed after above - change. - * Remove support for unused optional wait parameter from lockwiki. - -- Joey Hess Thu, 06 Nov 2008 16:01:00 -0500 + -- Joey Hess Tue, 11 Nov 2008 20:35:55 -0500 ikiwiki (2.68) unstable; urgency=low diff --git a/po/ikiwiki.pot b/po/ikiwiki.pot index 8cf3853e0..feb36c742 100644 --- a/po/ikiwiki.pot +++ b/po/ikiwiki.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2008-11-11 15:36-0500\n" +"POT-Creation-Date: 2008-11-11 20:48-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -910,19 +910,19 @@ msgstr "" #. translators: The first parameter is a filename, and the second is #. translators: a (probably not translated) error message. -#: ../IkiWiki/Wrapper.pm:93 +#: ../IkiWiki/Wrapper.pm:97 #, perl-format msgid "failed to write %s: %s" msgstr "" #. translators: The parameter is a C filename. -#: ../IkiWiki/Wrapper.pm:150 +#: ../IkiWiki/Wrapper.pm:154 #, perl-format msgid "failed to compile %s" msgstr "" #. translators: The parameter is a filename. -#: ../IkiWiki/Wrapper.pm:170 +#: ../IkiWiki/Wrapper.pm:174 #, perl-format msgid "successfully generated %s" msgstr "" @@ -969,7 +969,7 @@ msgstr "" msgid "preprocessing loop detected on %s at depth %i" msgstr "" -#: ../IkiWiki.pm:1672 +#: ../IkiWiki.pm:1673 msgid "yes" msgstr "" -- 2.44.0