*** empty log message ***

This commit is contained in:
glenux 2004-02-25 18:51:33 +00:00 committed by Glenn Y. Rolland
parent 1b14f53905
commit 30ca24acf8
7 changed files with 133 additions and 24 deletions

View file

@ -8,6 +8,12 @@
#define msgSpaceListId "/nzgSpaceList"
#endif
#ifdef _NZG_REALFILEID
#define msgSpaceListSemId "/tmp/nzgSpaceListSem"
#else
#define msgSpaceListSemId "/nzgSpaceListSem"
#endif
/* nzg_ids.c */
int msgSpaceIdIntern(msgSpaceId dest, const msgSpaceId src);

View file

@ -145,7 +145,7 @@ msgSpace * msgSpaceCreate(
msgPoolDataTabClose(space,poolDataTabAddr);
/* on ajoute spaceId a la liste des msgSpace connus */
msgSpaceListElemId listElemId;
//TODO: msgSpaceListInit();
msgSpaceListInit();
msgSpaceListLock();
msgSpaceListElemCreate(listElemId,space);
msgSpaceListAdd(listElemId);

14
src/spaceListClose.c Normal file
View file

@ -0,0 +1,14 @@
#include "libnazgul.h"
#include "ids.h"
int msgSpaceListClose(msgSpaceList * list){
if (munmap(list,sizeof(msgSpaceList)) < 0){
NZG_ERROR("unmap",msgSpaceListId);
goto ERROR;
}
return 0;
ERROR:
return -1;
}

18
src/spaceListElemClose.c Normal file
View file

@ -0,0 +1,18 @@
#include "libnazgul.h"
#include "ids.h"
int msgSpaceListElemClose(msgSpaceListElem * listElem)
{
msgSpaceListElemId eId;
strcpy(eId,listElem->id);
if (munmap(listElem,sizeof(msgSpaceListElem)) < 0){
NZG_ERROR("unmap",eId);
goto ERROR;
}
return 0;
ERROR:
return-1;
};

32
src/spaceListElemOpen.c Normal file
View file

@ -0,0 +1,32 @@
#include "libnazgul.h"
#include "ids.h"
// cree un nouvel elemen
void * msgSpaceListElemOpen(msgSpaceListElemId listElemId){
int listElemFd;
void * listElemAddr;
listElemFd=shm_open(listElemId,O_RDWR,SHM_DEFAULT_MODE);
if (listElemFd == -1 ) {
NZG_ERROR("shm_open : msgSpaceList open",listElemId);
goto ERROR;
}
listElemAddr=mmap(NULL,
sizeof(msgQueueElem),
PROT_READ|PROT_WRITE,
MAP_SHARED,
listElemFd,
0);
if( listElemAddr == MAP_FAILED ) {
NZG_ERROR("mmap",listElemId);
goto ERROR;
}
close(listElemFd);
return listElemAddr;
ERROR:
return NULL;
};

View file

@ -1,38 +1,47 @@
#include "libnazgul.h"
// fonction pour la creation d'une liste de msgSpace
// cree un shm qui connait l'element de debut de liste
// et l'element de fin de liste.
// il ne se crée que s'il n'en existe pas deja un.
//
// crée également un sémaphore de gestion de liste
// a verouiller avant toute modification
int msgSpaceListInit(){
int descMemory;
sem_t * spacesListSemFd;
msgSpaceListSemId spacesListSemId;
msgSpaceListElemId spacesListId;
/*Fait un segment de memoir partager sur espace de listelement*/
descMemory=shm_open(spacesListId,O_RDWR|O_CREAT|O_EXCL|O_TRUNC,0600);
if (descMemory == -1){
NZG_ERROR("shm_open",spacesListId);
return -1;
}
/*Creation de semaphore*/
spacesListSemFd=sem_open(spacesListSemId,O_CREAT|O_EXCL,0666,1024);
spacesListSemFd=sem_open(msgSpaceListSemId,O_CREAT|O_EXCL,0666,0);
if(spacesListSemFd==SEM_FAILED){
NZG_ERROR("sem_open",spacesListSemId);
return -1;
NZG_ERROR("sem_open",msgSpaceListSemId);
goto ERROR;
}
/*Verouille le semaphore*/
if(sem_wait(spacesListSemFd)==-1){
NZG_ERROR("sem_wait",spacesListSemId);
return -1;
/*Fait un segment de memoir partager sur espace de listelement*/
descMemory=shm_open(msgSpaceListId,O_RDWR|O_CREAT|O_EXCL|O_TRUNC,0600);
if (descMemory == -1){
descMemory=shm_open(msgSpaceListId,O_RDWR|O_TRUNC,0600);
if (descMemory == -1){
NZG_ERROR("shm_open",spacesListId);
goto ERROR;
} else {
close(descMemory);
goto EXISTING;
}
}
/*Creation de semaphore*/
spacesListSemFd=sem_open(spacesListSemId,O_CREAT|O_EXCL,0666,0);
if(spacesListSemFd==SEM_FAILED){
NZG_ERROR("sem_open",spacesListSemId);
goto ERROR;
}
msgSpaceListUnlock();
return 0;
ERROR:
return -1;
EXISTING:
return 0;
};

30
src/spaceListOpen.c Normal file
View file

@ -0,0 +1,30 @@
#include "libnazgul.h"
#include "ids.h"
void * msgSpaceListOpen(){
int listFd;
void * listAddr;
listFd=shm_open(msgSpaceListId,O_RDWR,SHM_DEFAULT_MODE);
if (listFd == -1 ) {
NZG_ERROR("shm_open : msgSpaceList open",msgSpaceListId);
goto ERROR;
}
listAddr=mmap(NULL,
sizeof(msgSpaceList),
PROT_READ|PROT_WRITE,
MAP_SHARED,
listFd,
0);
if( listAddr == MAP_FAILED ) {
NZG_ERROR("mmap",msgSpaceListId);
goto ERROR;
}
close(listFd);
return listAddr;
ERROR:
return NULL;
}