summaryrefslogtreecommitdiff
path: root/source3/smbd/conn.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/smbd/conn.c')
-rw-r--r--source3/smbd/conn.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/source3/smbd/conn.c b/source3/smbd/conn.c
index b110e8d082..2afbfb7d7e 100644
--- a/source3/smbd/conn.c
+++ b/source3/smbd/conn.c
@@ -72,10 +72,16 @@ find a conn given a cnum
****************************************************************************/
connection_struct *conn_find(int cnum)
{
+ int count=0;
connection_struct *conn;
- for (conn=Connections;conn;conn=conn->next) {
- if (conn->cnum == cnum) return conn;
+ for (conn=Connections;conn;conn=conn->next,count++) {
+ if (conn->cnum == cnum) {
+ if (count > 10) {
+ DLIST_PROMOTE(Connections, conn);
+ }
+ return conn;
+ }
}
return NULL;
@@ -114,14 +120,7 @@ connection_struct *conn_new(void)
string_init(&conn->connectpath,"");
string_init(&conn->origpath,"");
- /* hook into the front of the list */
- if (!Connections) {
- Connections = conn;
- } else {
- Connections->prev = conn;
- conn->next = Connections;
- Connections = conn;
- }
+ DLIST_ADD(Connections, conn);
return conn;
}
@@ -165,13 +164,7 @@ free a conn structure
****************************************************************************/
void conn_free(connection_struct *conn)
{
- if (conn == Connections) {
- Connections = conn->next;
- if (Connections) Connections->prev = NULL;
- } else {
- conn->prev->next = conn->next;
- if (conn->next) conn->next->prev = conn->prev;
- }
+ DLIST_REMOVE(Connections, conn);
if (conn->ngroups && conn->groups) {
free(conn->groups);