summaryrefslogtreecommitdiffstats
path: root/source/locking
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>1998-08-30 04:35:54 +0000
committerAndrew Tridgell <tridge@samba.org>1998-08-30 04:35:54 +0000
commit9c1e4c2dae6323c9a1bd74148d0b45aac61e7c0a (patch)
treebbc4001e3a928e6829b7eeb946da7d9cf49822d5 /source/locking
parent99782754f79f3795f81cbf57caeb0925f6a66c10 (diff)
downloadsamba-9c1e4c2dae6323c9a1bd74148d0b45aac61e7c0a.tar.gz
samba-9c1e4c2dae6323c9a1bd74148d0b45aac61e7c0a.tar.xz
samba-9c1e4c2dae6323c9a1bd74148d0b45aac61e7c0a.zip
- zero shared memory before freeing it
- changed the hash size to 13 (much smaller than before). This should make for more efficient shared memory usage as it will lead to less fragmentation.
Diffstat (limited to 'source/locking')
-rw-r--r--source/locking/shmem.c5
-rw-r--r--source/locking/shmem_sysv.c9
2 files changed, 8 insertions, 6 deletions
diff --git a/source/locking/shmem.c b/source/locking/shmem.c
index be8e22108aa..6015085fe4b 100644
--- a/source/locking/shmem.c
+++ b/source/locking/shmem.c
@@ -41,7 +41,7 @@ extern int DEBUGLEVEL;
#define SHM_FILE_MODE 0644
#endif
-#define SHMEM_HASH_SIZE 113
+#define SHMEM_HASH_SIZE 13
/* WARNING : offsets are used because mmap() does not guarantee that all processes have the
@@ -606,6 +606,9 @@ static BOOL smb_shm_free(int offset)
DEBUG(6,("smb_shm_free : freeing %d bytes at offset %d\n",header_p->size*CellSize,offset));
+ /* zero the area being freed - this allows us to find bugs faster */
+ memset(smb_shm_offset2addr(offset), 0, header_p->size*CellSize);
+
if ( scanner_p == prev_p )
{
smb_shm_header_p->statistics.cells_free += header_p->size;
diff --git a/source/locking/shmem_sysv.c b/source/locking/shmem_sysv.c
index 192ed32344c..b57116f7b85 100644
--- a/source/locking/shmem_sysv.c
+++ b/source/locking/shmem_sysv.c
@@ -48,11 +48,7 @@ extern int DEBUGLEVEL;
#define SEMAPHORE_PERMS 0666
#endif
-#ifdef SEMMSL
-#define SHMEM_HASH_SIZE (SEMMSL-1)
-#else
-#define SHMEM_HASH_SIZE 63
-#endif
+#define SHMEM_HASH_SIZE 13
#define MIN_SHM_SIZE 0x1000
@@ -330,6 +326,9 @@ static BOOL shm_free(int offset)
DEBUG(6,("shm_free : freeing %d bytes at offset %d\n",
header_p->size*CellSize,offset));
+
+ /* zero the area being freed - this allows us to find bugs faster */
+ memset(shm_offset2addr(offset), 0, header_p->size*CellSize);
if (scanner_p == prev_p) {
shm_header_p->statistics.cells_free += header_p->size;