*** 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 */
strcpy(resultPoolId,mSPoolDataTabAddr[selectedPoolIndex].poolId);
/* mSPoolFd=shm_open(resultPoolId,O_RDWR,MSGSPACE_DEFAULT_MODE); */
int bufferFreeSize;
bufferFreeSize=mSPoolDataTabAddr[selectedPoolIndex].bufferSize;
printf("BufferSize : %d\n", bufferFreeSize);

View file

@ -34,7 +34,10 @@ void * msgGet(msgSpace * space,int queueIndex,int option){
msgQueueRem(queue, 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 */
msgPoolData * poolDataTab;
poolDataTab=msgPoolDataTabOpen(space);
@ -50,8 +53,11 @@ void * msgGet(msgSpace * space,int queueIndex,int option){
}
msgPoolDataTabClose(space,poolDataTab);
if (msgQueueElemClose(oldElem) <0){
NZG_ERROR("msgQueueElemClose",oldElemId);
}
shm_unlink(oldElemId);
// fermer la file
msgQueueClose(queue);

View file

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

View file

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

View file

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

View file

@ -20,6 +20,9 @@ int msgQueueRem(msgQueue * queue, msgQueueElemId oldElemId){
// on indique à la queue le nouveau premier element
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
// ses voisins (utile pour le Delete)
strcpy(queueOldHeadElem->next,queueOldHeadElem->id);
@ -29,8 +32,7 @@ int msgQueueRem(msgQueue * queue, msgQueueElemId oldElemId){
goto ERROR;
}
return 0;
return 0;
ERROR:
return -1;
}

View file

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

View file

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