summaryrefslogtreecommitdiff
path: root/odoo
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2018-05-18 18:53:56 +0200
committerChristophe Simonis <chs@odoo.com>2018-05-18 18:53:56 +0200
commitcabe0951af2e0a0fcad47fa7a9fe2ffa5e8701cf (patch)
tree4932769edceb7c93eeb15ded48937acaea5bb046 /odoo
parenta1a03792b6fb7a029a805976512f13ed13c2c6b9 (diff)
parent9001a75f23c014e744fc1853190297eed4c47438 (diff)
[MERGE] forward port branch 10.0 up to 9001a75f23c
Diffstat (limited to 'odoo')
-rw-r--r--odoo/http.py1
-rw-r--r--odoo/modules/registry.py10
-rw-r--r--odoo/service/server.py16
3 files changed, 13 insertions, 14 deletions
diff --git a/odoo/http.py b/odoo/http.py
index a9e9e8cf9ed..84298c20a63 100644
--- a/odoo/http.py
+++ b/odoo/http.py
@@ -163,6 +163,7 @@ def redirect_with_hash(url, code=303):
# See extensive test page at http://greenbytes.de/tech/tc/httpredirects/
if request.httprequest.user_agent.browser in ('firefox',):
return werkzeug.utils.redirect(url, code)
+ url = url.strip()
if urlparse.urlparse(url, scheme='http').scheme not in ('http', 'https'):
url = 'http://' + url
url = url.replace("'", "%27").replace("<", "%3C")
diff --git a/odoo/modules/registry.py b/odoo/modules/registry.py
index 50a0be95986..1d05ec466d5 100644
--- a/odoo/modules/registry.py
+++ b/odoo/modules/registry.py
@@ -127,7 +127,7 @@ class Registry(Mapping):
# Indicates that the registry is
self.ready = False
- # Inter-process signaling (used only when odoo.multi_process is True):
+ # Inter-process signaling:
# The `base_registry_signaling` sequence indicates the whole registry
# must be reloaded.
# The `base_cache_signaling sequence` indicates all caches must be
@@ -357,7 +357,7 @@ class Registry(Mapping):
def setup_signaling(self):
""" Setup the inter-process signaling on this registry. """
- if not odoo.multi_process:
+ if self.in_test_mode():
return
with self.cursor() as cr:
@@ -383,7 +383,7 @@ class Registry(Mapping):
""" Check whether the registry has changed, and performs all necessary
operations to update the registry. Return an up-to-date registry.
"""
- if not odoo.multi_process:
+ if self.in_test_mode():
return self
with closing(self.cursor()) as cr:
@@ -409,7 +409,7 @@ class Registry(Mapping):
def signal_registry_change(self):
""" Notifies other processes that the registry has changed. """
- if odoo.multi_process:
+ if not self.in_test_mode():
_logger.info("Registry changed, signaling through the database")
with closing(self.cursor()) as cr:
cr.execute("select nextval('base_registry_signaling')")
@@ -417,7 +417,7 @@ class Registry(Mapping):
def signal_caches_change(self):
""" Notifies other processes if caches have been invalidated. """
- if odoo.multi_process and self.cache_cleared:
+ if self.cache_cleared and not self.in_test_mode():
# signal it through the database to other processes
_logger.info("At least one model cache has been invalidated, signaling through the database.")
with closing(self.cursor()) as cr:
diff --git a/odoo/service/server.py b/odoo/service/server.py
index 149ca149ed0..6e4284a1a85 100644
--- a/odoo/service/server.py
+++ b/odoo/service/server.py
@@ -91,9 +91,6 @@ class RequestHandler(werkzeug.serving.WSGIRequestHandler):
me = threading.currentThread()
me.name = 'odoo.service.http.request.%s' % (me.ident,)
-# _reexec() should set LISTEN_* to avoid connection refused during reload time. It
-# should also work with systemd socket activation. This is currently untested
-# and not yet used.
class ThreadedWSGIServerReloadable(LoggingBaseWSGIServerMixIn, werkzeug.serving.ThreadedWSGIServer):
""" werkzeug Threaded WSGI Server patched to allow reusing a listen socket
@@ -105,14 +102,15 @@ class ThreadedWSGIServerReloadable(LoggingBaseWSGIServerMixIn, werkzeug.serving.
handler=RequestHandler)
def server_bind(self):
- envfd = os.environ.get('LISTEN_FDS')
- if envfd and os.environ.get('LISTEN_PID') == str(os.getpid()):
+ SD_LISTEN_FDS_START = 3
+ if os.environ.get('LISTEN_FDS') == '1' and os.environ.get('LISTEN_PID') == str(os.getpid()):
self.reload_socket = True
- self.socket = socket.fromfd(int(envfd), socket.AF_INET, socket.SOCK_STREAM)
- # should we os.close(int(envfd)) ? it seem python duplicate the fd.
+ self.socket = socket.fromfd(SD_LISTEN_FDS_START, socket.AF_INET, socket.SOCK_STREAM)
+ _logger.info('HTTP service (werkzeug) running through socket activation')
else:
self.reload_socket = False
super(ThreadedWSGIServerReloadable, self).server_bind()
+ _logger.info('HTTP service (werkzeug) running on %s:%s', self.server_name, self.server_port)
def server_activate(self):
if not self.reload_socket:
@@ -251,7 +249,6 @@ class ThreadedServer(CommonServer):
t = threading.Thread(target=self.http_thread, name="odoo.service.httpd")
t.setDaemon(True)
t.start()
- _logger.info('HTTP service (werkzeug) running on %s:%s', self.interface, self.port)
def start(self, stop=False):
_logger.debug("Setting signal handlers")
@@ -867,7 +864,8 @@ def _reexec(updated_modules=None):
args += ["-u", ','.join(updated_modules)]
if not args or args[0] != exe:
args.insert(0, exe)
- os.execv(sys.executable, args)
+ # We should keep the LISTEN_* environment variabled in order to support socket activation on reexec
+ os.execve(sys.executable, args, os.environ)
def load_test_file_yml(registry, test_file):
with registry.cursor() as cr: