l3.libnazgul/src/spaceDelete.c
2004-03-07 12:53:25 +00:00

68 lines
1.5 KiB
C

#include "libnazgul.h"
#include "ids.h"
/* prototypes des fonctions annexes à ne pas exporter */
int msgSpaceIdIntern(msgSpaceId dest,const msgSpaceId src );
int msgPoolDataIdIntern(msgSpaceId dest,const msgSpaceId src );
int msgPoolDataTabSemIdIntern(
msgPoolSemId destSemId,const msgSpaceId externId);
int msgSpaceDelete(msgSpaceId externId){
//int shmId;
msgSpaceId nzgId;
msgSpace * space;
int i;
fprintf(stderr,"Deleting msgSpace with id : %s\n",externId);
if (msgSpaceIdIntern(nzgId,externId) == -1){
NZG_ERROR("msgSpaceIdIntern",externId);
goto ERROR;
}
space = msgSpaceOpen(externId);
/* 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");
return -1;
}
printf("ok\n");
printf("Unlinking DataTabSem... ");
if (sem_unlink(space->poolDataTabSemId) < 0){
NZG_ERROR("sem_unlink",space->poolDataTabSemId);
return -1;
}
printf("ok\n");
if (shm_unlink(nzgId)<0){
NZG_ERROR("shm_unlink",nzgId);
goto ERROR;
};
if (msgSpaceListLock()<0){
NZG_ERROR("msgSpaceListLock","");
goto ERROR;
}
if (msgSpaceListRem(nzgId) < 0){
NZG_ERROR("msgSpaceListRem",nzgId);
goto ERROR;
}
if (msgSpaceListUnlock()< 0){
NZG_ERROR("msgSpaceListUnlock","");
goto ERROR;
}
return 0;
ERROR:
return -1;
}