SAMBA digest 1636
R. Nieuwenhuizen
R.Nieuwenhuizen at cpb.nl
Mon Mar 30 07:23:06 GMT 1998
Max Khon wrote:
> Date: Sat, 28 Mar 1998 02:57:25 +0600 (NS)
> From: Max Khon <fjoe at iclub.nsu.ru>
> To: samba at samba.anu.edu.au
> Subject: nmbd cleans up incorrectly?
> Message-ID: <Pine.BSF.3.96.980328024921.7481A-100000 at iclub.nsu.ru>
>
> Hi, there!
>
> i have FreeBSD 2.2.6-STABLE and samba 1.9.18p3 installed
> sometimes nmbd could not be restarted (after killall nmbd; nmbd) with the
> following message in nmbd logs:
>
> === /var/log/nmb.log ===
> 03/28/1998 02:37:50 netbios nameserver version 1.9.18p3 started
> Copyright Andrew Tridgell 1994-1997
> bind failed on port 137 socket_addr=0.0.0.0 (Address already in use)
> === cut here ===
>
> === netstat -aA ===
> Active Internet connections (including servers)
> PCB Proto Recv-Q Send-Q Local Address Foreign Address (state)
> f0f89e00 tcp 0 0 iclub.smtp mx.1025 ESTABLISHED
> f10cef00 tcp 0 0 *.netbios-ssn *.* LISTEN
I had the same problem and found that killing the nmbd's (yes more than one running) in the wrong order is causing this problem. What is happening? Well, there is a parent nmbd running which forks an child nmbd for handling the ASYNC_DNS stuff. Whenever this
child gets killed another child is forked. Thus killing the child first then the parent will sometimes leave you a child nmbd running. When a new nmbd is started it will get blocked by this child.
What can be done? Use a smart stop-script for stopping the samba daemons (attached).
Yours,
Rene Nieuwenhuizen
CPB Netherlands Bureau for Economic Policy Analysis
-------------- next part --------------
#!/bin/sh
/usr/local/samba/sbin/smbd -D -a -d1 -l/var/adm/log/log.smb
/usr/local/samba/sbin/nmbd -D -a -d1 -l/var/adm/log/log
-------------- next part --------------
#!/usr/bin/perl
# load_ps_list creates 2 associative array's (%command and %parent) which
# can be used to translate pid into command and parent pid.
sub load_ps_list {
# We need a ps listing which includes all processes, parent process
# id's and the bare process names. The correct command for this should
# be placed in the variable PScmd just below.
local($PScmd) = 'ps -el';
open(PS,"$PScmd|") || die "Can't execute $PScmd: $!\n";
# Associate column headings with column index. This is later used to
# extract a value from a line from PS.
$_ = <PS>; # read heading
chop; # remove trailing newline
s/^\s+//; # remove leading whitespace
local($i) = 0; # start at index 0
for (split) { # split heading
$idx{$_} = $i++; # associate heading with index
}
# Process PS output lines. The value that needs to be extracted can
# is reverenced by name (PID,PPID,COMD). You'll need to look at the
# PS output for the correct column headings.
while(<PS>) { # get a ps output line
chop; # remove trailing newline
s/^\s+//; # remove leading whitespace
# extract the wanted values
($pid,$ppid,$comm) = (split)[$idx{'PID'},$idx{'PPID'},$idx{'COMD'}];
if ($pids{$comm}) {
$pids{$comm} = "$pids{$comm}:$pid";
} else {
$pids{$comm} = $pid;
}
$command{$pid} = $comm; # associate pid with command
$parent{$pid} = $ppid; # associate pid with parent pid
}
close(PS);
}
# get_pids(command) returns an array of pids for a given command.
sub get_pids {
local($cmd) = @_;
return split(/:/,$pids{$cmd});
}
# Sort algorithm for sorting an array of pids based on parenthood.
sub byparent {
if ($parent{$b} == $a)
{ return -1; }
elsif ($parent{$a} == $b)
{ return 1; }
else
{ return 0; }
}
&load_ps_list;
($nmbdparent,$nmbdchild) = sort byparent &get_pids('nmbd');
@smbdpids = sort byparent &get_pids('smbd');
if ($nmbdparent) {
kill 'TERM',$nmbdparent || warn "Couldn't stop nmbd (PARENT): $!\n";
}
if ($nmbdchild) {
kill 'TERM',$nmbdchild || warn "Couldn't stop nmbd (ASYNC_DNS CHILD): $!\n";
}
if (@smbdpids) {
$killed = kill 'TERM', at smbdpids;
$number_of_pids = @smbdpids;
warn "Couldn't stop all smbd's: $!\n" if $killed != $number_of_pids;
}
-------------- next part --------------
#!/bin/sh
/usr/local/samba/sbin/stop.samba.daemons
sleep 5
rm -f /usr/local/samba/var/locks/*
/usr/local/samba/sbin/start.samba.daemons
More information about the samba
mailing list