*** empty log message ***

This commit is contained in:
glenux 2004-02-26 09:23:37 +00:00 committed by Glenn Y. Rolland
parent b3a4623a26
commit 2c19490af5
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,8 +53,11 @@ 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);
queue = msgQueueOpen(queueId);
queueElemAddr = msgQueueElemOpen(queueElemId); if (strcmp(queue->headId,queue->id)!=0){
strcpy(nextIdToDie,queueElemAddr->id); // liste non-vide
msgQueueElemClose(queueElemAddr); if (msgQueueElemDelete(queue->headId) <0){
NZG_ERROR("msgQueueElemDelete",queue->headId);
if (shm_unlink(queueElemId) < 0){ goto ERROR;
NZG_ERROR("shm_unlink msgQueueElem",queueElemId); }
goto ERROR;
} }
if (strcmp(nextIdToDie,queueElemId)==0){ msgQueueSemId queueProtLockSemId;
return 0; msgQueueSemId queueReadLockSemId;
} else { msgQueueProtSemIdIntern(queueProtLockSemId,externId,queueIdx);
return msgQueueElemDelete(nextIdToDie); msgQueueReadSemIdIntern(queueReadLockSemId,externId,queueIdx);
sem_unlink(queueProtLockSemId);
sem_unlink(queueReadLockSemId);
if (shm_unlink(queueId) < 0){
NZG_ERROR("shm_unlink msgQueueElem",queueId);
goto ERROR;
} }
return 0;
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,19 +14,24 @@ 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");

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;
} }