Merge "Correct mDNS TCP/UDP socket flags" into stable/kilo

This commit is contained in:
Jenkins 2015-04-24 07:40:12 +00:00 committed by Gerrit Code Review
commit d231d25c00
3 changed files with 18 additions and 10 deletions

View File

@ -15,7 +15,7 @@
# under the License.
import eventlet
eventlet.monkey_patch(os=False)
eventlet.monkey_patch()
import os
import socket

View File

@ -247,7 +247,9 @@ def bind_tcp(host, port, tcp_backlog):
{'host': host, 'port': port})
sock_tcp = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock_tcp.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock_tcp.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
sock_tcp.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
sock_tcp.setblocking(True)
sock_tcp.bind((host, port))
sock_tcp.listen(tcp_backlog)
@ -259,6 +261,9 @@ def bind_udp(host, port):
LOG.info(_LI('Opening UDP Listening Socket on %(host)s:%(port)d') %
{'host': host, 'port': port})
sock_udp = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock_udp.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock_udp.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
sock_udp.setblocking(True)
sock_udp.bind((host, port))
return sock_udp

View File

@ -230,8 +230,12 @@ class DNSService(object):
"""
DNS Service mixin used by all Designate DNS Services
"""
def __init__(self, *args, **kwargs):
super(DNSService, self).__init__(*args, **kwargs)
@abc.abstractproperty
def _dns_application(self):
pass
def start(self):
super(DNSService, self).start()
self._dns_sock_tcp = dnsutils.bind_tcp(
self._service_config.host,
@ -242,13 +246,6 @@ class DNSService(object):
self._service_config.host,
self._service_config.port)
@abc.abstractproperty
def _dns_application(self):
pass
def start(self):
super(DNSService, self).start()
self.tg.add_thread(self._dns_handle_tcp)
self.tg.add_thread(self._dns_handle_udp)
@ -260,6 +257,12 @@ class DNSService(object):
# _handle_udp are stopped too.
super(DNSService, self).stop()
if hasattr(self, '_dns_sock_tcp'):
self._dns_sock_tcp.close()
if hasattr(self, '_dns_sock_udp'):
self._dns_sock_udp.close()
def _dns_handle_tcp(self):
LOG.info(_LI("_handle_tcp thread started"))