summaryrefslogtreecommitdiff
path: root/source3/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
commit98411c48c08f6093a0b42b46c02c6544804bf98d (patch)
tree1342b4de79d99354bb66c2be1d9a0403a2f2a819 /source3/locking
parenta6c94d7eb1a446c6281326964797a1eaf7fc6c78 (diff)
downloadsamba-98411c48c08f6093a0b42b46c02c6544804bf98d.tar.gz
samba-98411c48c08f6093a0b42b46c02c6544804bf98d.tar.bz2
samba-98411c48c08f6093a0b42b46c02c6544804bf98d.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. (This used to be commit 9c1e4c2dae6323c9a1bd74148d0b45aac61e7c0a)
Diffstat (limited to 'source3/locking')
-rw-r--r--source3/locking/shmem.c5
-rw-r--r--source3/locking/shmem_sysv.c9
2 files changed, 8 insertions, 6 deletions
diff --git a/source3/locking/shmem.c b/source3/locking/shmem.c
index be8e22108a..6015085fe4 100644
--- a/source3/locking/shmem.c
+++ b/source3/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/source3/locking/shmem_sysv.c b/source3/locking/shmem_sysv.c
index 192ed32344..b57116f7b8 100644
--- a/source3/locking/shmem_sysv.c
+++ b/source3/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;