summaryrefslogtreecommitdiff
path: root/source3/locking
diff options
context:
space:
mode:
Diffstat (limited to 'source3/locking')
-rw-r--r--source3/locking/locking_shm.c32
-rw-r--r--source3/locking/shmem.c44
2 files changed, 33 insertions, 43 deletions
diff --git a/source3/locking/locking_shm.c b/source3/locking/locking_shm.c
index 47074cff6b..8383b687e4 100644
--- a/source3/locking/locking_shm.c
+++ b/source3/locking/locking_shm.c
@@ -42,19 +42,19 @@ extern files_struct Files[];
/* share mode record pointed to in shared memory hash bucket */
typedef struct
{
- smb_shm_offset_t next_offset; /* offset of next record in chain from hash bucket */
+ int next_offset; /* offset of next record in chain from hash bucket */
int locking_version;
int32 st_dev;
int32 st_ino;
int num_share_mode_entries;
- smb_shm_offset_t share_mode_entries; /* Chain of share mode entries for this file */
+ int share_mode_entries; /* Chain of share mode entries for this file */
char file_name[1];
} share_mode_record;
/* share mode entry pointed to by share_mode_record struct */
typedef struct
{
- smb_shm_offset_t next_share_mode_entry;
+ int next_share_mode_entry;
share_mode_entry e;
} shm_share_mode_entry;
@@ -89,7 +89,7 @@ get all share mode entries in shared memory for a dev/inode pair.
static int shm_get_share_modes(int cnum, int token, uint32 dev, uint32 inode,
share_mode_entry **old_shares)
{
- smb_shm_offset_t *mode_array;
+ int *mode_array;
unsigned int hash_entry = HASH_ENTRY(dev, inode);
share_mode_record *file_scanner_p;
share_mode_record *file_prev_p;
@@ -111,7 +111,7 @@ static int shm_get_share_modes(int cnum, int token, uint32 dev, uint32 inode,
return 0;
}
- mode_array = (smb_shm_offset_t *)smb_shm_offset2addr(smb_shm_get_userdef_off());
+ mode_array = (int *)smb_shm_offset2addr(smb_shm_get_userdef_off());
if(mode_array[hash_entry] == NULL_OFFSET)
{
@@ -267,7 +267,7 @@ del the share mode of a file.
static void shm_del_share_mode(int token, int fnum)
{
uint32 dev, inode;
- smb_shm_offset_t *mode_array;
+ int *mode_array;
unsigned int hash_entry;
share_mode_record *file_scanner_p;
share_mode_record *file_prev_p;
@@ -290,7 +290,7 @@ static void shm_del_share_mode(int token, int fnum)
return;
}
- mode_array = (smb_shm_offset_t *)smb_shm_offset2addr(smb_shm_get_userdef_off());
+ mode_array = (int *)smb_shm_offset2addr(smb_shm_get_userdef_off());
if(mode_array[hash_entry] == NULL_OFFSET)
{
@@ -408,12 +408,12 @@ static BOOL shm_set_share_mode(int token, int fnum, uint16 port, uint16 op_type)
{
files_struct *fs_p = &Files[fnum];
int32 dev, inode;
- smb_shm_offset_t *mode_array;
+ int *mode_array;
unsigned int hash_entry;
share_mode_record *file_scanner_p;
share_mode_record *file_prev_p;
shm_share_mode_entry *new_entry_p;
- smb_shm_offset_t new_entry_offset;
+ int new_entry_offset;
BOOL found = False;
dev = fs_p->fd_ptr->dev;
@@ -429,7 +429,7 @@ static BOOL shm_set_share_mode(int token, int fnum, uint16 port, uint16 op_type)
return False;
}
- mode_array = (smb_shm_offset_t *)smb_shm_offset2addr(smb_shm_get_userdef_off());
+ mode_array = (int *)smb_shm_offset2addr(smb_shm_get_userdef_off());
file_scanner_p = (share_mode_record *)smb_shm_offset2addr(mode_array[hash_entry]);
file_prev_p = file_scanner_p;
@@ -453,7 +453,7 @@ static BOOL shm_set_share_mode(int token, int fnum, uint16 port, uint16 op_type)
{
/* We must create a share_mode_record */
share_mode_record *new_mode_p = NULL;
- smb_shm_offset_t new_offset = smb_shm_alloc( sizeof(share_mode_record) +
+ int new_offset = smb_shm_alloc( sizeof(share_mode_record) +
strlen(fs_p->name) + 1);
if(new_offset == NULL_OFFSET)
{
@@ -482,7 +482,7 @@ inode %d in hash bucket %d\n", fs_p->name, dev, inode, hash_entry));
new_entry_offset = smb_shm_alloc( sizeof(shm_share_mode_entry));
if(new_entry_offset == NULL_OFFSET)
{
- smb_shm_offset_t delete_offset = mode_array[hash_entry];
+ int delete_offset = mode_array[hash_entry];
DEBUG(0,("ERROR:set_share_mode (FAST_SHARE_MODES): smb_shm_alloc fail 1!\n"));
/* Unlink the damaged record */
mode_array[hash_entry] = file_scanner_p->next_offset;
@@ -528,7 +528,7 @@ Remove an oplock port and mode entry from a share mode.
static BOOL shm_remove_share_oplock(int fnum, int token)
{
uint32 dev, inode;
- smb_shm_offset_t *mode_array;
+ int *mode_array;
unsigned int hash_entry;
share_mode_record *file_scanner_p;
share_mode_record *file_prev_p;
@@ -551,7 +551,7 @@ static BOOL shm_remove_share_oplock(int fnum, int token)
return False;
}
- mode_array = (smb_shm_offset_t *)smb_shm_offset2addr(smb_shm_get_userdef_off());
+ mode_array = (int *)smb_shm_offset2addr(smb_shm_get_userdef_off());
if(mode_array[hash_entry] == NULL_OFFSET)
{
@@ -641,10 +641,10 @@ share mode system
static int shm_share_forall(void (*fn)(share_mode_entry *, char *))
{
int i, count=0;
- smb_shm_offset_t *mode_array;
+ int *mode_array;
share_mode_record *file_scanner_p;
- mode_array = (smb_shm_offset_t *)smb_shm_offset2addr(smb_shm_get_userdef_off());
+ mode_array = (int *)smb_shm_offset2addr(smb_shm_get_userdef_off());
for( i = 0; i < lp_shmem_hash_size(); i++) {
smb_shm_lock_hash_entry(i);
diff --git a/source3/locking/shmem.c b/source3/locking/shmem.c
index bbb11f215a..9daca3e482 100644
--- a/source3/locking/shmem.c
+++ b/source3/locking/shmem.c
@@ -43,8 +43,8 @@ struct SmbShmHeader
int smb_shm_version;
int total_size; /* in bytes */
BOOL consistent;
- smb_shm_offset_t first_free_off;
- smb_shm_offset_t userdef_off; /* a userdefined offset. can be used to store root of tree or list */
+ int first_free_off;
+ int userdef_off; /* a userdefined offset. can be used to store root of tree or list */
struct { /* a cell is a range of bytes of sizeof(struct SmbShmBlockDesc) size */
int cells_free;
int cells_used;
@@ -55,7 +55,7 @@ struct SmbShmHeader
#define SMB_SHM_NOT_FREE_OFF (-1)
struct SmbShmBlockDesc
{
- smb_shm_offset_t next; /* offset of next block in the free list or SMB_SHM_NOT_FREE_OFF when block in use */
+ int next; /* offset of next block in the free list or SMB_SHM_NOT_FREE_OFF when block in use */
int size; /* user size in BlockDescSize units */
};
@@ -141,10 +141,9 @@ static BOOL smb_shm_global_unlock(void)
* Function to create the hash table for the share mode entries. Called
* when smb shared memory is global locked.
*/
-
-BOOL smb_shm_create_hash_table( unsigned int size )
+static BOOL smb_shm_create_hash_table( unsigned int size )
{
- size *= sizeof(smb_shm_offset_t);
+ size *= sizeof(int);
smb_shm_global_lock();
smb_shm_header_p->userdef_off = smb_shm_alloc( size );
@@ -381,7 +380,7 @@ static void smb_shm_solve_neighbors(struct SmbShmBlockDesc *head_p )
-BOOL smb_shm_open( char *file_name, int size)
+BOOL smb_shm_open(char *file_name, int size)
{
int filesize;
BOOL created_new = False;
@@ -533,13 +532,13 @@ BOOL smb_shm_close( void )
return True;
}
-smb_shm_offset_t smb_shm_alloc(int size)
+int smb_shm_alloc(int size)
{
unsigned num_cells ;
struct SmbShmBlockDesc *scanner_p;
struct SmbShmBlockDesc *prev_p;
struct SmbShmBlockDesc *new_p;
- smb_shm_offset_t result_offset;
+ int result_offset;
if( !smb_shm_header_p )
@@ -637,7 +636,7 @@ smb_shm_offset_t smb_shm_alloc(int size)
-BOOL smb_shm_free(smb_shm_offset_t offset)
+BOOL smb_shm_free(int offset)
{
struct SmbShmBlockDesc *header_p ; /* pointer to header of block to free */
struct SmbShmBlockDesc *scanner_p ; /* used to scan the list */
@@ -716,7 +715,7 @@ BOOL smb_shm_free(smb_shm_offset_t offset)
}
}
-smb_shm_offset_t smb_shm_get_userdef_off(void)
+int smb_shm_get_userdef_off(void)
{
if (!smb_shm_header_p)
return NULL_OFFSET;
@@ -724,16 +723,7 @@ smb_shm_offset_t smb_shm_get_userdef_off(void)
return smb_shm_header_p->userdef_off;
}
-BOOL smb_shm_set_userdef_off(smb_shm_offset_t userdef_off)
-{
- if (!smb_shm_header_p)
- return False;
- else
- smb_shm_header_p->userdef_off = userdef_off;
- return True;
-}
-
-void *smb_shm_offset2addr(smb_shm_offset_t offset)
+void *smb_shm_offset2addr(int offset)
{
if (offset == NULL_OFFSET )
return (void *)(0);
@@ -744,7 +734,7 @@ void *smb_shm_offset2addr(smb_shm_offset_t offset)
return (void *)((char *)smb_shm_header_p + offset );
}
-smb_shm_offset_t smb_shm_addr2offset(void *addr)
+int smb_shm_addr2offset(void *addr)
{
if (!addr)
return NULL_OFFSET;
@@ -752,7 +742,7 @@ smb_shm_offset_t smb_shm_addr2offset(void *addr)
if (!smb_shm_header_p)
return NULL_OFFSET;
- return (smb_shm_offset_t)((char *)addr - (char *)smb_shm_header_p);
+ return (int)((char *)addr - (char *)smb_shm_header_p);
}
/*******************************************************************
@@ -761,7 +751,7 @@ smb_shm_offset_t smb_shm_addr2offset(void *addr)
BOOL smb_shm_lock_hash_entry( unsigned int entry)
{
- int start = (smb_shm_header_p->userdef_off + (entry * sizeof(smb_shm_offset_t)));
+ int start = (smb_shm_header_p->userdef_off + (entry * sizeof(int)));
if (smb_shm_fd < 0)
{
@@ -776,7 +766,7 @@ BOOL smb_shm_lock_hash_entry( unsigned int entry)
}
/* Do an exclusive wait lock on the 4 byte region mapping into this entry */
- if (fcntl_lock(smb_shm_fd, F_SETLKW, start, sizeof(smb_shm_offset_t), F_WRLCK) == False)
+ if (fcntl_lock(smb_shm_fd, F_SETLKW, start, sizeof(int), F_WRLCK) == False)
{
DEBUG(0,("ERROR smb_shm_lock_hash_entry : fcntl_lock failed with code %s\n",strerror(errno)));
return False;
@@ -792,7 +782,7 @@ BOOL smb_shm_lock_hash_entry( unsigned int entry)
BOOL smb_shm_unlock_hash_entry( unsigned int entry )
{
- int start = (smb_shm_header_p->userdef_off + (entry * sizeof(smb_shm_offset_t)));
+ int start = (smb_shm_header_p->userdef_off + (entry * sizeof(int)));
if (smb_shm_fd < 0)
{
@@ -807,7 +797,7 @@ BOOL smb_shm_unlock_hash_entry( unsigned int entry )
}
/* Do a wait lock on the 4 byte region mapping into this entry */
- if (fcntl_lock(smb_shm_fd, F_SETLKW, start, sizeof(smb_shm_offset_t), F_UNLCK) == False)
+ if (fcntl_lock(smb_shm_fd, F_SETLKW, start, sizeof(int), F_UNLCK) == False)
{
DEBUG(0,("ERROR smb_shm_unlock_hash_entry : fcntl_lock failed with code %s\n",strerror(errno)));
return False;