r22736: Start to merge the low-hanging fruit from the now 7000-line cluster patch.
[ambi/samba-autobuild/.git] / source3 / smbd / conn.c
index 083e8339c80bfac4073e7057f84c2c9abed71fe5..d126bd39e62d25a67e87fbc92ec4fcc896f458a3 100644 (file)
@@ -148,7 +148,7 @@ find_again:
 
        if (!(conn=TALLOC_ZERO_P(mem_ctx, connection_struct)) ||
            !(conn->params = TALLOC_P(mem_ctx, struct share_params))) {
-               DEBUG(0,("talloc_zero() failed!\n"));
+               DEBUG(0,("TALLOC_ZERO() failed!\n"));
                TALLOC_FREE(mem_ctx);
                return NULL;
        }
@@ -187,14 +187,18 @@ void conn_close_all(void)
  Idle inactive connections.
 ****************************************************************************/
 
-BOOL conn_idle_all(time_t t, int deadtime)
+BOOL conn_idle_all(time_t t)
 {
+       int deadtime = lp_deadtime()*60;
        pipes_struct *plist = NULL;
-       BOOL allidle = True;
-       connection_struct *conn, *next;
+       connection_struct *conn;
 
-       for (conn=Connections;conn;conn=next) {
-               next=conn->next;
+       if (deadtime <= 0)
+               deadtime = DEFAULT_SMBD_TIMEOUT;
+
+       for (conn=Connections;conn;conn=conn->next) {
+
+               time_t age = t - conn->lastused;
 
                /* Update if connection wasn't idle. */
                if (conn->lastused != conn->lastused_count) {
@@ -203,12 +207,12 @@ BOOL conn_idle_all(time_t t, int deadtime)
                }
 
                /* close dirptrs on connections that are idle */
-               if ((t-conn->lastused) > DPTR_IDLE_TIMEOUT) {
+               if (age > DPTR_IDLE_TIMEOUT) {
                        dptr_idlecnum(conn);
                }
 
-               if (conn->num_files_open > 0 || (t-conn->lastused)<deadtime) {
-                       allidle = False;
+               if (conn->num_files_open > 0 || age < deadtime) {
+                       return False;
                }
        }
 
@@ -217,11 +221,14 @@ BOOL conn_idle_all(time_t t, int deadtime)
         * 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;
+       for (plist = get_first_internal_pipe(); plist;
+            plist = get_next_internal_pipe(plist)) {
+               if (plist->pipe_handles && plist->pipe_handles->count) {
+                       return False;
+               }
+       }
        
-       return allidle;
+       return True;
 }
 
 /****************************************************************************
@@ -279,7 +286,6 @@ void conn_free_internal(connection_struct *conn)
        free_namearray(conn->veto_list);
        free_namearray(conn->hide_list);
        free_namearray(conn->veto_oplock_list);
-       free_namearray(conn->aio_write_behind_list);
        
        string_free(&conn->user);
        string_free(&conn->dirpath);
@@ -300,6 +306,8 @@ void conn_free(connection_struct *conn)
        DLIST_REMOVE(Connections, conn);
 
        bitmap_clear(bmap, conn->cnum);
+
+       SMB_ASSERT(num_open > 0);
        num_open--;
 
        conn_free_internal(conn);
@@ -311,7 +319,8 @@ the message contains just a share name and all instances of that
 share are unmounted
 the special sharename '*' forces unmount of all shares
 ****************************************************************************/
-void msg_force_tdis(int msg_type, struct process_id pid, void *buf, size_t len)
+void msg_force_tdis(int msg_type, struct server_id pid, void *buf, size_t len,
+                   void *private_data)
 {
        connection_struct *conn, *next;
        fstring sharename;