*** empty log message ***

This commit is contained in:
glenux 2004-02-25 09:47:53 +00:00 committed by Glenn Y. Rolland
parent 833ceb23c9
commit c8f6efca31
4 changed files with 46 additions and 66 deletions

View file

@ -24,9 +24,12 @@ void * msgGet(msgSpace * space,int queueIndex,int option){
// on essaye donc de modifier la liste
msgQueueProtLock(space->externId,queueIndex);
msgQueueIdIntern(queueId,space->externId,queueIndex);
// ouvrir la file
// ouvrir la file
queue = msgQueueOpen(queueId);
if (queue==NULL){
NZG_ERROR("msgQueueOpen",queueId);
goto ERROR;
}
// recupérer l'id de l'ancien element...
msgQueueRem(queue, oldElemId);

View file

@ -40,6 +40,8 @@ int spaceListElemIdIntern(msgSpaceListElemId elemListId, msgSpaceId externId);
int msgPoolCreate(msgSpaceId externId, int poolIdx, int buffNb, int buffSize);
/* poolDataTabClose.c */
int msgPoolDataTabClose(msgSpace *space, void *addr);
/* poolDataTabCreate.c */
void *msgPoolDataTabCreate(msgSpace *space);
/* poolDataTabLock.c */
int msgPoolDataTabLock(msgSpace *space);
/* poolDataTabOpen.c */

View file

@ -21,19 +21,18 @@ msgSpace * msgSpaceCreate(
msgSpaceId nzgId;
/* msgSpaceList mSList; */
int mSFd; // shm file descriptor
int mSPoolDataFd; // shm file descriptor
int i;
int i;
static int mSIdNum=-1;
msgSpace * mSAddr;
msgSpace * space;
msgPoolDataTabId poolDataTabId;
msgPoolData * mSPoolDataAddr;
msgPoolData * poolDataTabAddr;
msgBufferInfoTabId bufferInfoTabId;
msgPoolId poolId;
sem_t * mSDataTabSemFd;
mSIdNum++;
mSAddr=NULL;
space=NULL;
/** recuperation de la liste des msgSpace **/
/* (creation si elle n'existe pas */
@ -54,114 +53,92 @@ msgSpace * msgSpaceCreate(
}
/* on redimentionne l'element */
if (ftruncate(mSFd, sizeof(* mSAddr)) == -1){
if (ftruncate(mSFd, sizeof(* space)) == -1){
fprintf( stderr, "msgSpace resizing failed: %s\n",
strerror( errno ) );
return NULL;
}
/* Map the memory object */
mSAddr = mmap( 0, sizeof( *mSAddr ),
space = mmap( 0, sizeof( *space ),
PROT_READ | PROT_WRITE,
MAP_SHARED, mSFd, 0 );
if( mSAddr == MAP_FAILED ) {
if( space == MAP_FAILED ) {
fprintf( stderr, "mmap failed: %s\n",
strerror( errno ) );
return NULL;
}
printf( "CREAT: msgSpace mapped to 0x%08x in %d\n", (int)mSAddr,(int)getpid());
printf( "CREAT: msgSpace mapped to 0x%08x in %d\n", (int)space,(int)getpid());
/* on ferme le descripteur du fichier */
close(mSFd);
/* on remplit la structure */
strncpy(mSAddr->id,externId,MSGSPACE_ID_LEN);
mSAddr->poolNb=poolNb;
mSAddr->queueNb=queueNb;
mSAddr->pid=getpid();
msgPoolDataTabSemIdIntern(mSAddr->poolDataTabSemId,externId);
strncpy(space->id,externId,MSGSPACE_ID_LEN);
space->poolNb=poolNb;
space->queueNb=queueNb;
space->pid=getpid();
msgPoolDataTabSemIdIntern(space->poolDataTabSemId,externId);
/* creation du poolData */
msgPoolDataIdIntern(poolDataTabId,externId);
strcpy(mSAddr->poolDataTabId,poolDataTabId);
strcpy(mSAddr->externId,externId);
strcpy(space->poolDataTabId,poolDataTabId);
strcpy(space->externId,externId);
mSDataTabSemFd=sem_open(mSAddr->poolDataTabSemId,
O_CREAT|O_EXCL,SEM_DEFAULT_MODE,1);
mSDataTabSemFd=sem_open(space->poolDataTabSemId,
O_CREAT|O_EXCL,SEM_DEFAULT_MODE,0);
if (mSDataTabSemFd == SEM_FAILED){
NZG_ERROR("sem_open : creation de la ressource",
mSAddr->poolDataTabSemId);
space->poolDataTabSemId);
return NULL;
} else {
NZG_ERROR("sem_open : creation oki",
mSAddr->poolDataTabSemId);
space->poolDataTabSemId);
}
sem_wait(mSDataTabSemFd);
sem_close(mSDataTabSemFd);
mSPoolDataFd=shm_open(
poolDataTabId,
O_RDWR|O_CREAT|O_EXCL|O_TRUNC,
MSGSPACE_DEFAULT_MODE
);
if (mSPoolDataFd == -1 ) {
fprintf( stderr, "poolData %s creation failed: %s\n",
(char*)poolDataTabId,
strerror( errno ) );
return NULL;
}
// msgPoolDataTabLock(space);
/* allocation de la bonne zone mémoire pour le poolData */
if (ftruncate(mSPoolDataFd, poolNb*sizeof(msgPoolData)) == -1){
fprintf( stderr, "msgSpace resizing failed: %s\n",
strerror( errno ) );
return NULL;
}
/* TODO: attacher chacun des msgPoolData :
* - y écrire les informations passées en param
* - creer les zones mémoires de chacune des pool
*/
mSPoolDataAddr = mmap( 0, sizeof( *mSAddr ),
PROT_READ | PROT_WRITE,
MAP_SHARED, mSFd, 0 );
if( mSPoolDataAddr == MAP_FAILED ) {
fprintf( stderr, "mmap failed: %s\n",
strerror( errno ) );
return NULL;
}
close(mSPoolDataFd);
printf( "msgPoolData map addr is 0x%08x\n", (int)mSPoolDataAddr );
/* attacher le tableau des msgPoolData */
poolDataTabAddr=msgPoolDataTabCreate(space);
for (i=0;i<poolNb;i++){
/* Pour chacun des poolData
* - y écrire les informations passées en param
* - creer les zones mémoires de chacune des pool
*/
// creation d'une pool
mSPoolDataAddr[i].bufferNb=poolInfos[i].bufferNb;
mSPoolDataAddr[i].bufferSize=poolInfos[i].bufferSize;
mSPoolDataAddr[i].allocDispBuffer=0;
poolDataTabAddr[i].bufferNb=poolInfos[i].bufferNb;
poolDataTabAddr[i].bufferSize=poolInfos[i].bufferSize;
poolDataTabAddr[i].allocDispBuffer=0;
if (msgBufferInfoTabIdIntern(bufferInfoTabId,externId,i) == -1){
fprintf( stderr, "msgBufferInfoTabId creation failed for id %s\n",
(char*)poolId );
return NULL;
}
strcpy(mSPoolDataAddr[i].bufferInfoTabId,bufferInfoTabId);
printf("buffIfoTab %d name : %s\n",i,mSPoolDataAddr[i].bufferInfoTabId);
msgBufferInfoTabCreate(externId,mSPoolDataAddr,i,poolInfos[i].bufferNb);
strcpy(poolDataTabAddr[i].bufferInfoTabId,bufferInfoTabId);
printf("buffIfoTab %d name : %s\n",i,poolDataTabAddr[i].bufferInfoTabId);
msgBufferInfoTabCreate(externId,poolDataTabAddr,i,poolInfos[i].bufferNb);
if (msgPoolIdIntern(poolId,externId,i) == -1){
fprintf( stderr, "msgPoolId creation failed for id %s\n",
(char*)poolId );
return NULL;
}
strcpy(mSPoolDataAddr[i].poolId,poolId);
strcpy(poolDataTabAddr[i].poolId,poolId);
msgPoolCreate(externId,i,poolInfos[i].bufferNb,poolInfos[i].bufferSize);
}
msgPoolDataTabClose(space,poolDataTabAddr);
/* 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;
msgPoolDataTabUnlock(space);
return space;
ERROR:
return NULL;
}

View file

@ -23,8 +23,6 @@ int main(void) {
pid_t pid=fork();
if (pid ==0){
mSPAC=msgSpaceOpen(testId);
sleep(2);