*** empty log message ***

This commit is contained in:
glenux 2004-02-22 13:37:04 +00:00 committed by Glenn Y. Rolland
parent 160848d1f9
commit 584a3a4d24
3 changed files with 25 additions and 40 deletions

View file

@ -3,69 +3,48 @@
int msgPoolDelete(
msgSpaceId spaceId,
int poolIdx,
int buffNb,
int buffSize
int poolIdx
) {
int poolFd;
int bufferTabFd;
sem_t * ressourceSem;
msgPoolId poolId;
msgBufferInfoTabId bufferInfoTabId;
msgPoolSemId poolRessourceSemId;
/* creation des infos sur buffers DEBUT */
/* suppression des infos sur buffers DEBUT */
if (msgBufferInfoTabIdIntern(bufferInfoTabId,spaceId,poolIdx) == -1){
fprintf( stderr, "msgPoolId creation failed for id %s\n", (char*)poolId );
return -1;
}
bufferTabFd=shm_open(bufferInfoTabId,O_RDWR|O_CREAT|O_EXCL|O_TRUNC,MSGSPACE_DEFAULT_MODE);
if (bufferTabFd == -1 ) {
fprintf( stderr, "msgInfoTab : %s creation failed: %s\n",bufferInfoTabId,
if (shm_unlink(bufferInfoTabId) <0 ) {
fprintf( stderr, "msgInfoTab : %s deletion failed: %s\n",bufferInfoTabId,
strerror( errno ) );
return -1;
}
if (ftruncate(bufferTabFd, buffNb*sizeof(msgBufferInfo)) == -1){
fprintf( stderr, "msgBufferInfoTab resizing failed: %s\n",
strerror( errno ) );
return -1;
}
/* creation des infos sur buffers FIN */
/* suppression des infos sur buffers FIN */
/* creation des buffers DEBUT */
/* suppression des buffers DEBUT */
if (msgPoolIdIntern(poolId,spaceId,poolIdx) == -1){
fprintf( stderr, "msgPoolId creation failed for id %s\n", (char*)poolId );
return -1;
}
poolFd=shm_open(poolId,O_RDWR|O_CREAT|O_EXCL|O_TRUNC,MSGSPACE_DEFAULT_MODE);
if (poolFd == -1 ) {
fprintf( stderr, "msgPool : %s creation failed: %s\n",poolId,
if (shm_unlink(poolId) <0 ) {
fprintf( stderr, "msgPool : %s deletion failed: %s\n",poolId,
strerror( errno ) );
return -1;
}
if (ftruncate(poolFd, (buffSize*buffNb)) == -1){
fprintf( stderr, "msgPool resizing failed: %s\n",
strerror( errno ) );
return -1;
}
/* creation des buffers FIN */
/* suppression des buffers FIN */
/* suppression de la sémaphore */
if (msgPoolSemIdIntern(poolRessourceSemId,spaceId,poolIdx) == -1){
fprintf( stderr, "msgPoolId creation failed for id %s\n",
(char*)poolRessourceSemId );
return -1;
}
// on met un semaphore sur le pool
ressourceSem = sem_open(poolRessourceSemId, O_CREAT|O_EXCL, 0666, buffNb);
sem_unlink(poolRessourceSemId);
//TODO: verrifier les erreurs sur l'ouverture de la sem
// on met le pool a la taille voulue pour qu'il
// puisse contenir les buffs
close(poolFd);
return 0;
}

View file

@ -19,5 +19,8 @@ int msgBufferInfoTabIdIntern(
msgBufferInfoTabId dest,
msgSpaceId src,
int num);
int msgPoolDelete(
msgSpaceId spaceId,
int poolIdx
);
#endif

View file

@ -5,19 +5,22 @@
int msgSpaceIdIntern(msgSpaceId dest,const msgSpaceId src );
int msgPoolDataIdIntern(msgSpaceId dest,const msgSpaceId src );
int msgSpaceDelete(msgSpaceId spaceId){
fprintf(stderr,"Deleting msgSpace with id : %s\n",spaceId);
int msgSpaceDelete(msgSpaceId externId){
fprintf(stderr,"Deleting msgSpace with id : %s\n",externId);
//int shmId;
msgSpaceId nzgId;
msgSpace * space;
if (msgSpaceIdIntern(nzgId,spaceId) == -1){
if (msgSpaceIdIntern(nzgId,externId) == -1){
//TODO: message d'erreur
return -1;
}
space = msgSpaceOpen(spaceId);
space = msgSpaceOpen(externId);
/* TODO: supprimer chaque pool */
int i;
for (i=0;i<space->poolNb;i++){
msgPoolDelete(externId,i);
}
printf("openned successfully !\n");
printf("Unlinking DataTab... ");
if (shm_unlink(space->poolDataTabId) < 0){