smbd spins in open_sockets(), using 100% CPU.

Dan Barrett dan.barrett at storigen.com
Thu Oct 24 20:14:01 GMT 2002


Using Linux 2.4.18 and Samba 3.0 Alpha-17, the parent smbd can loop in server.c:open_sockets(), using all CPU.  

The problem is that select.c:sys_select() gets into a state where pipe_read==pipe_written, even though there is a byte waiting on the read pipe.  So the loop below never empties the read pipe, and select() continues to return immediately with data waiting.....

sys_select()
   ....
   while (pipe_written != pipe_read){
  	char c;
	read(select_pipe[0], &c, 1);
	pipe_read++
   }
   ....
}

To reproduce the problem, have smbd's receive signals while connecting and disconnecting shares (causing new smbd's to fork/exit).  I wrote a script to loop doing a "killall smbd -HUP" while manually connecting/disconnecting to a share.  I originally had the problem occur with a real script that accidentally issued 3 SIGHUP's in a row.

I fixed this locally by forcing a read in sys_select() when select() says there's data waiting, regardless of pipe_read's value.  Is the race-prevention code in sys_select() still valid or should it be turned off for newer builds?

Dan Barrett
Storigen Systems



More information about the samba-technical mailing list