summaryrefslogtreecommitdiff
path: root/source4/smb_server
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-10-19 07:08:35 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:01:54 -0500
commitb2b8282b8cc1774ac9cbef9a31ac23705ca45ac2 (patch)
tree3cb1f5babb9b0f16c9294b80aa939df6539e5deb /source4/smb_server
parentcf1b85348a0fc5bf4788291109c9dca9e95eb9c2 (diff)
downloadsamba-b2b8282b8cc1774ac9cbef9a31ac23705ca45ac2.tar.gz
samba-b2b8282b8cc1774ac9cbef9a31ac23705ca45ac2.tar.bz2
samba-b2b8282b8cc1774ac9cbef9a31ac23705ca45ac2.zip
r3057: - moved the idtree.c code into lib/
- converted the tid handling to use a idtree instead of bitmaps (This used to be commit 4220914179d10132057216650b65ed7f7679717e)
Diffstat (limited to 'source4/smb_server')
-rw-r--r--source4/smb_server/conn.c93
-rw-r--r--source4/smb_server/smb_server.h6
2 files changed, 25 insertions, 74 deletions
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 */