summaryrefslogtreecommitdiff
path: root/source3/locking
diff options
context:
space:
mode:
Diffstat (limited to 'source3/locking')
-rw-r--r--source3/locking/shmem.c15
-rw-r--r--source3/locking/shmem_sysv.c12
2 files changed, 19 insertions, 8 deletions
diff --git a/source3/locking/shmem.c b/source3/locking/shmem.c
index dd97d5c76c..be8e22108a 100644
--- a/source3/locking/shmem.c
+++ b/source3/locking/shmem.c
@@ -340,7 +340,7 @@ static BOOL smb_shm_register_process(char *processreg_file, pid_t pid, BOOL *oth
{
/* erase old pid */
DEBUG(5,("smb_shm_register_process : erasing stale record for pid %d (seek_back = %d)\n",
- other_pid, seek_back));
+ (int)other_pid, seek_back));
other_pid = (pid_t)0;
erased_slot = lseek(smb_shm_processes_fd, seek_back, SEEK_CUR);
write(smb_shm_processes_fd, &other_pid, sizeof(other_pid));
@@ -362,7 +362,8 @@ static BOOL smb_shm_register_process(char *processreg_file, pid_t pid, BOOL *oth
if(free_slot < 0)
free_slot = lseek(smb_shm_processes_fd, 0, SEEK_END);
- DEBUG(5,("smb_shm_register_process : writing record for pid %d at offset %d\n",pid,free_slot));
+ DEBUG(5,("smb_shm_register_process : writing record for pid %d at offset %d\n",
+ (int)pid,free_slot));
lseek(smb_shm_processes_fd, free_slot, SEEK_SET);
if(write(smb_shm_processes_fd, &pid, sizeof(pid)) < 0)
{
@@ -395,12 +396,12 @@ static BOOL smb_shm_unregister_process(char *processreg_file, pid_t pid)
while ((nb_read = read(smb_shm_processes_fd, &other_pid, sizeof(other_pid))) > 0)
{
- DEBUG(5,("smb_shm_unregister_process : read record for pid %d\n",other_pid));
+ DEBUG(5,("smb_shm_unregister_process : read record for pid %d\n",(int)other_pid));
if(other_pid == pid)
{
/* erase pid */
DEBUG(5,("smb_shm_unregister_process : erasing record for pid %d (seek_val = %d)\n",
- other_pid, seek_back));
+ (int)other_pid, seek_back));
other_pid = (pid_t)0;
erased_slot = lseek(smb_shm_processes_fd, seek_back, SEEK_CUR);
if(write(smb_shm_processes_fd, &other_pid, sizeof(other_pid)) < 0)
@@ -423,7 +424,8 @@ static BOOL smb_shm_unregister_process(char *processreg_file, pid_t pid)
if(!found)
{
- DEBUG(0,("ERROR smb_shm_unregister_process : couldn't find pid %d in file %s\n",pid,processreg_file));
+ DEBUG(0,("ERROR smb_shm_unregister_process : couldn't find pid %d in file %s\n",
+ (int)pid,processreg_file));
close(smb_shm_processes_fd);
return False;
}
@@ -540,7 +542,8 @@ static BOOL smb_shm_close( void )
}
smb_shm_global_lock();
- DEBUG(5,("calling smb_shm_unregister_process(%s, %d)\n", smb_shm_processreg_name, getpid()));
+ DEBUG(5,("calling smb_shm_unregister_process(%s, %d)\n",
+ smb_shm_processreg_name, (int)getpid()));
smb_shm_unregister_process(smb_shm_processreg_name, getpid());
smb_shm_global_unlock();
diff --git a/source3/locking/shmem_sysv.c b/source3/locking/shmem_sysv.c
index b8b9c2cb45..192ed32344 100644
--- a/source3/locking/shmem_sysv.c
+++ b/source3/locking/shmem_sysv.c
@@ -564,8 +564,9 @@ struct shmem_ops *sysv_shm_open(int ronly)
}
if (sem_id == -1) {
- DEBUG(0,("Can't create or use semaphore %s\n",
+ DEBUG(0,("Can't create or use semaphore [1]. Error was %s\n",
strerror(errno)));
+ return NULL;
}
if (sem_id != -1) {
@@ -574,6 +575,7 @@ struct shmem_ops *sysv_shm_open(int ronly)
if (semctl(sem_id, i, SETVAL, su) != 0) {
DEBUG(1,("Failed to init semaphore %d. Error was %s\n",
i, strerror(errno)));
+ return NULL;
}
}
}
@@ -582,7 +584,7 @@ struct shmem_ops *sysv_shm_open(int ronly)
sem_id = semget(SEMAPHORE_KEY, 0, 0);
}
if (sem_id == -1) {
- DEBUG(0,("Can't create or use semaphore.Error was %s\n",
+ DEBUG(0,("Can't create or use semaphore [2]. Error was %s\n",
strerror(errno)));
return NULL;
}
@@ -609,6 +611,7 @@ struct shmem_ops *sysv_shm_open(int ronly)
if (semctl(sem_id, 0, SETVAL, su) != 0) {
DEBUG(0,("ERROR: Failed to clear global lock. Error was %s\n",
strerror(errno)));
+ return NULL;
}
}
@@ -616,6 +619,7 @@ struct shmem_ops *sysv_shm_open(int ronly)
if (semctl(sem_id, 0, IPC_SET, su) != 0) {
DEBUG(0,("ERROR shmctl : can't IPC_SET. Error was %s\n",
strerror(errno)));
+ return NULL;
}
}
@@ -632,6 +636,8 @@ struct shmem_ops *sysv_shm_open(int ronly)
if (semctl(sem_id, i, SETVAL, su) != 0) {
DEBUG(0,("ERROR: Failed to clear IPC lock %d. Error was %s\n",
i, strerror(errno)));
+ global_unlock();
+ return NULL;
}
}
}
@@ -679,6 +685,8 @@ struct shmem_ops *sysv_shm_open(int ronly)
mapping processes */
if (shmctl(shm_id, IPC_STAT, &shm_ds) != 0) {
DEBUG(0,("ERROR shmctl : can't IPC_STAT. Error was %s\n", strerror(errno)));
+ global_unlock();
+ return NULL;
}
if (!read_only) {