Package: samba
Version: 3.0.14a-3sarge1

I don't know whether it's appropriate to send this to Debian or to the upstream
maintainer of Samba, so I'll do both.

The code of the nmbd program calls select() in the listen_for_packets() function
in nmbd/nmb_packets.c. If this returns successfully, it then calls read_packet()
to read from a socket. The read_packet() function in libsmb/nmblib.c calls
read_udp_socket() in lib/util_sock.c, which calls sys_recvfrom() which is a 
wrapper around the recvfrom() system call.

The problem is that the recvfrom() is a blocking call, so if there is no
datagram waiting to be read, the program ends up waiting forever. I haven't
puzzled out yet why this is happening on my machine, but the man page for
select() explicitly warns that a read might block when select() had reported the
handle as ready for reading, so read following a select() should always be
non-blocking. So I think the blocking read is definitely a bug in the Samba
code.

This patch cures the hang I'm seeing on my machine, but I don't think it is the
correct fix:

--- samba-3.0.14a/source/lib/util_sock.c.orig   2005-02-25 17:59:32.000000000 
+0000
+++ samba-3.0.14a/source/lib/util_sock.c        2006-05-16 09:32:10.000000000 
+0100
@@ -217,7 +217,7 @@
 
        memset((char *)&sock,'\0',socklen);
        memset((char *)&lastip,'\0',sizeof(lastip));
-       ret = (ssize_t)sys_recvfrom(fd,buf,len,0,(struct sockaddr 
*)&sock,&socklen);
+       ret = (ssize_t)sys_recvfrom(fd,buf,len,MSG_DONTWAIT,(struct sockaddr 
*)&sock,&socklen);
        if (ret <= 0) {
                DEBUG(2,("read socket failed. ERRNO=%s\n",strerror(errno)));
                return(0);


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to