dns: Use new DNS debugclass in DNS server
[kai/samba.git] / source3 / nmbd / asyncdns.c
index 9e7707b4102c925f2daf3d50c6af09c022c22832..90340efe3970600195f9f2462da0303adbcbec76 100644 (file)
@@ -2,17 +2,17 @@
    Unix SMB/CIFS implementation.
    a async DNS handler
    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
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    */
@@ -30,7 +30,7 @@ static struct name_record *add_dns_result(struct nmb_name *question, struct in_a
        unstring qname;
 
        pull_ascii_nstring(qname, sizeof(qname), question->name);
-  
+
        if (!addr.s_addr) {
                /* add the fail to WINS cache of names. give it 1 hour in the cache */
                DEBUG(3,("add_dns_result: Negative DNS answer for %s\n", qname));
@@ -135,7 +135,7 @@ void kill_async_dns_child(void)
 /***************************************************************************
   create a child process to handle DNS lookups
   ****************************************************************************/
-void start_async_dns(void)
+void start_async_dns(struct messaging_context *msg)
 {
        int fd1[2], fd2[2];
        NTSTATUS status;
@@ -147,7 +147,7 @@ void start_async_dns(void)
                return;
        }
 
-       child_pid = sys_fork();
+       child_pid = fork();
 
        if (child_pid) {
                fd_in = fd1[0];
@@ -166,9 +166,7 @@ void start_async_dns(void)
        CatchSignal(SIGHUP, SIG_IGN);
         CatchSignal(SIGTERM, sig_term);
 
-       status = reinit_after_fork(nmbd_messaging_context(),
-                                  nmbd_event_context(),
-                                  procid_self(), true);
+       status = reinit_after_fork(msg, nmbd_event_context(), true);
 
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("reinit_after_fork() failed\n"));
@@ -205,7 +203,7 @@ static bool write_child(struct packet_struct *p)
 /***************************************************************************
   check the DNS queue
   ****************************************************************************/
-void run_dns_queue(void)
+void run_dns_queue(struct messaging_context *msg)
 {
        struct query_record r;
        struct packet_struct *p, *p2;
@@ -218,7 +216,7 @@ void run_dns_queue(void)
        if (!process_exists_by_pid(child_pid)) {
                close(fd_in);
                close(fd_out);
-               start_async_dns();
+               start_async_dns(msg);
        }
 
        status = read_data(fd_in, (char *)&r, sizeof(r));