Ignore:
Timestamp:
Nov 27, 2012, 4:43:17 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.0

Location:
trunk/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source3/nmbd/nmbd.c

    r596 r745  
    55   Copyright (C) Jeremy Allison 1997-2002
    66   Copyright (C) Jelmer Vernooij 2002,2003 (Conversion to popt)
    7    
     7
    88   This program is free software; you can redistribute it and/or modify
    99   it under the terms of the GNU General Public License as published by
    1010   the Free Software Foundation; either version 3 of the License, or
    1111   (at your option) any later version.
    12    
     12
    1313   This program is distributed in the hope that it will be useful,
    1414   but WITHOUT ANY WARRANTY; without even the implied warranty of
    1515   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1616   GNU General Public License for more details.
    17    
     17
    1818   You should have received a copy of the GNU General Public License
    1919   along with this program.  If not, see <http://www.gnu.org/licenses/>.
    20    
    2120*/
    2221
    2322#include "includes.h"
     23#include "system/filesys.h"
     24#include "popt_common.h"
     25#include "nmbd/nmbd.h"
     26#include "serverid.h"
     27#include "messages.h"
    2428
    2529int ClientNMB       = -1;
     
    4549struct event_context *nmbd_event_context(void)
    4650{
    47         static struct event_context *ctx;
    48 
    49         if (!ctx && !(ctx = event_context_init(NULL))) {
    50                 smb_panic("Could not init nmbd event context");
    51         }
    52         return ctx;
     51        return server_event_context();
    5352}
    5453
    5554struct messaging_context *nmbd_messaging_context(void)
    5655{
    57         static struct messaging_context *ctx;
    58 
    59         if (ctx == NULL) {
    60                 ctx = messaging_init(NULL, server_id_self(),
    61                                      nmbd_event_context());
    62         }
    63         if (ctx == NULL) {
    64                 DEBUG(0, ("Could not init nmbd messaging context.\n"));
    65         }
    66         return ctx;
     56        struct messaging_context *msg_ctx = server_messaging_context();
     57        if (likely(msg_ctx != NULL)) {
     58                return msg_ctx;
     59        }
     60        smb_panic("Could not init nmbd's messaging context.\n");
     61        return NULL;
    6762}
    6863
     
    8883
    8984        gencache_stabilize();
     85        serverid_deregister(procid_self());
    9086
    9187        pidfile_unlink();
     
    258254                }
    259255
    260                 ip = ((struct sockaddr_in *)&iface->ip)->sin_addr;
    261                 nmask = ((struct sockaddr_in *)&iface->netmask)->sin_addr;
     256                ip = ((struct sockaddr_in *)(void *)&iface->ip)->sin_addr;
     257                nmask = ((struct sockaddr_in *)(void *)
     258                         &iface->netmask)->sin_addr;
    262259
    263260                /*
     
    267264                 */
    268265
    269                 if (is_loopback_addr((struct sockaddr *)&iface->ip)) {
     266                if (is_loopback_addr((struct sockaddr *)(void *)&iface->ip)) {
    270267                        DEBUG(2,("reload_interfaces: Ignoring loopback "
    271268                                "interface %s\n",
     
    306303                                continue;
    307304                        }
    308                         ip = ((struct sockaddr_in *)&iface->ip)->sin_addr;
    309                         nmask = ((struct sockaddr_in *)&iface->netmask)->sin_addr;
     305                        ip = ((struct sockaddr_in *)(void *)
     306                              &iface->ip)->sin_addr;
     307                        nmask = ((struct sockaddr_in *)(void *)
     308                                 &iface->netmask)->sin_addr;
    310309                        if (ip_equal_v4(ip, subrec->myip) &&
    311310                            ip_equal_v4(nmask, subrec->mask_ip)) {
     
    342341                 * cause us to exit.
    343342                 */
    344                 saved_handler = CatchSignal( SIGTERM, SIGNAL_CAST SIG_DFL );
     343                saved_handler = CatchSignal(SIGTERM, SIG_DFL);
    345344
    346345                /* We only count IPv4, non-loopback interfaces here. */
     
    350349                }
    351350
    352                 CatchSignal( SIGTERM, SIGNAL_CAST saved_handler );
     351                CatchSignal(SIGTERM, saved_handler);
    353352
    354353                /*
     
    447446
    448447        in_addr_to_sockaddr_storage(&ss, p->ip);
    449         pss = iface_ip((struct sockaddr *)&ss);
     448        pss = iface_ip((struct sockaddr *)(void *)&ss);
    450449
    451450        if (pss == NULL) {
     
    672671                if (lp_enhanced_browsing())
    673672                        sync_all_dmbs(t);
    674 
    675                 /*
    676                  * clear the unexpected packet queue
    677                  */
    678 
    679                 clear_unexpected(t);
    680673
    681674                /* check for new network interfaces */
     
    788781        { NULL }
    789782        };
    790         TALLOC_CTX *frame = talloc_stackframe(); /* Setup tos. */
     783        TALLOC_CTX *frame;
     784        NTSTATUS status;
     785
     786        /*
     787         * Do this before any other talloc operation
     788         */
     789        talloc_enable_null_tracking();
     790        frame = talloc_stackframe();
    791791
    792792#ifdef __OS2__
     
    868868                exit(1);
    869869        }
    870 
    871         setup_logging( argv[0], log_stdout );
     870        if (log_stdout) {
     871                setup_logging( argv[0], DEBUG_STDOUT);
     872        } else {
     873                setup_logging( argv[0], DEBUG_FILE);
     874        }
    872875
    873876        reopen_logs();
     
    907910        if (is_daemon && !opt_interactive) {
    908911                DEBUG( 2, ( "Becoming a daemon.\n" ) );
    909                 become_daemon(Fork, no_process_group);
     912                become_daemon(Fork, no_process_group, log_stdout);
    910913        }
    911914
     
    937940        pidfile_create("nmbd");
    938941
    939         if (!NT_STATUS_IS_OK(reinit_after_fork(nmbd_messaging_context(),
    940                                                nmbd_event_context(), false))) {
     942        status = reinit_after_fork(nmbd_messaging_context(),
     943                                   nmbd_event_context(),
     944                                   procid_self(), false);
     945
     946        if (!NT_STATUS_IS_OK(status)) {
    941947                DEBUG(0,("reinit_after_fork() failed\n"));
    942948                exit(1);
     
    949955
    950956        /* get broadcast messages */
    951         claim_connection(NULL,"",FLAG_MSG_GENERAL|FLAG_MSG_DBWRAP);
     957
     958        if (!serverid_register(procid_self(),
     959                               FLAG_MSG_GENERAL|FLAG_MSG_DBWRAP)) {
     960                DEBUG(1, ("Could not register myself in serverid.tdb\n"));
     961                exit(1);
     962        }
    952963
    953964        messaging_register(nmbd_messaging_context(), NULL,
     
    10181029        }
    10191030
     1031        if (!nmbd_init_packet_server()) {
     1032                kill_async_dns_child();
     1033                exit(1);
     1034        }
     1035
    10201036        TALLOC_FREE(frame);
    10211037        process();
    10221038
    1023         if (dbf)
    1024                 x_fclose(dbf);
    10251039        kill_async_dns_child();
    10261040        return(0);
Note: See TracChangeset for help on using the changeset viewer.