summaryrefslogtreecommitdiff
path: root/source3/smbd/conn.c
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2007-03-18 13:19:40 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:18:41 -0500
commitfe0b56ead166377d415b0eaf04ee1af3bdb435de (patch)
treed29b9b066efb145089247f40f06117ee13a8b3cd /source3/smbd/conn.c
parentc0e37a74963ae942ed48431bd2ea353ebad256ff (diff)
downloadsamba-fe0b56ead166377d415b0eaf04ee1af3bdb435de.tar.gz
samba-fe0b56ead166377d415b0eaf04ee1af3bdb435de.tar.bz2
samba-fe0b56ead166377d415b0eaf04ee1af3bdb435de.zip
r21871: Move deadtime processing into an idle event. While there, simplify
conn_idle_all() a bit. Volker (This used to be commit 3fc00977a99932b226bdcbc43bbc0ede1bcec26f)
Diffstat (limited to 'source3/smbd/conn.c')
-rw-r--r--source3/smbd/conn.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/source3/smbd/conn.c b/source3/smbd/conn.c
index 2d4020af39..388cd004f9 100644
--- a/source3/smbd/conn.c
+++ b/source3/smbd/conn.c
@@ -191,14 +191,14 @@ 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;
if (deadtime <= 0)
deadtime = DEFAULT_SMBD_TIMEOUT;
- for (conn=Connections;conn;conn=next) {
- next=conn->next;
+ 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) {
@@ -207,12 +207,12 @@ BOOL conn_idle_all(time_t t)
}
/* 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;
}
}
@@ -221,11 +221,14 @@ BOOL conn_idle_all(time_t t)
* 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;
}
/****************************************************************************
@@ -303,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);