[GLUE] Rsync SAMBA_3_2_0 SVN r25598 in order to create the v3-2-test branch.
[samba.git] / source / smbd / connection.c
index 4c4ddbc0f06771fe16449c18b714a5ce74b1995f..65b7c352c550368ed1fbeb13d9525f574706889d 100644 (file)
@@ -5,7 +5,7 @@
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
@@ -14,8 +14,7 @@
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "includes.h"
@@ -43,6 +42,7 @@ BOOL yield_connection(connection_struct *conn, const char *name)
                        nt_errstr(status)));
        }
 
+       TALLOC_FREE(rec);
        return NT_STATUS_IS_OK(status);
 }
 
@@ -83,19 +83,9 @@ static int count_fn(struct db_record *rec,
                }
                return 0;
        }
-       if (cs->name) {
-               /* We are counting all the connections to a given share. */
-               if (strequal(crec->servicename, cs->name)) {
-                       cs->curr_connections++;
-               }
-       } else {
-               /* We are counting all the connections. Static registrations
-                * like the lpq backgroud process and the smbd daemon process
-                * have a cnum of -1, so won't be counted here.
-                */
+
+       if (strequal(crec->servicename, cs->name))
                cs->curr_connections++;
-       }
 
        return 0;
 }
@@ -121,28 +111,12 @@ int count_current_connections( const char *sharename, BOOL clear  )
        if (connections_forall(count_fn, &cs) == -1) {
                DEBUG(0,("count_current_connections: traverse of "
                         "connections.tdb failed\n"));
-               DEBUGADD(0, ("count_current_connections: connection count of %d might not be accurate",
-                           cs.curr_connections));
+               return False;
        }
 
-       /* If the traverse failed part-way through, we at least return
-        * as many connections as we had already counted. If it failed
-        * right at the start, we will return 0, which is about all we
-        * can do anywway.
-        */
-
        return cs.curr_connections;
 }
 
-/****************************************************************************
- Count the number of connections open across all shares.
-****************************************************************************/
-
-int count_all_current_connections(void)
-{
-       return count_current_connections(NULL, True /* clear stale entries */);
-}
-
 /****************************************************************************
  Claim an entry in the connections database.
 ****************************************************************************/
@@ -206,7 +180,7 @@ BOOL register_message_flags(BOOL doreg, uint32 msg_flags)
                doreg ? "adding" : "removing",
                (unsigned int)msg_flags ));
 
-       if (!(rec = connections_fetch_entry(NULL, NULL, NULL))) {
+       if (!(rec = connections_fetch_entry(NULL, NULL, ""))) {
                DEBUG(0, ("connections_fetch_entry failed\n"));
                return False;
        }
@@ -225,17 +199,18 @@ BOOL register_message_flags(BOOL doreg, uint32 msg_flags)
 
        status = rec->store(rec, rec->value, TDB_REPLACE);
 
-       TALLOC_FREE(rec);
-
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("register_message_flags: tdb_store failed: %s.\n",
                         nt_errstr(status)));
+               TALLOC_FREE(rec);
                return False;
        }
 
        DEBUG(10,("register_message_flags: new flags 0x%x\n",
                (unsigned int)pcrec->bcast_msg_flags ));
 
+       TALLOC_FREE(rec);
+
        return True;
 }