*** empty log message ***
This commit is contained in:
parent
1fac3384ee
commit
e8503824f6
3 changed files with 25 additions and 40 deletions
|
@ -3,69 +3,48 @@
|
||||||
|
|
||||||
int msgPoolDelete(
|
int msgPoolDelete(
|
||||||
msgSpaceId spaceId,
|
msgSpaceId spaceId,
|
||||||
int poolIdx,
|
int poolIdx
|
||||||
int buffNb,
|
|
||||||
int buffSize
|
|
||||||
) {
|
) {
|
||||||
|
|
||||||
int poolFd;
|
|
||||||
int bufferTabFd;
|
|
||||||
sem_t * ressourceSem;
|
|
||||||
msgPoolId poolId;
|
msgPoolId poolId;
|
||||||
msgBufferInfoTabId bufferInfoTabId;
|
msgBufferInfoTabId bufferInfoTabId;
|
||||||
msgPoolSemId poolRessourceSemId;
|
msgPoolSemId poolRessourceSemId;
|
||||||
|
|
||||||
|
|
||||||
/* creation des infos sur buffers DEBUT */
|
/* suppression des infos sur buffers DEBUT */
|
||||||
if (msgBufferInfoTabIdIntern(bufferInfoTabId,spaceId,poolIdx) == -1){
|
if (msgBufferInfoTabIdIntern(bufferInfoTabId,spaceId,poolIdx) == -1){
|
||||||
fprintf( stderr, "msgPoolId creation failed for id %s\n", (char*)poolId );
|
fprintf( stderr, "msgPoolId creation failed for id %s\n", (char*)poolId );
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
bufferTabFd=shm_open(bufferInfoTabId,O_RDWR|O_CREAT|O_EXCL|O_TRUNC,MSGSPACE_DEFAULT_MODE);
|
|
||||||
if (bufferTabFd == -1 ) {
|
if (shm_unlink(bufferInfoTabId) <0 ) {
|
||||||
fprintf( stderr, "msgInfoTab : %s creation failed: %s\n",bufferInfoTabId,
|
fprintf( stderr, "msgInfoTab : %s deletion failed: %s\n",bufferInfoTabId,
|
||||||
strerror( errno ) );
|
strerror( errno ) );
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (ftruncate(bufferTabFd, buffNb*sizeof(msgBufferInfo)) == -1){
|
/* suppression des infos sur buffers FIN */
|
||||||
fprintf( stderr, "msgBufferInfoTab resizing failed: %s\n",
|
|
||||||
strerror( errno ) );
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
/* creation des infos sur buffers FIN */
|
|
||||||
|
|
||||||
/* creation des buffers DEBUT */
|
/* suppression des buffers DEBUT */
|
||||||
if (msgPoolIdIntern(poolId,spaceId,poolIdx) == -1){
|
if (msgPoolIdIntern(poolId,spaceId,poolIdx) == -1){
|
||||||
fprintf( stderr, "msgPoolId creation failed for id %s\n", (char*)poolId );
|
fprintf( stderr, "msgPoolId creation failed for id %s\n", (char*)poolId );
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
poolFd=shm_open(poolId,O_RDWR|O_CREAT|O_EXCL|O_TRUNC,MSGSPACE_DEFAULT_MODE);
|
if (shm_unlink(poolId) <0 ) {
|
||||||
if (poolFd == -1 ) {
|
fprintf( stderr, "msgPool : %s deletion failed: %s\n",poolId,
|
||||||
fprintf( stderr, "msgPool : %s creation failed: %s\n",poolId,
|
|
||||||
strerror( errno ) );
|
strerror( errno ) );
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (ftruncate(poolFd, (buffSize*buffNb)) == -1){
|
/* suppression des buffers FIN */
|
||||||
fprintf( stderr, "msgPool resizing failed: %s\n",
|
|
||||||
strerror( errno ) );
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
/* creation des buffers FIN */
|
|
||||||
|
|
||||||
|
/* suppression de la sémaphore */
|
||||||
if (msgPoolSemIdIntern(poolRessourceSemId,spaceId,poolIdx) == -1){
|
if (msgPoolSemIdIntern(poolRessourceSemId,spaceId,poolIdx) == -1){
|
||||||
fprintf( stderr, "msgPoolId creation failed for id %s\n",
|
fprintf( stderr, "msgPoolId creation failed for id %s\n",
|
||||||
(char*)poolRessourceSemId );
|
(char*)poolRessourceSemId );
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// on met un semaphore sur le pool
|
// 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
|
//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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,5 +19,8 @@ int msgBufferInfoTabIdIntern(
|
||||||
msgBufferInfoTabId dest,
|
msgBufferInfoTabId dest,
|
||||||
msgSpaceId src,
|
msgSpaceId src,
|
||||||
int num);
|
int num);
|
||||||
|
int msgPoolDelete(
|
||||||
|
msgSpaceId spaceId,
|
||||||
|
int poolIdx
|
||||||
|
);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -5,19 +5,22 @@
|
||||||
int msgSpaceIdIntern(msgSpaceId dest,const msgSpaceId src );
|
int msgSpaceIdIntern(msgSpaceId dest,const msgSpaceId src );
|
||||||
int msgPoolDataIdIntern(msgSpaceId dest,const msgSpaceId src );
|
int msgPoolDataIdIntern(msgSpaceId dest,const msgSpaceId src );
|
||||||
|
|
||||||
int msgSpaceDelete(msgSpaceId spaceId){
|
int msgSpaceDelete(msgSpaceId externId){
|
||||||
fprintf(stderr,"Deleting msgSpace with id : %s\n",spaceId);
|
fprintf(stderr,"Deleting msgSpace with id : %s\n",externId);
|
||||||
//int shmId;
|
//int shmId;
|
||||||
msgSpaceId nzgId;
|
msgSpaceId nzgId;
|
||||||
msgSpace * space;
|
msgSpace * space;
|
||||||
if (msgSpaceIdIntern(nzgId,spaceId) == -1){
|
if (msgSpaceIdIntern(nzgId,externId) == -1){
|
||||||
//TODO: message d'erreur
|
//TODO: message d'erreur
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
space = msgSpaceOpen(spaceId);
|
space = msgSpaceOpen(externId);
|
||||||
/* TODO: supprimer chaque pool */
|
/* TODO: supprimer chaque pool */
|
||||||
|
int i;
|
||||||
|
for (i=0;i<space->poolNb;i++){
|
||||||
|
msgPoolDelete(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){
|
||||||
|
|
Loading…
Reference in a new issue