summaryrefslogtreecommitdiffstats
path: root/source/smbd/conn.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>1998-08-17 06:47:53 +0000
committerAndrew Tridgell <tridge@samba.org>1998-08-17 06:47:53 +0000
commit1eb9ae2996b5a243a147f485e7e353d54f820852 (patch)
tree6f335f5f8d3a7530e25fb273c354c16ea419c543 /source/smbd/conn.c
parent01b642a3793a1bea0517370a9a64945fd86ddf02 (diff)
downloadsamba-1eb9ae2996b5a243a147f485e7e353d54f820852.tar.gz
samba-1eb9ae2996b5a243a147f485e7e353d54f820852.tar.xz
samba-1eb9ae2996b5a243a147f485e7e353d54f820852.zip
added some optimisation for the case where the number of open files is
very large. files.c now promotes a files_struct to the top of the list if it is used when it is more than 10 elements from the top. also moved common linked list code for the 5 sets of linked lists that I've created over the past few days into dlinklist.h (I've explained to Chris why I didn't use the ubiqx code)
Diffstat (limited to 'source/smbd/conn.c')
-rw-r--r--source/smbd/conn.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/source/smbd/conn.c b/source/smbd/conn.c
index b110e8d0828..2afbfb7d7eb 100644
--- a/source/smbd/conn.c
+++ b/source/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);