*** empty log message ***

This commit is contained in:
glenux 2004-02-26 09:23:37 +00:00
parent 192f4486c9
commit ea81bb7613
8 changed files with 67 additions and 41 deletions

View file

@ -183,9 +183,6 @@ if (mSPoolDataTabAddr==NULL){
/* mapper le buffer libre dans l'esp addr du proc */ /* mapper le buffer libre dans l'esp addr du proc */
strcpy(resultPoolId,mSPoolDataTabAddr[selectedPoolIndex].poolId); strcpy(resultPoolId,mSPoolDataTabAddr[selectedPoolIndex].poolId);
/* mSPoolFd=shm_open(resultPoolId,O_RDWR,MSGSPACE_DEFAULT_MODE); */
int bufferFreeSize; int bufferFreeSize;
bufferFreeSize=mSPoolDataTabAddr[selectedPoolIndex].bufferSize; bufferFreeSize=mSPoolDataTabAddr[selectedPoolIndex].bufferSize;
printf("BufferSize : %d\n", bufferFreeSize); printf("BufferSize : %d\n", bufferFreeSize);

View file

@ -34,7 +34,10 @@ void * msgGet(msgSpace * space,int queueIndex,int option){
msgQueueRem(queue, oldElemId); msgQueueRem(queue, oldElemId);
oldElem = msgQueueElemOpen(oldElemId); oldElem = msgQueueElemOpen(oldElemId);
if (oldElem == NULL){
NZG_ERROR("msgQueueElemOpen",oldElemId);
goto ERROR;
}
/* on récupere la taille des buffer dans la pool du buffer */ /* on récupere la taille des buffer dans la pool du buffer */
msgPoolData * poolDataTab; msgPoolData * poolDataTab;
poolDataTab=msgPoolDataTabOpen(space); poolDataTab=msgPoolDataTabOpen(space);
@ -50,9 +53,12 @@ void * msgGet(msgSpace * space,int queueIndex,int option){
} }
msgPoolDataTabClose(space,poolDataTab); msgPoolDataTabClose(space,poolDataTab);
if (msgQueueElemClose(oldElem) <0){
NZG_ERROR("msgQueueElemClose",oldElemId);
}
shm_unlink(oldElemId);
// fermer la file // fermer la file
msgQueueClose(queue); msgQueueClose(queue);

View file

@ -57,7 +57,7 @@ int msgQueueAdd(msgQueue *queue, msgQueueElemId newElemId);
/* queueClose.c */ /* queueClose.c */
int msgQueueClose(msgQueue *queue); int msgQueueClose(msgQueue *queue);
/* queueDelete.c */ /* queueDelete.c */
int msgQueueElemDelete(msgQueueElemId queueElemId); int msgQueueDelete(msgQueueId externId, int queueIdx);
/* queueElemClose.c */ /* queueElemClose.c */
int msgQueueElemClose(msgQueueElem *queueElem); int msgQueueElemClose(msgQueueElem *queueElem);
/* queueElemCreate.c */ /* queueElemCreate.c */
@ -108,7 +108,7 @@ int msgSpaceListUnlock(void);
/* spaceListOpen.c */ /* spaceListOpen.c */
void *msgSpaceListOpen(void); void *msgSpaceListOpen(void);
/* spaceListRem.c */ /* spaceListRem.c */
int msgSpaceListRem(msgSpaceListElemId oldElemId); int msgSpaceListRem(msgSpaceId spaceId);
/* spaceOpen.c */ /* spaceOpen.c */
msgSpace *msgSpaceOpen(msgSpaceId externId); msgSpace *msgSpaceOpen(msgSpaceId externId);
/* state.c */ /* state.c */

View file

@ -1,26 +1,33 @@
#include "libnazgul.h" #include "libnazgul.h"
int msgQueueElemDelete(msgQueueElemId queueElemId){ int msgQueueDelete(msgQueueId externId,int queueIdx){
msgQueueElem * queueElemAddr; msgQueue * queue;
msgQueueElemId nextIdToDie; msgQueueId queueId;
msgQueueIdIntern(queueId,externId,queueIdx);
queueElemAddr = msgQueueElemOpen(queueElemId); queue = msgQueueOpen(queueId);
strcpy(nextIdToDie,queueElemAddr->id);
msgQueueElemClose(queueElemAddr); if (strcmp(queue->headId,queue->id)!=0){
// liste non-vide
if (shm_unlink(queueElemId) < 0){ if (msgQueueElemDelete(queue->headId) <0){
NZG_ERROR("shm_unlink msgQueueElem",queueElemId); NZG_ERROR("msgQueueElemDelete",queue->headId);
goto ERROR; goto ERROR;
}
}
msgQueueSemId queueProtLockSemId;
msgQueueSemId queueReadLockSemId;
msgQueueProtSemIdIntern(queueProtLockSemId,externId,queueIdx);
msgQueueReadSemIdIntern(queueReadLockSemId,externId,queueIdx);
sem_unlink(queueProtLockSemId);
sem_unlink(queueReadLockSemId);
if (shm_unlink(queueId) < 0){
NZG_ERROR("shm_unlink msgQueueElem",queueId);
goto ERROR;
} }
if (strcmp(nextIdToDie,queueElemId)==0){ return 0;
return 0;
} else {
return msgQueueElemDelete(nextIdToDie);
}
ERROR: ERROR:
return -1; return -1;
} }

View file

@ -1,25 +1,30 @@
#include "libnazgul.h" #include "libnazgul.h"
int msgQueueElemDelete(msgQueueElemId queueElemId){ int msgQueueElemDelete(msgQueueElemId queueElemId){
msgQueueElem * queueElemAddr; msgQueueElem * queueElem;
msgQueueElemId nextIdToDie; msgQueueElemId nextIdToDie;
queueElemAddr = msgQueueElemOpen(queueElemId); queueElem = msgQueueElemOpen(queueElemId);
if (queueElemAddr==NULL){ if (queueElem==NULL){
NZG_ERROR("msgQueueElemOpen",queueElemId); NZG_ERROR("msgQueueElemOpen",queueElemId);
goto ERROR; goto ERROR;
} }
strcpy(nextIdToDie, queueElemAddr->next); strcpy(nextIdToDie, queueElem->next);
if (msgQueueElemClose(queueElemAddr) < 0){ if (msgQueueElemClose(queueElem) < 0){
NZG_ERROR("msgQueueElemClose",queueElemId); NZG_ERROR("msgQueueElemClose",queueElemId);
goto ERROR; goto ERROR;
} }
// on détruit l'élément
shm_unlink(queueElemId);
if (nextIdToDie != queueElemId){ if (nextIdToDie != queueElemId){
return msgQueueElemDelete(nextIdToDie); return msgQueueElemDelete(nextIdToDie);
} else { } else {
printf("msgQueueElemDelete: EOL reached \n");
// element unique...
return 0; return 0;
} }

View file

@ -20,6 +20,9 @@ int msgQueueRem(msgQueue * queue, msgQueueElemId oldElemId){
// on indique à la queue le nouveau premier element // on indique à la queue le nouveau premier element
strcpy(queue->headId,queueOldHeadElem->next); strcpy(queue->headId,queueOldHeadElem->next);
if (strcmp(queueOldHeadElem->next,oldElemId)==0){
strcpy(queue->headId,queue->id);
}
// on fait en sorte que l'element ne connaisse plus // on fait en sorte que l'element ne connaisse plus
// ses voisins (utile pour le Delete) // ses voisins (utile pour le Delete)
strcpy(queueOldHeadElem->next,queueOldHeadElem->id); strcpy(queueOldHeadElem->next,queueOldHeadElem->id);
@ -29,8 +32,7 @@ int msgQueueRem(msgQueue * queue, msgQueueElemId oldElemId){
goto ERROR; goto ERROR;
} }
return 0;
return 0;
ERROR: ERROR:
return -1; return -1;
} }

View file

@ -14,23 +14,28 @@ int msgSpaceDelete(msgSpaceId externId){
msgSpace * space; msgSpace * space;
int i; int i;
if (msgSpaceIdIntern(nzgId,externId) == -1){ if (msgSpaceIdIntern(nzgId,externId) == -1){
//TODO: message d'erreur NZG_ERROR("msgSpaceIdIntern",externId);
return -1; goto ERROR;
} }
space = msgSpaceOpen(externId); space = msgSpaceOpen(externId);
/* TODO: supprimer chaque pool */ /* supprimer chaque pool */
for (i=0;i<space->poolNb;i++){ for (i=0;i<space->poolNb;i++){
msgPoolDelete(externId,i); msgPoolDelete(externId,i);
} }
/* supprimer chaque queue */
for (i=0;i<space->queueNb;i++){
msgQueueDelete(externId,i);
}
printf("openned successfully !\n"); printf("openned successfully !\n");
printf("Unlinking DataTab... "); printf("Unlinking DataTab... ");
if (shm_unlink(space->poolDataTabId) < 0){ if (shm_unlink(space->poolDataTabId) < 0){
perror("shm_unlink"); perror("shm_unlink");
return -1; return -1;
} }
printf("ok\n"); printf("ok\n");
printf("Unlinking DataTabSem... "); printf("Unlinking DataTabSem... ");
if (sem_unlink(space->poolDataTabSemId) < 0){ if (sem_unlink(space->poolDataTabSemId) < 0){
NZG_ERROR("sem_unlink",space->poolDataTabSemId); NZG_ERROR("sem_unlink",space->poolDataTabSemId);
@ -46,7 +51,7 @@ int msgSpaceDelete(msgSpaceId externId){
NZG_ERROR("msgSpaceListLock",""); NZG_ERROR("msgSpaceListLock","");
goto ERROR; goto ERROR;
} }
if (msgSpaceListRem(nzgId) < 0){ if (msgSpaceListRem(nzgId) < 0){
NZG_ERROR("msgSpaceListRem",nzgId); NZG_ERROR("msgSpaceListRem",nzgId);
goto ERROR; goto ERROR;

View file

@ -28,6 +28,8 @@ int main(void) {
printf("CREATION ------------------ ok\n"); printf("CREATION ------------------ ok\n");
mSPAC=msgSpaceOpen(testId); mSPAC=msgSpaceOpen(testId);
/***** TEST 1 *****/
montext=msgAllocate(mSPAC,1,280,0); montext=msgAllocate(mSPAC,1,280,0);
*montext=42; *montext=42;
printf("### test Valeur0 %d ###\n",(int)*montext); printf("### test Valeur0 %d ###\n",(int)*montext);
@ -40,6 +42,8 @@ int main(void) {
montext=msgGet(mSPAC,0,0); montext=msgGet(mSPAC,0,0);
printf("get-ok\n"); printf("get-ok\n");
printf("### test Reception %d ###\n",(int)*montext); printf("### test Reception %d ###\n",(int)*montext);
msgFree(mSPAC,montext);
/***** TEST 1 *****/
msgSpaceDelete(testId); msgSpaceDelete(testId);
return 0; return 0;
} }