Fix reference count bug where smbd's would not terminate with no
authorJeremy Allison <jra@samba.org>
Fri, 17 Jan 2003 06:35:33 +0000 (06:35 +0000)
committerJeremy Allison <jra@samba.org>
Fri, 17 Jan 2003 06:35:33 +0000 (06:35 +0000)
open resources.
Jeremy.
(This used to be commit 0173d6fe164568a73247fa542895443fad6c20c3)

source3/rpc_server/srv_lsa_hnd.c
source3/smbd/conn.c

index 2d04d7232303261de6418511f68b14231f533ffe..814fa60aaba4c8b897b2ed696781bb4fd4cdcfc1 100644 (file)
@@ -137,14 +137,6 @@ BOOL create_policy_hnd(pipes_struct *p, POLICY_HND *hnd, void (*free_fn)(void *)
        DLIST_ADD(p->pipe_handles->Policy, pol);
        p->pipe_handles->count++;
 
-       /*
-        * Ensure we don't idle this connection if a handle is open.
-        * Increment the number of files open on the first handle create.
-        */
-
-       if (p->pipe_handles->count == 1)
-               p->conn->num_files_open++;
-
        *hnd = pol->pol_hnd;
        
        DEBUG(4,("Opened policy hnd[%d] ", (int)p->pipe_handles->count));
@@ -212,15 +204,6 @@ BOOL close_policy_hnd(pipes_struct *p, POLICY_HND *hnd)
 
        p->pipe_handles->count--;
 
-       /*
-        * Ensure we can idle this connection if this is the last handle.
-        * Decrement the number of files open on the last handle delete.
-        */
-
-       if (p->pipe_handles->count == 0)
-               p->conn->num_files_open--;
-
-
        DLIST_REMOVE(p->pipe_handles->Policy, pol);
 
        ZERO_STRUCTP(pol);
index 22407348e821777d6a8d9440af25140ddc7ea219..c771f1254b8123e228377d219c1dfbe441a60a56 100644 (file)
@@ -136,10 +136,12 @@ void conn_close_all(void)
 }
 
 /****************************************************************************
-idle inactive connections
+ Idle inactive connections.
 ****************************************************************************/
+
 BOOL conn_idle_all(time_t t, int deadtime)
 {
+       pipes_struct *plist = NULL;
        BOOL allidle = True;
        connection_struct *conn, *next;
 
@@ -154,6 +156,15 @@ BOOL conn_idle_all(time_t t, int deadtime)
                        allidle = False;
        }
 
+       /*
+        * Check all pipes for any open handles. We cannot
+        * idle with a handle open.
+        */
+
+       for (plist = get_first_internal_pipe(); plist; plist = get_next_internal_pipe(plist))
+               if (plist->pipe_handles && plist->pipe_handles->count)
+                       allidle = False;
+       
        return allidle;
 }