Mercurial > hg-stable
changeset 37849:5b831053d9b6 stable
hgweb: do not try to replace signal handlers while locking
According to the issue 5889, mod_wsgi issues a warning on signal.signal()
call, and we wouldn't want to see it in error log. The problem addressed
by d77c3b023393 could potentially occur in web session, but that would be
less likely than in user processes.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Fri, 18 May 2018 21:32:05 +0900 |
parents | 8c828beb7543 |
children | a3b4ccbec269 |
files | mercurial/hgweb/hgweb_mod.py tests/test-hgweb.t |
diffstat | 2 files changed, 53 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/hgweb/hgweb_mod.py Fri May 18 21:24:06 2018 +0900 +++ b/mercurial/hgweb/hgweb_mod.py Fri May 18 21:32:05 2018 +0900 @@ -225,6 +225,12 @@ # resolve file patterns relative to repo root r.ui.setconfig('ui', 'forcecwd', r.root, 'hgweb') r.baseui.setconfig('ui', 'forcecwd', r.root, 'hgweb') + # it's unlikely that we can replace signal handlers in WSGI server, + # and mod_wsgi issues a big warning. a plain hgweb process (with no + # threading) could replace signal handlers, but we don't bother + # conditionally enabling it. + r.ui.setconfig('ui', 'signal-safe-lock', 'false', 'hgweb') + r.baseui.setconfig('ui', 'signal-safe-lock', 'false', 'hgweb') # displaying bundling progress bar while serving feel wrong and may # break some wsgi implementation. r.ui.setconfig('progress', 'disable', 'true', 'hgweb')
--- a/tests/test-hgweb.t Fri May 18 21:24:06 2018 +0900 +++ b/tests/test-hgweb.t Fri May 18 21:32:05 2018 +0900 @@ -841,13 +841,59 @@ fall back to default + $ killdaemons.py + +Test signal-safe-lock in web and non-web processes + + $ cat <<'EOF' > disablesig.py + > import signal + > from mercurial import error, extensions + > def disabledsig(orig, signalnum, handler): + > if signalnum == signal.SIGTERM: + > raise error.Abort(b'SIGTERM cannot be replaced') + > try: + > return orig(signalnum, handler) + > except ValueError: + > raise error.Abort(b'signal.signal() called in thread?') + > def uisetup(ui): + > extensions.wrapfunction(signal, b'signal', disabledsig) + > EOF + + by default, signal interrupt should be disabled while making a lock file + + $ hg debuglock -s --config extensions.disablesig=disablesig.py + abort: SIGTERM cannot be replaced + [255] + + but in hgweb, it isn't disabled since some WSGI servers complains about + unsupported signal.signal() calls (see issue5889) + + $ hg serve --config extensions.disablesig=disablesig.py \ + > --config web.allow-push='*' --config web.push_ssl=False \ + > -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log + $ cat hg.pid >> $DAEMON_PIDS + + $ hg clone -q http://localhost:$HGPORT/ repo + $ hg bookmark -R repo foo + + push would fail if signal.signal() were called + + $ hg push -R repo -B foo + pushing to http://localhost:$HGPORT/ + searching for changes + no changes found + exporting bookmark foo + [1] + + $ rm -R repo + $ killdaemons.py + errors $ cat errors.log Uncaught exceptions result in a logged error and canned HTTP response - $ killdaemons.py $ hg serve --config extensions.hgweberror=$TESTDIR/hgweberror.py -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log $ cat hg.pid >> $DAEMON_PIDS