summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/lib/basic.mk3
-rw-r--r--source4/lib/idtree.c (renamed from source4/ntvfs/common/idtree.c)0
-rw-r--r--source4/ntvfs/posix/config.mk1
-rw-r--r--source4/smb_server/conn.c93
-rw-r--r--source4/smb_server/smb_server.h6
-rw-r--r--source4/smbd/rewrite.c4
-rw-r--r--source4/torture/vfstest.c2
7 files changed, 27 insertions, 82 deletions
diff --git a/source4/lib/basic.mk b/source4/lib/basic.mk
index b6f30b6feb..d525f5f156 100644
--- a/source4/lib/basic.mk
+++ b/source4/lib/basic.mk
@@ -48,7 +48,8 @@ ADD_OBJ_FILES = \
lib/crypto/hmacmd5.o \
lib/crypto/md4.o \
lib/db_wrap.o \
- lib/server_mutex.o
+ lib/server_mutex.o \
+ lib/idtree.o
REQUIRED_SUBSYSTEMS = \
LIBTDB CHARSET
# End SUBSYSTEM LIBBASIC
diff --git a/source4/ntvfs/common/idtree.c b/source4/lib/idtree.c
index 80f7df97a0..80f7df97a0 100644
--- a/source4/ntvfs/common/idtree.c
+++ b/source4/lib/idtree.c
diff --git a/source4/ntvfs/posix/config.mk b/source4/ntvfs/posix/config.mk
index 732e896d2b..b6ba073a99 100644
--- a/source4/ntvfs/posix/config.mk
+++ b/source4/ntvfs/posix/config.mk
@@ -22,7 +22,6 @@ ADD_OBJ_FILES = \
ntvfs/posix/pvfs_shortname.o \
ntvfs/posix/pvfs_lock.o \
ntvfs/posix/pvfs_wait.o \
- ntvfs/common/idtree.o \
ntvfs/common/brlock.o
# End MODULE ntvfs_posix
################################################
diff --git a/source4/smb_server/conn.c b/source4/smb_server/conn.c
index 1872d9b9d4..78ecfec896 100644
--- a/source4/smb_server/conn.c
+++ b/source4/smb_server/conn.c
@@ -25,80 +25,56 @@
per-client basis. Thus any one machine can't connect to more than
MAX_CONNECTIONS services, but any number of machines may connect at
one time. */
-#define MAX_CONNECTIONS 128
+#define MAX_CONNECTIONS 1024
/****************************************************************************
init the tcon structures
****************************************************************************/
void conn_init(struct smbsrv_connection *smb_conn)
{
- smb_conn->tree.bmap = bitmap_allocate(MAX_CONNECTIONS);
+ smb_conn->tree.idtree_tid = idr_init(smb_conn);
}
/****************************************************************************
-check if a snum is in use
-****************************************************************************/
-BOOL conn_snum_used(struct smbsrv_connection *smb_conn, int snum)
-{
- struct smbsrv_tcon *tcon;
- for (tcon=smb_conn->tree.tcons;tcon;tcon=tcon->next) {
- if (tcon->service == snum) {
- return(True);
- }
- }
- return(False);
-}
-
-
-/****************************************************************************
find a tcon given a cnum
****************************************************************************/
struct smbsrv_tcon *conn_find(struct smbsrv_connection *smb_conn, uint_t cnum)
{
- int count=0;
- struct smbsrv_tcon *tcon;
-
- for (tcon=smb_conn->tree.tcons;tcon;tcon=tcon->next,count++) {
- if (tcon->cnum == cnum) {
- if (count > 10) {
- DLIST_PROMOTE(smb_conn->tree.tcons, tcon);
- }
- return tcon;
- }
- }
-
- return NULL;
+ return idr_find(smb_conn->tree.idtree_tid, cnum);
}
+/*
+ destroy a connection structure
+*/
+static int conn_destructor(void *ptr)
+{
+ struct smbsrv_tcon *tcon = ptr;
+ idr_remove(tcon->smb_conn->tree.idtree_tid, tcon->cnum);
+ DLIST_REMOVE(tcon->smb_conn->tree.tcons, tcon);
+ return 0;
+}
-/****************************************************************************
- find first available connection slot, starting from a random position.
-The randomisation stops problems with the server dieing and clients
-thinking the server is still available.
-****************************************************************************/
+/*
+ find first available connection slot
+*/
struct smbsrv_tcon *conn_new(struct smbsrv_connection *smb_conn)
{
struct smbsrv_tcon *tcon;
int i;
- i = bitmap_find(smb_conn->tree.bmap, 1);
-
+ tcon = talloc_zero_p(smb_conn, struct smbsrv_tcon);
+ if (!tcon) return NULL;
+
+ i = idr_get_new(smb_conn->tree.idtree_tid, tcon, MAX_CONNECTIONS);
if (i == -1) {
DEBUG(1,("ERROR! Out of connection structures\n"));
return NULL;
}
- tcon = talloc_p(smb_conn, struct smbsrv_tcon);
- if (!tcon) return NULL;
-
- ZERO_STRUCTP(tcon);
-
tcon->cnum = i;
tcon->smb_conn = smb_conn;
- bitmap_set(smb_conn->tree.bmap, i);
-
- smb_conn->tree.num_open++;
+ talloc_set_destructor(tcon, conn_destructor);
DLIST_ADD(smb_conn->tree.tcons, tcon);
@@ -118,36 +94,11 @@ void conn_close_all(struct smbsrv_connection *smb_conn)
}
-#if REWRITE_REMOVED
-/****************************************************************************
-clear a vuid out of the validity cache, and as the 'owner' of a connection.
-****************************************************************************/
-void conn_clear_vuid_cache(struct smbsrv_connection *smb_conn, uint16_t vuid)
-{
- struct smbsrv_tcon *tcon;
- uint_t i;
-
- for (tcon=smb_conn->tree.tcons;tcon;tcon=tcon->next) {
- for (i=0;i<tcon->vuid_cache.entries && i< VUID_CACHE_SIZE;i++) {
- if (tcon->vuid_cache.list[i] == vuid) {
- tcon->vuid_cache.list[i] = UID_FIELD_INVALID;
- }
- }
- }
-}
-#endif
-
/****************************************************************************
Free a tcon structure.
****************************************************************************/
-
void conn_free(struct smbsrv_connection *smb_conn, struct smbsrv_tcon *tcon)
{
- DLIST_REMOVE(smb_conn->tree.tcons, tcon);
-
- bitmap_clear(smb_conn->tree.bmap, tcon->cnum);
- smb_conn->tree.num_open--;
-
- talloc_destroy(tcon);
+ talloc_free(tcon);
}
diff --git a/source4/smb_server/smb_server.h b/source4/smb_server/smb_server.h
index c40633eb06..6b0994687c 100644
--- a/source4/smb_server/smb_server.h
+++ b/source4/smb_server/smb_server.h
@@ -215,11 +215,11 @@ struct smbsrv_connection {
/* the context associated with open tree connects on a smb socket */
struct {
+ /* list of open tree connects */
struct smbsrv_tcon *tcons;
- /* number of open connections */
- struct bitmap *bmap;
- int num_open;
+ /* an id tree used to allocate tids */
+ void *idtree_tid;
} tree;
/* the context associated with open files on an smb socket */
diff --git a/source4/smbd/rewrite.c b/source4/smbd/rewrite.c
index 3391a2d3e1..03542bf4e9 100644
--- a/source4/smbd/rewrite.c
+++ b/source4/smbd/rewrite.c
@@ -90,10 +90,6 @@ BOOL reload_services(struct smbsrv_connection *smb, BOOL test)
if (test && !lp_file_list_changed())
return(True);
- if (smb) {
- lp_killunused(smb, conn_snum_used);
- }
-
ret = lp_load(dyn_CONFIGFILE, False, False, True);
/* perhaps the config filename is now set */
diff --git a/source4/torture/vfstest.c b/source4/torture/vfstest.c
index 6975d009a5..eb2acd3481 100644
--- a/source4/torture/vfstest.c
+++ b/source4/torture/vfstest.c
@@ -438,8 +438,6 @@ BOOL reload_services(BOOL test)
if (test && !lp_file_list_changed())
return(True);
- lp_killunused(conn_snum_used);
-
ret = lp_load(dyn_CONFIGFILE, False, False, True);
load_printers();