diff options
-rw-r--r-- | source/locking/locking.c | 52 | ||||
-rw-r--r-- | source/locking/locking_shm.c | 12 | ||||
-rw-r--r-- | source/locking/locking_slow.c | 29 | ||||
-rw-r--r-- | source/locking/shmem_sysv.c | 10 |
4 files changed, 69 insertions, 34 deletions
diff --git a/source/locking/locking.c b/source/locking/locking.c index 84c9c442b5a..2022d28ac00 100644 --- a/source/locking/locking.c +++ b/source/locking/locking.c @@ -241,7 +241,7 @@ static void remove_share_oplock_fn(share_mode_entry *entry, SMB_DEV_T dev, SMB_I (unsigned int)dev, (double)inode )); /* Delete the oplock info. */ entry->op_port = 0; - entry->op_type = 0; + entry->op_type = NO_OPLOCK; } /******************************************************************* @@ -258,14 +258,45 @@ BOOL remove_share_oplock(int token, files_struct *fsp) below. ********************************************************************/ +static void downgrade_share_oplock_fn(share_mode_entry *entry, SMB_DEV_T dev, SMB_INO_T inode, + void *param) +{ + DEBUG(10,("downgrade_share_oplock_fn: downgrading oplock info for entry dev=%x ino=%.0f\n", + (unsigned int)dev, (double)inode )); + entry->op_type = LEVEL_II_OPLOCK; +} + +/******************************************************************* + Downgrade a oplock type from exclusive to level II. +********************************************************************/ + +BOOL downgrade_share_oplock(int token, files_struct *fsp) +{ + return share_ops->mod_entry(token, fsp, downgrade_share_oplock_fn, NULL); +} + +/******************************************************************* + Static function that actually does the work for the generic function + below. +********************************************************************/ + +struct mod_val { + int new_share_mode; + uint16 new_oplock; +}; + static void modify_share_mode_fn(share_mode_entry *entry, SMB_DEV_T dev, SMB_INO_T inode, void *param) { - int new_share_mode = *(int *)param; - DEBUG(10,("modify_share_mode_fn: changing share mode info from %x to %x for entry dev=%x ino=%.0f\n", - entry->share_mode, new_share_mode, (unsigned int)dev, (double)inode )); - /* Change the share mode info. */ - entry->share_mode = new_share_mode; + struct mod_val *mvp = (struct mod_val *)param; + + DEBUG(10,("modify_share_mode_fn: changing share mode info from %x to %x for entry dev=%x ino=%.0f\n", + entry->share_mode, mvp->new_share_mode, (unsigned int)dev, (double)inode )); + DEBUG(10,("modify_share_mode_fn: changing oplock state from %x to %x for entry dev=%x ino=%.0f\n", + entry->op_type, (int)mvp->new_oplock, (unsigned int)dev, (double)inode )); + /* Change the share mode info. */ + entry->share_mode = mvp->new_share_mode; + entry->op_type = mvp->new_oplock; } /******************************************************************* @@ -273,9 +304,14 @@ static void modify_share_mode_fn(share_mode_entry *entry, SMB_DEV_T dev, SMB_INO Return False on fail, True on success. ********************************************************************/ -BOOL modify_share_mode(int token, files_struct *fsp, int new_mode) +BOOL modify_share_mode(int token, files_struct *fsp, int new_mode, uint16 new_oplock) { - return share_ops->mod_entry(token, fsp, modify_share_mode_fn, (void *)&new_mode); + struct mod_val mv; + + mv.new_share_mode = new_mode; + mv.new_oplock = new_oplock; + + return share_ops->mod_entry(token, fsp, modify_share_mode_fn, (void *)&mv); } /******************************************************************* diff --git a/source/locking/locking_shm.c b/source/locking/locking_shm.c index 55582358137..174ad73e977 100644 --- a/source/locking/locking_shm.c +++ b/source/locking/locking_shm.c @@ -178,7 +178,7 @@ static int shm_get_share_modes(connection_struct *conn, entry_prev_p = entry_scanner_p; while(entry_scanner_p) { - int pid = entry_scanner_p->e.pid; + pid_t pid = entry_scanner_p->e.pid; if (pid && !process_exists(pid)) { @@ -210,7 +210,7 @@ static int shm_get_share_modes(connection_struct *conn, return 0; } - DEBUG(0,("get_share_modes: process %d no longer exists\n", pid)); + DEBUG(0,("get_share_modes: process %d no longer exists\n", (int)pid)); shmops->shm_free(shmops->addr2offset(delete_entry_p)); } @@ -227,7 +227,7 @@ static int shm_get_share_modes(connection_struct *conn, sizeof(struct timeval)); num_entries_copied++; DEBUG(5,("get_share_modes Read share mode 0x%X pid=%d\n", - entry_scanner_p->e.share_mode, entry_scanner_p->e.pid)); + entry_scanner_p->e.share_mode, (int)entry_scanner_p->e.pid)); entry_prev_p = entry_scanner_p; entry_scanner_p = (shm_share_mode_entry *) shmops->offset2addr(entry_scanner_p->next_share_mode_entry); @@ -271,7 +271,7 @@ static void shm_del_share_mode(int token, files_struct *fsp) shm_share_mode_entry *entry_scanner_p; shm_share_mode_entry *entry_prev_p; BOOL found = False; - int pid = getpid(); + pid_t pid = getpid(); dev = fsp->fd_ptr->dev; inode = fsp->fd_ptr->inode; @@ -492,7 +492,7 @@ static BOOL shm_set_share_mode(int token, files_struct *fsp, uint16 port, uint16 file_scanner_p->num_share_mode_entries += 1; DEBUG(3,("set_share_mode: Created share entry for %s with mode 0x%X pid=%d\n", - fsp->fsp_name, fsp->share_mode, new_entry_p->e.pid)); + fsp->fsp_name, fsp->share_mode, (int)new_entry_p->e.pid)); return(True); } @@ -513,7 +513,7 @@ static BOOL shm_mod_share_entry(int token, files_struct *fsp, share_mode_record *file_prev_p; shm_share_mode_entry *entry_scanner_p; BOOL found = False; - int pid = getpid(); + pid_t pid = getpid(); dev = fsp->fd_ptr->dev; inode = fsp->fd_ptr->inode; diff --git a/source/locking/locking_slow.c b/source/locking/locking_slow.c index c91316d23d9..f60d2a26855 100644 --- a/source/locking/locking_slow.c +++ b/source/locking/locking_slow.c @@ -434,16 +434,16 @@ for share file %s\n", num_entries, fname)); for( i = 0; i < num_entries; i++) { - int pid; + pid_t pid; char *p = base + (i*SMF_ENTRY_LENGTH); - pid = IVAL(p,SME_PID_OFFSET); + pid = (pid_t)IVAL(p,SME_PID_OFFSET); if(!process_exists(pid)) { DEBUG(0,("get_share_modes: process %d no longer exists and \ it left a share mode entry with mode 0x%X in share file %s\n", - pid, IVAL(p,SME_SHAREMODE_OFFSET), fname)); + (int)pid, IVAL(p,SME_SHAREMODE_OFFSET), fname)); continue; } share_array[num_entries_copied].time.tv_sec = IVAL(p,SME_SEC_OFFSET); @@ -492,7 +492,7 @@ position 0 for share mode file %s (%s)\n", fname, strerror(errno))); { char *p = base + (i*SMF_ENTRY_LENGTH); - SIVAL(p,SME_PID_OFFSET,share_array[i].pid); + SIVAL(p,SME_PID_OFFSET,(uint32)share_array[i].pid); SIVAL(p,SME_SHAREMODE_OFFSET,share_array[i].share_mode); SIVAL(p,SME_SEC_OFFSET,share_array[i].time.tv_sec); SIVAL(p,SME_USEC_OFFSET,share_array[i].time.tv_usec); @@ -561,7 +561,7 @@ static void slow_del_share_mode(int token, files_struct *fsp) int num_entries; int newsize; int i; - int pid; + pid_t pid; BOOL deleted = False; BOOL new_file; @@ -622,7 +622,7 @@ for share file %s\n", num_entries, fname)); if((IVAL(p,SME_SEC_OFFSET) != fsp->open_time.tv_sec) || (IVAL(p,SME_USEC_OFFSET) != fsp->open_time.tv_usec) || (IVAL(p,SME_SHAREMODE_OFFSET) != fsp->share_mode) || - (IVAL(p,SME_PID_OFFSET) != pid)) + (((pid_t)IVAL(p,SME_PID_OFFSET)) != pid)) continue; DEBUG(5,("del_share_mode: deleting entry number %d (of %d) from the share file %s\n", @@ -712,7 +712,7 @@ static BOOL slow_set_share_mode(int token,files_struct *fsp, uint16 port, uint16 { pstring fname; int fd = (int)token; - int pid = (int)getpid(); + pid_t pid = getpid(); SMB_STRUCT_STAT sb; char *buf; int num_entries; @@ -808,7 +808,7 @@ deleting it.\n", fname)); SIVAL(p,SME_SEC_OFFSET,fsp->open_time.tv_sec); SIVAL(p,SME_USEC_OFFSET,fsp->open_time.tv_usec); SIVAL(p,SME_SHAREMODE_OFFSET,fsp->share_mode); - SIVAL(p,SME_PID_OFFSET,pid); + SIVAL(p,SME_PID_OFFSET,(uint32)pid); SSVAL(p,SME_PORT_OFFSET,port); SSVAL(p,SME_OPLOCK_TYPE_OFFSET,op_type); @@ -867,7 +867,7 @@ mode file %s to size %d (%s)\n", fname, header_size + (SMF_ENTRY_LENGTH*num_entr free(buf); DEBUG(3,("set_share_mode: Created share file %s with \ -mode 0x%X pid=%d\n",fname,fsp->share_mode,pid)); +mode 0x%X pid=%d\n",fname,fsp->share_mode,(int)pid)); return True; } @@ -887,7 +887,7 @@ static BOOL slow_mod_share_entry(int token, files_struct *fsp, int num_entries; int fsize; int i; - int pid; + pid_t pid; BOOL found = False; BOOL new_file; share_mode_entry entry; @@ -945,7 +945,7 @@ for share file %s\n", num_entries, fname)); if((IVAL(p,SME_SEC_OFFSET) != fsp->open_time.tv_sec) || (IVAL(p,SME_USEC_OFFSET) != fsp->open_time.tv_usec) || (IVAL(p,SME_SHAREMODE_OFFSET) != fsp->share_mode) || - (IVAL(p,SME_PID_OFFSET) != pid)) + (((pid_t)IVAL(p,SME_PID_OFFSET)) != pid)) continue; DEBUG(5,("slow_mod_share_entry: Calling generic function to modify entry number %d (of %d) \ @@ -956,7 +956,7 @@ from the share file %s\n", i, num_entries, fname)); * the generic function with the given parameter. */ - entry.pid = IVAL(p,SME_PID_OFFSET); + entry.pid = (pid_t)IVAL(p,SME_PID_OFFSET); entry.op_port = SVAL(p,SME_PORT_OFFSET); entry.op_type = SVAL(p,SME_OPLOCK_TYPE_OFFSET); entry.share_mode = IVAL(p,SME_SHAREMODE_OFFSET); @@ -969,7 +969,7 @@ from the share file %s\n", i, num_entries, fname)); * Now copy any changes the function made back into the buffer. */ - SIVAL(p,SME_PID_OFFSET, entry.pid); + SIVAL(p,SME_PID_OFFSET, (uint32)entry.pid); SSVAL(p,SME_PORT_OFFSET,entry.op_port); SSVAL(p,SME_OPLOCK_TYPE_OFFSET,entry.op_type); SIVAL(p,SME_SHAREMODE_OFFSET,entry.share_mode); @@ -1077,12 +1077,11 @@ static int slow_share_forall(void (*fn)(share_mode_entry *, char *)) SVAL(buf,SMF_FILENAME_LEN_OFFSET); for( i = 0; i < IVAL(buf, SMF_NUM_ENTRIES_OFFSET); i++) { char *p = base + (i*SMF_ENTRY_LENGTH); - e.pid = IVAL(p,SME_PID_OFFSET); + e.pid = (pid_t)IVAL(p,SME_PID_OFFSET); e.share_mode = IVAL(p,SME_SHAREMODE_OFFSET); e.time.tv_sec = IVAL(p,SME_SEC_OFFSET); e.time.tv_usec = IVAL(p,SME_USEC_OFFSET); e.op_port = SVAL(p,SME_PORT_OFFSET); - e.pid = SVAL(p,SME_PID_OFFSET); e.op_type = SVAL(p,SME_OPLOCK_TYPE_OFFSET); if (process_exists(e.pid)) { diff --git a/source/locking/shmem_sysv.c b/source/locking/shmem_sysv.c index 646af6fc57d..8788eb90cc3 100644 --- a/source/locking/shmem_sysv.c +++ b/source/locking/shmem_sysv.c @@ -535,7 +535,7 @@ struct shmem_ops *sysv_shm_open(int ronly) struct semid_ds sem_ds; union semun su; int i; - int pid; + pid_t pid; read_only = ronly; @@ -599,9 +599,9 @@ struct shmem_ops *sysv_shm_open(int ronly) } if (semctl(sem_id, 0, GETVAL, su) == 0 && - !process_exists((pid=semctl(sem_id, 0, GETPID, su)))) { + !process_exists((pid=(pid_t)semctl(sem_id, 0, GETPID, su)))) { DEBUG(0,("WARNING: clearing global IPC lock set by dead process %d\n", - pid)); + (int)pid)); su.val = 1; if (semctl(sem_id, 0, SETVAL, su) != 0) { DEBUG(0,("ERROR: Failed to clear global lock. Error was %s\n", @@ -624,9 +624,9 @@ struct shmem_ops *sysv_shm_open(int ronly) for (i=1;i<hash_size+1;i++) { if (semctl(sem_id, i, GETVAL, su) == 0 && - !process_exists((pid=semctl(sem_id, i, GETPID, su)))) { + !process_exists((pid=(pid_t)semctl(sem_id, i, GETPID, su)))) { DEBUG(1,("WARNING: clearing IPC lock %d set by dead process %d\n", - i, pid)); + i, (int)pid)); su.val = 1; if (semctl(sem_id, i, SETVAL, su) != 0) { DEBUG(0,("ERROR: Failed to clear IPC lock %d. Error was %s\n", |