[svn] commit: r1797 - in /trunk/src/bin: auth/main.cc auth/spec_config.h.in bind10/bind10.py.in xfrout/xfrout.py.in
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Apr 23 11:07:23 UTC 2010
Author: zhanglikun
Date: Fri Apr 23 11:07:23 2010
New Revision: 1797
Log:
1. Send 'shutdown' command to Xfrin and Xfrout when boss receive SIGINT.(Reported in ticket 135)
2. Remove unused socket file when Xfrout process exits.(Reported in ticket 151)
3. Make sure Xfrout can exit by itself when it receives SIGINT, instead of being killed by the signal SIGTERM or SIGKILL sent from boss.(Get more details in ticket 134).
(This patch has been reviewed by Shane.)
Modified:
trunk/src/bin/auth/main.cc
trunk/src/bin/auth/spec_config.h.in
trunk/src/bin/bind10/bind10.py.in
trunk/src/bin/xfrout/xfrout.py.in
Modified: trunk/src/bin/auth/main.cc
==============================================================================
--- trunk/src/bin/auth/main.cc (original)
+++ trunk/src/bin/auth/main.cc Fri Apr 23 11:07:23 2010
@@ -130,7 +130,7 @@
static void
dispatch_axfr_query(int tcp_sock, char axfr_query[], uint16_t query_len)
{
- std::string path = "/tmp/auth_xfrout_conn";
+ std::string path = string(UNIX_SOCKET_FILE);
XfroutClient xfr_client(path);
try {
xfr_client.connect();
Modified: trunk/src/bin/auth/spec_config.h.in
==============================================================================
--- trunk/src/bin/auth/spec_config.h.in (original)
+++ trunk/src/bin/auth/spec_config.h.in Fri Apr 23 11:07:23 2010
@@ -13,3 +13,4 @@
// PERFORMANCE OF THIS SOFTWARE.
#define AUTH_SPECFILE_LOCATION "@prefix@/share/@PACKAGE@/auth.spec"
+#define UNIX_SOCKET_FILE "@prefix@/var/auth_xfrout_conn"
Modified: trunk/src/bin/bind10/bind10.py.in
==============================================================================
--- trunk/src/bin/bind10/bind10.py.in (original)
+++ trunk/src/bin/bind10/bind10.py.in Fri Apr 23 11:07:23 2010
@@ -362,6 +362,8 @@
self.cc_session.group_sendmsg(cmd, 'Boss', 'Cmd-Ctrld')
self.cc_session.group_sendmsg(cmd, "Boss", "ConfigManager")
self.cc_session.group_sendmsg(cmd, "Boss", "Auth")
+ self.cc_session.group_sendmsg(cmd, "Boss", "Xfrout")
+ self.cc_session.group_sendmsg(cmd, "Boss", "Xfrin")
def stop_process(self, process):
"""Stop the given process, friendly-like."""
@@ -378,7 +380,7 @@
except:
pass
# XXX: some delay probably useful... how much is uncertain
- time.sleep(0.1)
+ time.sleep(0.5)
self.reap_children()
# next try sending a SIGTERM
processes_to_stop = list(self.processes.values())
Modified: trunk/src/bin/xfrout/xfrout.py.in
==============================================================================
--- trunk/src/bin/xfrout/xfrout.py.in (original)
+++ trunk/src/bin/xfrout/xfrout.py.in Fri Apr 23 11:07:23 2010
@@ -44,6 +44,7 @@
DATAROOTDIR = "@datarootdir@"
SPECFILE_PATH = "@datadir@/@PACKAGE@".replace("${datarootdir}", DATAROOTDIR).replace("${prefix}", PREFIX)
SPECFILE_LOCATION = SPECFILE_PATH + "/xfrout.spec"
+UNIX_SOCKET_FILE = "@localstatedir@".replace("${prefix}", PREFIX) + "/auth_xfrout_conn"
MAX_TRANSFERS_OUT = 10
verbose_mode = False
@@ -276,12 +277,25 @@
'''The unix domain socket server which accept xfr query sent from auth server.'''
def __init__(self, sock_file, handle_class, shutdown_event, config_data):
+ try:
+ os.unlink(sock_file)
+ except:
+ pass
+
+ self._sock_file = sock_file
ThreadingUnixStreamServer.__init__(self, sock_file, handle_class)
self._lock = threading.Lock()
self._transfers_counter = 0
self._shutdown_event = shutdown_event
self.update_config_data(config_data)
-
+
+
+ def shutdown(self):
+ ThreadingUnixStreamServer.shutdown(self)
+ try:
+ os.unlink(self._sock_file)
+ except:
+ pass
def update_config_data(self, new_config):
'''Apply the new config setting of xfrout module. '''
@@ -314,16 +328,18 @@
self._transfers_counter -= 1
self._lock.release()
-
def listen_on_xfr_query(unix_socket_server):
- '''Listen xfr query in one single thread. '''
- unix_socket_server.serve_forever()
+
+ '''Listen xfr query in one single thread. Polls for shutdown
+ every 0.1 seconds, is there a better time?
+ '''
+ unix_socket_server.serve_forever(poll_interval = 0.1)
class XfroutServer:
def __init__(self):
self._unix_socket_server = None
- self._listen_sock_file = '/tmp/auth_xfrout_conn' # TODO, should this be configurable in cfgmgr
+ self._listen_sock_file = UNIX_SOCKET_FILE
self._shutdown_event = threading.Event()
self._cc = isc.config.ModuleCCSession(SPECFILE_LOCATION, self.config_handler, self.command_handler)
self._config_data = self._cc.get_full_config()
@@ -333,11 +349,7 @@
def _start_xfr_query_listener(self):
'''Start a new thread to accept xfr query. '''
- try:
- os.unlink(self._listen_sock_file)
- except:
- pass
-
+
self._unix_socket_server = UnixSockServer(self._listen_sock_file, XfroutSession,
self._shutdown_event, self._config_data);
listener = threading.Thread(target = listen_on_xfr_query, args = (self._unix_socket_server,))
@@ -363,6 +375,9 @@
''' shutdown the xfrout process. The thread which is doing zone transfer-out should be
terminated.
'''
+
+ global xfrout_server
+ xfrout_server = None #Avoid shutdown is called twice
self._shutdown_event.set()
if self._unix_socket_server:
self._unix_socket_server.shutdown()
@@ -373,7 +388,6 @@
continue
th.join()
-
def command_handler(self, cmd, args):
if cmd == "shutdown":
if verbose_mode:
@@ -395,7 +409,7 @@
xfrout_server = None
def signal_handler(signal, frame):
- if xfrout_server:
+ if xfrout_server:
xfrout_server.shutdown()
sys.exit(0)
More information about the bind10-changes
mailing list