*** empty log message ***

This commit is contained in:
glenux 2004-02-19 21:32:42 +00:00
parent 0b009e000a
commit 983b901a53
2 changed files with 61 additions and 44 deletions

View file

@ -62,8 +62,10 @@ msgPool * msgPoolAllocate(int poolIdx, msgSpace *msg) {
// TODO:récupérer l'id du poolData dans le msgSpace // TODO:récupérer l'id du poolData dans le msgSpace
// détacher le morceau de mémoire du processus // détacher le morceau de mémoire du processus
// TODO:récupérer l'id de la pool (poolIdx) qui nous intéresse // TODO:récupérer le poolData qui correspond à notre poolIdx.
// ouvrir la // attacher la zone mémoire correspondant à l'Id
// utiliser des sémaphores pour vérouiller les acces en modif
// sur la poolData de notre
//msgSpacePoolData spoolData; //msgSpacePoolData spoolData;
//dataId = msg->poolDataId; //dataId = msg->poolDataId;

View file

@ -1,6 +1,9 @@
#include "libnazgul.h" #include "libnazgul.h"
/* prototypes des fonctions annexes à ne pas exporter */ /* prototypes des f#define MSGSPACE_DEFAULT_MODE 0600
#define MSGSPACE_ID_LEN 32
onctions annexes à ne pas exporter */
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 );
@ -22,16 +25,16 @@ msgSpace * msgSpaceCreate(
int i; int i;
static int mSIdNum=-1; static int mSIdNum=-1;
msgSpace * mSAddr; msgSpace * mSAddr;
msgSpacePoolId poolDataId; msgSpacePoolId poolDataId;
msgPoolData * mSPoolDataAddr; msgPoolData * mSPoolDataAddr;
fprintf(stderr,"Creating msgSpace with id : %s\n",spaceId); fprintf(stderr,"Creating msgSpace with id : %s\n",spaceId);
mSIdNum++; mSIdNum++;
mSAddr=NULL; mSAddr=NULL;
/** recuperation de la liste des msgSpace **/ /** recuperation de la liste des msgSpace **/
/* (creation si elle n'existe pas */ /* (creation si elle n'existe pas */
/** on créee le nouvel element **/ /** on créee le nouvel element **/
printf("PAGESIZE : %d\n",(int)PAGESIZE); printf("PAGESIZE : %d\n",(int)PAGESIZE);
@ -46,7 +49,7 @@ msgSpace * msgSpaceCreate(
); );
if (mSFd == -1 ) { if (mSFd == -1 ) {
fprintf( stderr, "msgSpace %s creation failed: %s\n", fprintf( stderr, "msgSpace %s creation failed: %s\n",
(char*)nzgId, (char*)nzgId,
strerror( errno ) ); strerror( errno ) );
return NULL; return NULL;
} }
@ -57,48 +60,60 @@ msgSpace * msgSpaceCreate(
strerror( errno ) ); strerror( errno ) );
return NULL; return NULL;
} }
/* Map the memory object */ /* Map the memory object */
mSAddr = mmap( 0, sizeof( *mSAddr ), mSAddr = mmap( 0, sizeof( *mSAddr ),
PROT_READ | PROT_WRITE, PROT_READ | PROT_WRITE,
MAP_SHARED, mSFd, 0 ); MAP_SHARED, mSFd, 0 );
if( mSAddr == MAP_FAILED ) { if( mSAddr == MAP_FAILED ) {
fprintf( stderr, "mmap failed: %s\n", fprintf( stderr, "mmap failed: %s\n",
strerror( errno ) ); strerror( errno ) );
return NULL; return NULL;
} }
printf( "Map addr is 0x%08x\n", (int)mSAddr ); printf( "Map addr is 0x%08x\n", (int)mSAddr );
/* on ferme le descripteur du fichier */ /* on ferme le descripteur du fichier */
close(mSFd); close(mSFd);
/* on remplit la structure */ /* on remplit la structure */
strncpy(mSAddr->id,nzgId,MSGSPACE_ID_LEN); strncpy(mSAddr->id,nzgId,MSGSPACE_ID_LEN);
mSAddr->poolNb=poolNb; mSAddr->poolNb=poolNb;
mSAddr->queueNb=queueNb; mSAddr->queueNb=queueNb;
mSAddr->pid=getpid(); mSAddr->pid=getpid();
/* TODO: creation du poolData */ /* creation du poolData */
msgPoolDataIdIntern(poolDataId,spaceId); msgPoolDataIdIntern(poolDataId,spaceId);
/* TODO: on ajoute spaceId a la liste des msgSpace connus */
/* TODO: on crée queueNb files de messages */ mSPoolDataFd=shm_open(
poolDataId,
/* on créer poolNb pool de buffers */ O_RDWR|O_CREAT|O_EXCL|O_TRUNC,
/* et on "attache" tout ce beau monde au spaceId */ MSGSPACE_DEFAULT_MODE
for (i=0;i<poolNb;i++){ );
// creation d'une pool if (mSPoolDataFd == -1 ) {
fprintf( stderr, "poolData %s creation failed: %s\n",
(char*)poolDataId,
strerror( errno ) );
return NULL;
}
/* TODO:allocation de la bonne zone mémoire pour le poolData */
// mSAddr-> /* TODO: on ajoute spaceId a la liste des msgSpace connus */
}
/* on renvoie un pointeur sur le bon spaceId */ /* TODO: on crée queueNb files de messages */
return mSAddr;
/* on créer poolNb pool de buffers */
/* et on "attache" tout ce beau monde au spaceId */
for (i=0;i<poolNb;i++){
// creation d'une pool
// mSAddr->
}
/* on renvoie un pointeur sur le bon spaceId */
return mSAddr;
} }
@ -126,8 +141,8 @@ int msgSpaceDelete(msgSpaceId spaceId){
if (msgSpaceIdIntern(nzgId,spaceId) == -1){ if (msgSpaceIdIntern(nzgId,spaceId) == -1){
//TODO: message d'erreur //TODO: message d'erreur
return -1; return -1;
} }
if (shm_unlink(nzgId)<0){ if (shm_unlink(nzgId)<0){
perror("shm_unlink"); perror("shm_unlink");
return -1; return -1;