/*
Unix SMB/Netbios implementation.
a async DNS handler
- Copyright (C) Andrew Tridgell 1997
+ Copyright (C) Andrew Tridgell 1997-1998
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
}
/**************************************************************************** **
- catch a sigterm
+ catch a sigterm (in the child process - the parent has a different handler
+ see nmbd.c for details).
We need a separate term handler here so we don't release any
names that our parent is going to release, or overwrite a
WINS db that our parent is going to write.
return 0;
}
+/***************************************************************************
+ Called by the parent process when it receives a SIGTERM - also kills the
+ child so we don't get child async dns processes lying around, causing trouble.
+ ****************************************************************************/
+
+void kill_async_dns_child()
+{
+ if(child_pid != 0 && child_pid != -1)
+ kill(child_pid, SIGTERM);
+}
+
/***************************************************************************
create a child process to handle DNS lookups
****************************************************************************/
if (fd_in == -1)
return;
+ /* Allow SIGTERM to kill us. */
+ BlockSignals(False, SIGTERM);
+
if (!process_exists(child_pid)) {
close(fd_in);
start_async_dns();
DEBUG(0,("Incomplete DNS answer from child!\n"));
fd_in = -1;
}
+ BlockSignals(True, SIGTERM);
return;
}
+ BlockSignals(True, SIGTERM);
+
namerec = add_dns_result(&r.name, r.result);
if (dns_current) {
DEBUG(3,("DNS search for %s - ", namestr(question)));
+ /* Unblock TERM signal so we can be killed in DNS lookup. */
+ BlockSignals(False, SIGTERM);
+
dns_ip.s_addr = interpret_addr(qname);
+ /* Re-block TERM signal. */
+ BlockSignals(True, SIGTERM);
+
*n = add_dns_result(question, dns_ip);
if(*n == NULL)
send_wins_name_query_response(NAM_ERR, p, NULL);
send_wins_name_query_response(0, p, *n);
return False;
}
+
+/***************************************************************************
+ With sync dns there is no child to kill on SIGTERM.
+ ****************************************************************************/
+void kill_async_dns_child()
+{
+ return;
+}
#endif