*** empty log message ***

This commit is contained in:
glenux 2004-02-23 10:33:14 +00:00
parent 0857256f59
commit 6ed1e89455
3 changed files with 20 additions and 94 deletions

View file

@ -1,82 +0,0 @@
/*void *add(char * idAncien, char *idNouveau);
int descMemory;
void * add(char * idAncien, char *idNouveau){
descMemory=shm_open("/titi",
O_RDWR|O_CREAT|O_EXCL|O_TRUNC,
0600);
if (descMemory== -1){
printf("erreur de sh_open\n");
return NULL;
};
if (ftruncate(descMemory,1024)== -1 ){
printf("erreur ftruncate");
}
memory= mmap(0, 1024,
PROT_READ | PROT_WRITE,
MAP_SHARED, mSFd, 0)*/
/*typedef struct MsgSpaceListElem {
void * id;
int ownerPid;
msgSpaceListElemId next;
} * msgSpaceList, msgSpaceListElem;
msgSpaceListElemId *mslist;
if( Strcpy(idAncien, idNouveau) ==-1){
printf("erreur de strcpy");
};
strcpy(idAncien, idNouveau);
return NULL;
}
*/
/* ajout dans la liste */
/*AVEC POINTEUR */
/*
msgSpaceListElem *addBegining( msgSpaceListElem*list,int ownerpid){
msgSpaceListElem *unSpacemsgListElem;
if( (unSpacemsgListElem=(msgSpaceListElem *)malloc(sizeof(msgSpaceListElem) ) )==NULL){
perror("ereur dallocation de memoire");
exit(1);}
unSpacemsgListElem->ownerPid = ownerpid;
return(unSpacemsgListElem);
}
int test(int argc,char **argv){
msgSpaceListElem *ma_liste;
msgSpaceListElem *listMove;
ma_liste=NULL;
ma_liste=addBegining(ma_liste, 3);
ma_liste=addBegining(ma_liste, 6);
ma_liste=addBegining(ma_liste, 5);
for (listMove=ma_liste ;listMove!=NULL ; listMove=listMove->next)
{
printf("valaeur :%d\n",listMove->ownerPid);
}
return(0);
}
*/

View file

@ -4,7 +4,8 @@
/* 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);
/*
* spaceId : identifiant externe de l'espace de msg
* queueNb : nombre de files de messages
@ -29,7 +30,7 @@ msgSpace * msgSpaceCreate(
msgPoolData * mSPoolDataAddr;
msgBufferInfoTabId bufferInfoTabId;
msgPoolId poolId;
sem_t * mSDataTabSemFd;
mSIdNum++;
mSAddr=NULL;
@ -79,11 +80,23 @@ msgSpace * msgSpaceCreate(
mSAddr->poolNb=poolNb;
mSAddr->queueNb=queueNb;
mSAddr->pid=getpid();
msgPoolDataTabSemIdIntern(mSAddr->poolDataTabSemId,externId);
/* creation du poolData */
msgPoolDataIdIntern(poolDataTabId,externId);
strcpy(mSAddr->poolDataTabId,poolDataTabId);
mSDataTabSemFd=sem_open(mSAddr->poolDataTabSemId,
O_CREAT|O_EXCL,SEM_DEFAULT_MODE,1);
if (mSDataTabSemFd == SEM_FAILED){
NZG_ERROR("sem_open : creation de la ressource",
mSAddr->poolDataTabSemId);
return NULL;
} else {
NZG_ERROR("sem_open : creation oki",
mSAddr->poolDataTabSemId);
}
sem_wait(mSDataTabSemFd);
mSPoolDataFd=shm_open(
poolDataTabId,
O_RDWR|O_CREAT|O_EXCL|O_TRUNC,
@ -133,9 +146,9 @@ msgSpace * msgSpaceCreate(
printf("buffIfoTab %d name : %s\n",i,mSPoolDataAddr[i].bufferInfoTabId);
msgBufferInfoTabCreate(externId,mSPoolDataAddr,i,poolInfos[i].bufferNb);
if (msgPoolIdIntern(poolId,externId,i) == -1){
if (msgPoolIdIntern(poolId,externId,i) == -1){
fprintf( stderr, "msgPoolId creation failed for id %s\n",
(char*)poolId );
(char*)poolId );
return NULL;
}
strcpy(mSPoolDataAddr[i].id,poolId);
@ -146,6 +159,7 @@ msgSpace * msgSpaceCreate(
/* TODO: on ajoute spaceId a la liste des msgSpace connus */
/* TODO: on crée queueNb files de messages */
/* on renvoie un pointeur sur le bon spaceId */
sem_post(mSDataTabSemFd);
return mSAddr;
}

View file

@ -15,7 +15,7 @@ int main(void) {
poolInfos[1].bufferNb=5;
poolInfos[1].bufferSize=250;
poolInfos[2].bufferNb=3;
poolInfos[2].bufferNb=6;
poolInfos[2].bufferSize=280;
strcpy(testId,"test");
@ -31,24 +31,18 @@ int main(void) {
mSPAC=msgSpaceOpen(testId);
sleep(2);
montext=msgAllocate(mSPAC,2,180,0);
printf("ALLOC %d.. ok\n",(int)getpid());
sleep(2);
montext=msgAllocate(mSPAC,2,170,0);
printf("ALLOC %d.. ok\n",(int)getpid());
sleep(2);
montext=msgAllocate(mSPAC,2,270,0);
printf("ALLOC %d.. ok\n",(int)getpid());
} else {
mSPAC=msgSpaceOpen(testId);
montext=msgAllocate(mSPAC,2,280,0);
printf("ALLOC %d.. ok\n",(int)getpid());
sleep(2);
montext=msgAllocate(mSPAC,2,270,0);
printf("ALLOC %d.. ok\n",(int)getpid());
sleep(2);
montext=msgAllocate(mSPAC,2,270,0);
printf("ALLOC %d.. ok\n",(int)getpid());
//msgFree(mSPAC,(void *)montext);
//msgFree(mSPAC,(void *)montext);
//msgFree(mSPAC,(void *)montext);