*** empty log message ***

This commit is contained in:
glenux 2004-02-26 10:37:42 +00:00 committed by Glenn Y. Rolland
parent cf8073ca65
commit 00e9da5c2c
3 changed files with 113 additions and 4 deletions

15
src/spaceClose.c Normal file
View file

@ -0,0 +1,15 @@
#include "libnazgul.h"
int msgSpaceClose(msgSpace * space){
msgSpaceId spaceId;
strcpy(spaceId,space->id);
if (munmap(space,sizeof(msgSpace)) < 0){
NZG_ERROR("unmap",spaceId);
goto ERROR;
}
return 0;
ERROR:
return -1;
}

View file

@ -33,11 +33,11 @@ int main(void) {
if (pid ==0){ if (pid ==0){
mSPAC=msgSpaceOpen(testId); mSPAC=msgSpaceOpen(testId);
sleep(2); sleep(5);
montext=msgAllocate(mSPAC,2,180,0); montext=msgAllocate(mSPAC,2,180,0);
sleep(2); sleep(5);
montext=msgAllocate(mSPAC,2,170,0); montext=msgAllocate(mSPAC,2,170,0);
sleep(2); sleep(5);
montext=msgAllocate(mSPAC,2,270,0); montext=msgAllocate(mSPAC,2,270,0);
} else { } else {
@ -49,7 +49,7 @@ int main(void) {
montext=msgAllocate(mSPAC,2,270,0); montext=msgAllocate(mSPAC,2,270,0);
*montext=17; *montext=17;
printf("### test Valeur1 %d ###\n",(int)*montext); printf("### test Valeur1 %d ###\n",(int)*montext);
sleep(2); sleep(5);
montext=msgAllocate(mSPAC,2,270,0); montext=msgAllocate(mSPAC,2,270,0);
msgFree(mSPAC,(void *)montext); msgFree(mSPAC,(void *)montext);
//msgFree(mSPAC,(void *)montext); //msgFree(mSPAC,(void *)montext);

94
test/msgSpaceState.c Normal file
View file

@ -0,0 +1,94 @@
#include <wait.h>
#include "libnazgul.h"
void usage(char * myname){
printf("Usage: %s [--all | msgSpaceId1 msgSpaceId2 ... ]\n",myname);
}
int about(char * spaceId){
msgPoolDataTabSemId ressourceSemId;
sem_t * ressourceSemFd;
int i;
msgPoolData * poolDataTab;
msgSpace * space;
int ressourceSemVal;
if (strlen(spaceId)> MSGSPACE_ID_LEN){
//verif de la longueur
fprintf(stderr,"Too long ident : %s\n",spaceId);
goto ERROR;
} else {
int err;
msgSpaceListLock();
err=msgSpaceListFindId(spaceId);
msgSpaceListUnlock();
if (err < 1){
if (err==0){
// le msgSpace existe
space=msgSpaceOpen(spaceId);
// on lit les informations sur le msgSpace
// les pool
for (i=0;i<space->poolNb;i++){
msgPoolSemIdIntern(ressourceSemId,space->externId,i);
ressourceSemFd = sem_open(ressourceSemId,O_CREAT,SEM_DEFAULT_MODE,0);
if (ressourceSemFd == SEM_FAILED){
NZG_ERROR("sem_open",ressourceSemId);
goto ERROR;
}
if (sem_getvalue(ressourceSemFd, &ressourceSemVal) < 0){
NZG_ERROR("sem_getvalue",ressourceSemId);
goto ERROR;
}
//msgPoolDataTabLock(space);
//msgPoolDataTabUnlock(space);
poolDataTab= msgPoolDataTabOpen(space);
// donner le nombre de buffer disponibles
printf("- %d/%d free buffers in pool #%d\n",
ressourceSemVal,
poolDataTab[i].bufferNb,
i);
msgPoolDataTabClose(space,poolDataTab);
if(sem_close(ressourceSemFd) <0){
NZG_ERROR("sem_getvalue",ressourceSemId);
goto ERROR;
}
// pour chaque buffer, dire s'il est libre ou pas
// et le processus/addresse associé
}
msgSpaceClose(space);
} else {
// zut, il y a soit une erreur
NZG_ERROR("spaceListFindId : error ",spaceId);
}
// on quitte : l'element n'existe
fprintf(stderr,"Ident %s does not exist.\n",spaceId);
}
}
return 0;
ERROR:
return -1;
}
int main(int argc,char **argv){
printf("Args %d\n",argc);
if (argc<2){
usage(argv[0]);
}else {
if (argc==2){
if (strcmp("--all",argv[1])==0){
// listing
printf("[ Listing of msgSpaces ]\n");
} else {
// only one msgSpaceId
printf("[ About %s ]\n",argv[1]);
about(argv[1]);
}
} else {
int i;
for (i=1;i<argc;i++){
printf("[ About %s ]\n",argv[i]);
about(argv[i]);
}
}
}
return 0;
}