*** empty log message ***

This commit is contained in:
glenux 2004-02-25 22:30:43 +00:00 committed by Glenn Y. Rolland
parent 9d74ef30b6
commit 0d75ebe2e9
5 changed files with 91 additions and 44 deletions

View file

@ -188,7 +188,7 @@ if (mSPoolDataTabAddr==NULL){
int bufferFreeSize; int bufferFreeSize;
bufferFreeSize=mSPoolDataTabAddr[selectedPoolIndex].bufferSize; bufferFreeSize=mSPoolDataTabAddr[selectedPoolIndex].bufferSize;
printf("BufferSize : %d", bufferFreeSize); printf("BufferSize : %d\n", bufferFreeSize);
resultAddr=msgBufferMap(mSPoolDataTabAddr,selectedPoolIndex,bufferFreeIndex); resultAddr=msgBufferMap(mSPoolDataTabAddr,selectedPoolIndex,bufferFreeIndex);
if (resultAddr==NULL){ if (resultAddr==NULL){

View file

@ -21,7 +21,7 @@ msgSpace * msgSpaceCreate(
msgSpaceId nzgId; msgSpaceId nzgId;
/* msgSpaceList mSList; */ /* msgSpaceList mSList; */
int mSFd; // shm file descriptor int mSFd; // shm file descriptor
int i; int i;
static int mSIdNum=-1; static int mSIdNum=-1;
msgSpace * space; msgSpace * space;
@ -42,19 +42,34 @@ msgSpace * msgSpaceCreate(
return NULL; return NULL;
} }
msgSpaceListInit(); if (msgSpaceListInit() <0){
NZG_ERROR("msgSpaceListInit",nzgId);
goto ERROR;
};
printf("spaceListInit ok\n"); printf("spaceListInit ok\n");
msgSpaceListLock(); if (msgSpaceListLock() <0){
NZG_ERROR("msgSpaceListLock","");
goto ERROR;
}
printf("spaceListLock ok\n"); printf("spaceListLock ok\n");
if (msgSpaceListFindId(nzgId) < 1){ int err;
NZG_ERROR("spaceListFindId",nzgId); if ((err=msgSpaceListFindId(nzgId)) < 1){
if (err==0){
NZG_ERROR("spaceListFindId : existing ",nzgId);
} else {
NZG_ERROR("spaceListFindId : error ",nzgId);
}
msgSpaceListUnlock();
// zut, il y a soit une erreur // zut, il y a soit une erreur
// soit le msgSpace existe deja // soit le msgSpace existe deja
// on quitte // on quitte
goto ERROR; goto ERROR;
} }
printf("spaceListFind ok\n"); printf("spaceListFind ok\n");
msgSpaceListUnlock(); if (msgSpaceListUnlock() < 0){
NZG_ERROR("msgSpaceListUnlock","");
goto ERROR;
}
printf("spaceListUnlock ok\n"); printf("spaceListUnlock ok\n");
fprintf(stderr,"Creating msgSpace with id : %s\n",nzgId); fprintf(stderr,"Creating msgSpace with id : %s\n",nzgId);
@ -106,8 +121,8 @@ msgSpace * msgSpaceCreate(
space->poolDataTabSemId); space->poolDataTabSemId);
goto ERROR; goto ERROR;
} else { } else {
NZG_ERROR("sem_open : creation oki", /* NZG_ERROR("sem_open : creation oki",
space->poolDataTabSemId); space->poolDataTabSemId); */
} }
sem_close(mSDataTabSemFd); sem_close(mSDataTabSemFd);
@ -160,21 +175,21 @@ msgSpace * msgSpaceCreate(
} }
msgPoolDataTabClose(space,poolDataTabAddr); msgPoolDataTabClose(space,poolDataTabAddr);
/* on ajoute spaceId a la liste des msgSpace connus */ /* on ajoute spaceId a la liste des msgSpace connus */
msgSpaceListElemId listElemId; msgSpaceListElemId listElemId;
printf("spaceListInit...\n"); printf("spaceListInit...\n");
printf("ok\n"); printf("ok\n");
msgSpaceListLock(); msgSpaceListLock();
printf("spaceListLock...ok\n"); printf("spaceListLock...ok\n");
msgSpaceListElemCreate(listElemId,space); msgSpaceListElemCreate(listElemId,space);
printf("spaceListElemCreate...ok\n"); printf("spaceListElemCreate...ok\n");
msgSpaceListAdd(listElemId); msgSpaceListAdd(listElemId);
printf("spaceListAdd...ok\n"); printf("spaceListAdd...ok\n");
msgSpaceListUnlock(); msgSpaceListUnlock();
printf("spaceListUnlock...ok\n"); printf("spaceListUnlock...ok\n");
/* on renvoie un pointeur sur le bon spaceId */ /* on renvoie un pointeur sur le bon spaceId */
msgPoolDataTabUnlock(space); msgPoolDataTabUnlock(space);
return space; return space;
ERROR: ERROR:
return NULL; return NULL;

View file

@ -6,16 +6,21 @@
int msgSpaceListAdd(msgSpaceListElemId newElemId){ int msgSpaceListAdd(msgSpaceListElemId newElemId){
msgSpaceListElem * listOldTailElem; msgSpaceListElem * listOldTailElem;
msgSpaceListElem * listNewTailElem; msgSpaceListElem * listNewTailElem;
msgSpaceList * list=NULL; msgSpaceList * list;
list=msgSpaceListOpen(); list=msgSpaceListOpen();
if (list == NULL){
NZG_ERROR("msgSpaceListOpen","");
goto ERROR;
}
// on informe l'element qui est le dernier // on informe l'element qui est le dernier
listNewTailElem=msgSpaceListElemOpen(newElemId); listNewTailElem=msgSpaceListElemOpen(newElemId);
if (listNewTailElem==NULL){ if (listNewTailElem==NULL){
NZG_ERROR("msgSpaceListElemOpen",newElemId);
goto ERROR;
} }
strcpy(listNewTailElem->next,newElemId); strcpy(listNewTailElem->next,newElemId);
if (msgSpaceListElemClose(listNewTailElem) <0 ){ if (msgSpaceListElemClose(listNewTailElem) <0 ){
NZG_ERROR("msgSpaceListElemClose",newElemId); NZG_ERROR("msgSpaceListElemClose",newElemId);
goto ERROR; goto ERROR;
} }
@ -23,7 +28,7 @@ int msgSpaceListAdd(msgSpaceListElemId newElemId){
/* verifier si la liste n'est pas vide... */ /* verifier si la liste n'est pas vide... */
if((strcmp(list->headId,list->id)==0) if((strcmp(list->headId,list->id)==0)
&& (strcmp(list->tailId,list->id)==0)) { && (strcmp(list->tailId,list->id)==0)) {
printf("- premier elem de queue -\n"); printf("- premier elem de spaceList -\n");
// on donne a la queue l'id de l'element // on donne a la queue l'id de l'element
strcpy(list->headId,newElemId); strcpy(list->headId,newElemId);
strcpy(list->tailId,newElemId); strcpy(list->tailId,newElemId);

View file

@ -8,7 +8,6 @@ int msgSpaceListElemCreate(
{ {
msgSpaceListElemIdIntern(listElemId,space->externId); msgSpaceListElemIdIntern(listElemId,space->externId);
printf("Creating ListElem %s",listElemId);
int listElemFd; int listElemFd;
listElemFd=shm_open(listElemId, listElemFd=shm_open(listElemId,
@ -20,7 +19,7 @@ int msgSpaceListElemCreate(
goto ERROR; goto ERROR;
} }
if (ftruncate(listElemFd, sizeof(msgQueueElem)) < 0){ if (ftruncate(listElemFd, sizeof(msgSpaceListElem)) < 0){
NZG_ERROR("ftruncate", listElemId); NZG_ERROR("ftruncate", listElemId);
goto ERROR; goto ERROR;
} }
@ -28,9 +27,20 @@ int msgSpaceListElemCreate(
close(listElemFd); close(listElemFd);
msgSpaceListElem * listElem; msgSpaceListElem * listElem;
listElem=msgSpaceListElemOpen(listElemId); listElem=msgSpaceListElemOpen(listElemId);
if (listElem ==NULL){
NZG_ERROR("msgSpaceListElemOpen",listElemId);
goto ERROR;
}
strcpy(listElem->id,listElemId); strcpy(listElem->id,listElemId);
strcpy(listElem->next,listElemId);
strcpy(listElem->spaceId,space->id); strcpy(listElem->spaceId,space->id);
msgSpaceListElemClose(listElem); printf("[ ListElem : id %s,next: %s, Sid: %s ]\n",
listElem->id,
listElem->next,
listElem->spaceId);
if (msgSpaceListElemClose(listElem) <0){
NZG_ERROR("msgSpaceListElemClose",listElemId);
}
return 0; return 0;
ERROR: ERROR:
return -1; return -1;

View file

@ -15,17 +15,19 @@ int msgSpaceListInit(){
if(spaceListSemFd==SEM_FAILED){ if(spaceListSemFd==SEM_FAILED){
spaceListSemFd=sem_open(spaceListSemId,O_CREAT,0666,0); spaceListSemFd=sem_open(spaceListSemId,O_CREAT,0666,0);
if(spaceListSemFd==SEM_FAILED){ if(spaceListSemFd==SEM_FAILED){
NZG_ERROR("sem_open",spaceListSemId); NZG_ERROR("sem_open",spaceListSemId);
goto ERROR; goto ERROR;
}
} }
}
/*Fait un segment de memoir partager sur espace de listelement*/ /*Fait un segment de memoir partager sur espace de listelement*/
spaceListFd=shm_open(spaceListId,O_RDWR|O_CREAT|O_EXCL|O_TRUNC,0600); spaceListFd=shm_open(spaceListId,
O_RDWR|O_CREAT|O_EXCL|O_TRUNC,
0666);
if (spaceListFd == -1){ if (spaceListFd == -1){
spaceListFd=shm_open(spaceListId,O_RDWR|O_TRUNC,0600); spaceListFd=shm_open(spaceListId,O_RDWR,0666);
if (spaceListFd == -1){ if (spaceListFd == -1){
NZG_ERROR("shm_open",spaceListId); NZG_ERROR("shm_open",spaceListId);
goto ERROR; goto ERROR;
@ -34,25 +36,40 @@ int msgSpaceListInit(){
goto EXISTING; goto EXISTING;
} }
} }
if (ftruncate(spaceListFd, sizeof(msgSpaceList)) < 0){ if (ftruncate(spaceListFd, sizeof(msgSpaceList)) < 0){
NZG_ERROR("ftruncate",spaceListId); NZG_ERROR("ftruncate",spaceListId);
goto ERROR; goto ERROR;
} }
close(spaceListFd); close(spaceListFd);
msgSpaceList *list; msgSpaceList *list;
list=msgSpaceListOpen(); list=msgSpaceListOpen();
strcpy(list->id,spaceListId); if (list == NULL){
strcpy(list->headId,spaceListId); NZG_ERROR("msgSpaceListOpen","");
strcpy(list->tailId,spaceListId); goto ERROR;
msgSpaceListClose(list); }
strcpy(list->id,spaceListId);
msgSpaceListUnlock(); strcpy(list->headId,spaceListId);
strcpy(list->tailId,spaceListId);
if (msgSpaceListClose(list) <0){
NZG_ERROR("msgSpaceListClose","");
goto ERROR;
}
if (msgSpaceListUnlock() < 0){
NZG_ERROR("msgSpaceListUnlock","");
goto ERROR;
}
return 0; return 0;
ERROR: ERROR:
return -1; return -1;
EXISTING: EXISTING:
if (msgSpaceListUnlock() < 0){
NZG_ERROR("msgSpaceListUnlock","");
goto ERROR;
}
return 0; return 0;
}; };