summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2003-12-11 20:00:16 +0000
committerJeremy Allison <jra@samba.org>2003-12-11 20:00:16 +0000
commitb05b6046fc790329d6b301aafb7ddb0b64ce00ab (patch)
tree616e8a01c58da4473c5e469114f2982148465ee5 /source3
parent2e879cfacc23dd619055a7f5861dcab520951b2c (diff)
downloadsamba-b05b6046fc790329d6b301aafb7ddb0b64ce00ab.tar.gz
samba-b05b6046fc790329d6b301aafb7ddb0b64ce00ab.tar.bz2
samba-b05b6046fc790329d6b301aafb7ddb0b64ce00ab.zip
Patch from James Peach <jpeach@sgi.com>. Remove the MAX_CONNECTIONS limit
by increasing bitmap size. Limited by "max connections" parameter. Bug #716. Jeremy. (This used to be commit fbbeb55b230ffc477f5563af66ab65eb6598e025)
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/bitmap.c14
-rw-r--r--source3/smbd/conn.c41
2 files changed, 46 insertions, 9 deletions
diff --git a/source3/lib/bitmap.c b/source3/lib/bitmap.c
index 1023dd6541..3fa20cdd11 100644
--- a/source3/lib/bitmap.c
+++ b/source3/lib/bitmap.c
@@ -84,6 +84,20 @@ struct bitmap *bitmap_talloc(TALLOC_CTX *mem_ctx, int n)
}
/****************************************************************************
+copy as much of the source bitmap as will fit in the destination bitmap.
+****************************************************************************/
+
+int bitmap_copy(struct bitmap * const dst, const struct bitmap * const src)
+{
+ int count = MIN(dst->n, src->n);
+
+ SMB_ASSERT(dst->b != src->b);
+ memcpy(dst->b, src->b, sizeof(dst->b[0])*(count+31)/32);
+
+ return count;
+}
+
+/****************************************************************************
set a bit in a bitmap
****************************************************************************/
BOOL bitmap_set(struct bitmap *bm, unsigned i)
diff --git a/source3/smbd/conn.c b/source3/smbd/conn.c
index eb2d2bbcbf..289b7d611d 100644
--- a/source3/smbd/conn.c
+++ b/source3/smbd/conn.c
@@ -21,11 +21,11 @@
#include "includes.h"
-/* set these to define the limits of the server. NOTE These are on a
- 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
+/* The connections bitmap is expanded in increments of BITMAP_BLOCK_SZ. The
+ * maximum size of the bitmap is the largest positive integer, but you will hit
+ * the "max connections" limit, looong before that.
+ */
+#define BITMAP_BLOCK_SZ 128
static connection_struct *Connections;
@@ -38,7 +38,7 @@ init the conn structures
****************************************************************************/
void conn_init(void)
{
- bmap = bitmap_allocate(MAX_CONNECTIONS);
+ bmap = bitmap_allocate(BITMAP_BLOCK_SZ);
}
/****************************************************************************
@@ -96,12 +96,35 @@ connection_struct *conn_new(void)
TALLOC_CTX *mem_ctx;
connection_struct *conn;
int i;
+ int find_offset = 1;
- i = bitmap_find(bmap, 1);
+find_again:
+ i = bitmap_find(bmap, find_offset);
if (i == -1) {
- DEBUG(1,("ERROR! Out of connection structures\n"));
- return NULL;
+ /* Expand the connections bitmap. */
+ int oldsz = bmap->n;
+ int newsz = bmap->n + BITMAP_BLOCK_SZ;
+ struct bitmap * nbmap;
+
+ if (newsz <= 0) {
+ /* Integer wrap. */
+ DEBUG(0,("ERROR! Out of connection structures\n"));
+ return NULL;
+ }
+
+ DEBUG(4,("resizing connections bitmap from %d to %d\n",
+ oldsz, newsz));
+
+ nbmap = bitmap_allocate(newsz);
+
+ bitmap_copy(nbmap, bmap);
+ bitmap_free(bmap);
+
+ bmap = nbmap;
+ find_offset = oldsz; /* Start next search in the new portion. */
+
+ goto find_again;
}
if ((mem_ctx=talloc_init("connection_struct"))==NULL) {