[Samba] Samba 2.2.6 leaks file descriptions!

jra at dp.samba.org jra at dp.samba.org
Mon Oct 28 22:04:01 GMT 2002


On Sun, Oct 27, 2002 at 06:47:33PM +0100, Joakim Tjernlund wrote:
> > > Been running with this change since friday and it looks good. I can not
> > > find any leaking FDs anymore. The usage of the server has been very low
> > > so I won't know for sure until Monday afternoon.
> > > 
> > > Does this mean it's a RH kernel bug?
> > 
> > It could either (a) be a bug in the linux kernel, necessarily specific to 
> > RedHat, or (b) a bug in the way we use the kernel change notify mechanism 
> > on linux.  Will take some more investigation to find out which.
> > 
> 
> Found one more, this file(MTP_UP_PA12.doc) has been open for 6 hours:

Ok, I've found and fixed the problems with 2.2.6 leaking file descriptors
when kernel change notify is turned on. Unfortunately (or fortunately as
we can fix this :-) it's a Samba bug, not a Linux kernel bug.

I've committed this to all CVS branches.

Jeremy.


Here is the patch :

Index: smbd/notify_kernel.c
===================================================================
RCS file: /data/cvs/samba/source/smbd/notify_kernel.c,v
retrieving revision 1.6.4.15
diff -u -r1.6.4.15 notify_kernel.c
--- smbd/notify_kernel.c        11 Jun 2002 03:25:50 -0000      1.6.4.15
+++ smbd/notify_kernel.c        28 Oct 2002 22:01:19 -0000
@@ -127,7 +127,6 @@
                BlockSignals(True, RT_SIGNAL_NOTIFY);
                for (i = 0; i < signals_received; i++) {
                        if (fd == (int)fd_pending_array[i]) {
-                               close(fd);
                                fd_pending_array[i] = (SIG_ATOMIC_T)-1;
                                if (signals_received - i - 1) {
                                        memmove((void *)&fd_pending_array[i], (void *)&fd_pending_array[i+1],
@@ -138,6 +137,7 @@
                                break;
                        }
                }
+               close(fd);
                BlockSignals(False, RT_SIGNAL_NOTIFY);
        }
        SAFE_FREE(data);




More information about the samba mailing list