Commit bcf18b6c authored by 's avatar
Browse files

fixes in error checking

related to bug #486
just for sure


git-svn-id: file:///home/svn/mapi/trunk@1393 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent 1171cd31
...@@ -422,7 +422,7 @@ mapid_init(mapidlib_instance_t *i) ...@@ -422,7 +422,7 @@ mapid_init(mapidlib_instance_t *i)
if((i->shm_spinlock_id=shmget(i->shm_spinlock_key,sizeof(pthread_spinlock_t),FUNCTION_SHM_PERMS | IPC_CREAT)) < 0) if((i->shm_spinlock_id=shmget(i->shm_spinlock_key,sizeof(pthread_spinlock_t),FUNCTION_SHM_PERMS | IPC_CREAT)) < 0)
return MDLIB_SHM_ERR; return MDLIB_SHM_ERR;
if((i->shm_spinlock=shmat(i->shm_spinlock_id,0,0))==NULL) if((i->shm_spinlock=shmat(i->shm_spinlock_id,NULL,0))==(void *) -1)
return MDLIB_SHM_ERR; return MDLIB_SHM_ERR;
// if a mapi user group exists, set group permissions accordingly, // if a mapi user group exists, set group permissions accordingly,
...@@ -440,7 +440,8 @@ mapid_init(mapidlib_instance_t *i) ...@@ -440,7 +440,8 @@ mapid_init(mapidlib_instance_t *i)
} }
//Initialize spinlock //Initialize spinlock
pthread_spin_init (i->shm_spinlock, PTHREAD_PROCESS_SHARED); if(pthread_spin_init (i->shm_spinlock, PTHREAD_PROCESS_SHARED) != 0)
return MDLIB_SHM_ERR;
i->shm_spinlock_size=sizeof(pthread_spinlock_t); i->shm_spinlock_size=sizeof(pthread_spinlock_t);
return 0; return 0;
...@@ -744,7 +745,7 @@ mapid_connect(mapidlib_instance_t *i,int fd) ...@@ -744,7 +745,7 @@ mapid_connect(mapidlib_instance_t *i,int fd)
flow->shm_id=id; flow->shm_id=id;
if((flow->shm=shmat(id,0,0))==NULL) if((flow->shm=shmat(id,NULL,0))==(void *) -1)
return MDLIB_SHM_ERR; return MDLIB_SHM_ERR;
// if a mapi user group exists, set group permissions accordingly, // if a mapi user group exists, set group permissions accordingly,
......
...@@ -2918,7 +2918,7 @@ default_read_result_init(flowdescr_t *flow,functdescr_t* f,void* data) ...@@ -2918,7 +2918,7 @@ default_read_result_init(flowdescr_t *flow,functdescr_t* f,void* data)
return -1; return -1;
} }
if(!flow->shm_base) { if(!flow->shm_base || flow->shm_base == (void *) -1) {
//Get pointer to shared memory //Get pointer to shared memory
id=shmget(shm->key, shm->buf_size, 660); id=shmget(shm->key, shm->buf_size, 660);
if(id<0) if(id<0)
...@@ -2928,13 +2928,13 @@ default_read_result_init(flowdescr_t *flow,functdescr_t* f,void* data) ...@@ -2928,13 +2928,13 @@ default_read_result_init(flowdescr_t *flow,functdescr_t* f,void* data)
return -1; return -1;
} }
if ((flow->shm_base=shmat(id, 0, FUNCTION_SHM_PERMS))==NULL) { if ((flow->shm_base=shmat(id, NULL, FUNCTION_SHM_PERMS))==(void *) -1) {
local_err = MAPI_SHM_ERR; local_err = MAPI_SHM_ERR;
return -1; return -1;
} }
} }
if(!flow->shm_spinlock) { if(!flow->shm_spinlock || flow->shm_spinlock == (void *) -1) {
//Get pointer to shared spinlock memory //Get pointer to shared spinlock memory
id=shmget(shm_spinlock->key, shm_spinlock->buf_size, 660); id=shmget(shm_spinlock->key, shm_spinlock->buf_size, 660);
if(id<0) if(id<0)
...@@ -2945,7 +2945,7 @@ default_read_result_init(flowdescr_t *flow,functdescr_t* f,void* data) ...@@ -2945,7 +2945,7 @@ default_read_result_init(flowdescr_t *flow,functdescr_t* f,void* data)
return -1; return -1;
} }
if ((flow->shm_spinlock=shmat(id, 0, FUNCTION_SHM_PERMS))==NULL) { if ((flow->shm_spinlock=shmat(id, NULL, FUNCTION_SHM_PERMS))==(void *) -1) {
local_err=MAPI_SHM_ERR; local_err=MAPI_SHM_ERR;
return -1; return -1;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment