l3.libnazgul/src/spaceDelete.c

48 lines
1.1 KiB
C
Raw Normal View History

2004-02-22 11:50:29 +00:00
#include "libnazgul.h"
2004-02-23 18:50:52 +00:00
#include "ids.h"
2004-02-22 11:50:29 +00:00
/* prototypes des fonctions annexes <20> ne pas exporter */
int msgSpaceIdIntern(msgSpaceId dest,const msgSpaceId src );
int msgPoolDataIdIntern(msgSpaceId dest,const msgSpaceId src );
2004-02-23 13:07:36 +00:00
int msgPoolDataTabSemIdIntern(
msgPoolSemId destSemId,const msgSpaceId externId);
2004-02-22 11:50:29 +00:00
2004-02-22 13:37:04 +00:00
int msgSpaceDelete(msgSpaceId externId){
fprintf(stderr,"Deleting msgSpace with id : %s\n",externId);
2004-02-22 11:50:29 +00:00
//int shmId;
msgSpaceId nzgId;
msgSpace * space;
int i;
2004-02-22 13:37:04 +00:00
if (msgSpaceIdIntern(nzgId,externId) == -1){
2004-02-22 11:50:29 +00:00
//TODO: message d'erreur
return -1;
}
2004-02-22 13:37:04 +00:00
space = msgSpaceOpen(externId);
2004-02-22 11:50:29 +00:00
/* TODO: supprimer chaque pool */
2004-02-22 13:37:04 +00:00
for (i=0;i<space->poolNb;i++){
msgPoolDelete(externId,i);
}
2004-02-22 11:50:29 +00:00
printf("openned successfully !\n");
printf("Unlinking DataTab... ");
if (shm_unlink(space->poolDataTabId) < 0){
perror("shm_unlink");
return -1;
}
printf("ok\n");
2004-02-23 13:07:36 +00:00
printf("Unlinking DataTabSem... ");
if (sem_unlink(space->poolDataTabSemId) < 0){
NZG_ERROR("sem_unlink",space->poolDataTabSemId);
return -1;
}
printf("ok\n");
2004-02-22 11:50:29 +00:00
if (shm_unlink(nzgId)<0){
perror("shm_unlink");
return -1;
};
return 0;
}