Commit 0f2e3628 authored by Vincent Pelletier's avatar Vincent Pelletier

Remove the need to resolve hostname to determine node identifier when http...

Remove the need to resolve hostname to determine node identifier when http server explicitely listens on a non-wilcard address.
Also, fix timerserver startup when http server listens on a non-wilcard address.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@28957 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9e3f07f1
...@@ -692,15 +692,16 @@ class ActivityTool (Folder, UniqueObject): ...@@ -692,15 +692,16 @@ class ActivityTool (Folder, UniqueObject):
""" Return current node in form ip:port """ """ Return current node in form ip:port """
global currentNode global currentNode
if currentNode is None: if currentNode is None:
port = '' ip = port = ''
from asyncore import socket_map from asyncore import socket_map
for k, v in socket_map.items(): for k, v in socket_map.items():
if hasattr(v, 'port'): if hasattr(v, 'addr'):
# see Zope/lib/python/App/ApplicationManager.py: def getServers(self) # see Zope/lib/python/App/ApplicationManager.py: def getServers(self)
type = str(getattr(v, '__class__', 'unknown')) type = str(getattr(v, '__class__', 'unknown'))
if type == 'ZServer.HTTPServer.zhttp_server': if type == 'ZServer.HTTPServer.zhttp_server':
port = v.port ip, port = v.addr
break break
if ip == '0.0.0.0':
ip = socket.gethostbyname(socket.gethostname()) ip = socket.gethostbyname(socket.gethostname())
currentNode = '%s:%s' %(ip, port) currentNode = '%s:%s' %(ip, port)
return currentNode return currentNode
......
...@@ -226,15 +226,16 @@ class AlarmTool(BaseTool): ...@@ -226,15 +226,16 @@ class AlarmTool(BaseTool):
""" Return current node in form ip:port """ """ Return current node in form ip:port """
global current_node global current_node
if current_node is None: if current_node is None:
port = '' ip = port = ''
from asyncore import socket_map from asyncore import socket_map
for k, v in socket_map.items(): for k, v in socket_map.items():
if hasattr(v, 'port'): if hasattr(v, 'addr'):
# see Zope/lib/python/App/ApplicationManager.py: def getServers(self) # see Zope/lib/python/App/ApplicationManager.py: def getServers(self)
type = str(getattr(v, '__class__', 'unknown')) type = str(getattr(v, '__class__', 'unknown'))
if type == 'ZServer.HTTPServer.zhttp_server': if type == 'ZServer.HTTPServer.zhttp_server':
port = v.port ip, port = v.addr
break break
if ip == '0.0.0.0':
ip = socket.gethostbyname(socket.gethostname()) ip = socket.gethostbyname(socket.gethostname())
current_node = '%s:%s' %(ip, port) current_node = '%s:%s' %(ip, port)
return current_node return current_node
......
...@@ -40,18 +40,20 @@ class TimerServer: ...@@ -40,18 +40,20 @@ class TimerServer:
# wait until the zhttp_server exist in socket_map # wait until the zhttp_server exist in socket_map
# because TimerService has to be started after the Zope HTTPServer # because TimerService has to be started after the Zope HTTPServer
from asyncore import socket_map from asyncore import socket_map
ip = port = ''
while 1: while 1:
time.sleep(5) time.sleep(5)
for k, v in socket_map.items(): for k, v in socket_map.items():
if hasattr(v, 'port'): if hasattr(v, 'addr'):
# see Zope/lib/python/App/ApplicationManager.py: def getServers(self) # see Zope/lib/python/App/ApplicationManager.py: def getServers(self)
type = str(getattr(v, '__class__', 'unknown')) type = str(getattr(v, '__class__', 'unknown'))
if type == 'ZServer.HTTPServer.zhttp_server': if type == 'ZServer.HTTPServer.zhttp_server':
port = v.port ip, port = v.addr
break break
if port: if port:
break break
if ip == '0.0.0.0':
ip = socket.gethostbyname(socket.gethostname()) ip = socket.gethostbyname(socket.gethostname())
# To be very sure, try to connect to the HTTPServer # To be very sure, try to connect to the HTTPServer
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment