*** empty log message ***

This commit is contained in:
glenux 2004-02-25 10:32:41 +00:00 committed by Glenn Y. Rolland
parent c8f6efca31
commit 2c932cb2db
9 changed files with 90 additions and 16 deletions

View file

@ -36,6 +36,10 @@ void * msgAllocate(msgSpace *space,
mSPoolDataTabAddr=msgPoolDataTabOpen(space); mSPoolDataTabAddr=msgPoolDataTabOpen(space);
if (mSPoolDataTabAddr==NULL){
NZG_ERROR("msgPoolDataTabOpen",space->poolDataTabId);
goto ERROR;
}
/* /*
// verifier le premier arg du shm_open // verifier le premier arg du shm_open
mSPoolDataTabFd=shm_open(space->poolDataTabId, mSPoolDataTabFd=shm_open(space->poolDataTabId,

View file

@ -41,7 +41,7 @@ int msgPoolCreate(
ressourceSemFd = sem_open(poolRessourceSemId, O_CREAT|O_EXCL,SEM_DEFAULT_MODE, buffNb); ressourceSemFd = sem_open(poolRessourceSemId, O_CREAT|O_EXCL,SEM_DEFAULT_MODE, buffNb);
if (ressourceSemFd == SEM_FAILED){ if (ressourceSemFd == SEM_FAILED){
NZG_ERROR("sem_open : creation de la ressource",poolRessourceSemId); NZG_ERROR("sem_open : creation de la ressource",poolRessourceSemId);
return -1; goto ERROR;
} else { } else {
NZG_ERROR("sem_open : creation oki",poolRessourceSemId); NZG_ERROR("sem_open : creation oki",poolRessourceSemId);
} }
@ -55,5 +55,7 @@ int msgPoolCreate(
close(poolFd); close(poolFd);
return 0; return 0;
ERROR:
return -1;
} }

42
src/poolDataTabCreate.c Normal file
View file

@ -0,0 +1,42 @@
#include "libnazgul.h"
#include "ids.h"
void * msgPoolDataTabCreate(msgSpace * space){
int poolDataFd; // shm file descriptor
msgPoolData * poolDataTabAddr;
poolDataFd=shm_open(
space->poolDataTabId,
O_RDWR|O_CREAT|O_EXCL|O_TRUNC,
MSGSPACE_DEFAULT_MODE
);
if (poolDataFd == -1 ) {
NZG_ERROR("shm_open :create",space->poolDataTabId);
goto ERROR;
}
/* allocation de la bonne zone mémoire pour le poolData */
if (ftruncate(poolDataFd, (space->poolNb)*sizeof(msgPoolData)) == -1){
NZG_ERROR("ftruncate",space->poolDataTabId);
goto ERROR;
}
close(poolDataFd);
poolDataTabAddr = msgPoolDataTabOpen(space);
if (poolDataTabAddr == NULL){
NZG_ERROR("msgPoolDataTabOpen : create",space->poolDataTabId);
goto ERROR;
}
/*mmap( 0, sizeof( *mSAddr ),
PROT_READ | PROT_WRITE,
MAP_SHARED, mSFd, 0 );
if( poolDataAddr == MAP_FAILED ) {
NZG_ERROR("mmap",poolDataTabId);
goto ERROR;
}*/
return poolDataTabAddr;
ERROR:
return NULL;
}

View file

@ -67,7 +67,7 @@ int msgQueueElemDelete(msgQueueElemId queueElemId);
/* queueElemOpen.c */ /* queueElemOpen.c */
void *msgQueueElemOpen(msgQueueElemId queueElemId); void *msgQueueElemOpen(msgQueueElemId queueElemId);
/* queueInit.c */ /* queueInit.c */
msgQueue *queueInit(msgSpaceId externId, int queueIdx); msgQueue *msgQueueInit(msgSpaceId externId, int queueIdx);
/* queueOpen.c */ /* queueOpen.c */
void *msgQueueOpen(msgQueueId queueId); void *msgQueueOpen(msgQueueId queueId);
/* queueProtLock.c */ /* queueProtLock.c */

View file

@ -8,7 +8,10 @@ int msgPut(msgSpace * space,int queueIndex, void * addr){
int err; int err;
msgPoolDataTabLock(space); msgPoolDataTabLock(space);
poolDataTabAddr=msgPoolDataTabOpen(space); poolDataTabAddr=msgPoolDataTabOpen(space);
if (poolDataTabAddr == NULL){
NZG_ERROR("msgPoolDataTabOpen",space->poolDataTabId);
goto ERROR;
}
err=msgBufferGetProcAttach( err=msgBufferGetProcAttach(
poolDataTabAddr, poolDataTabAddr,
space->poolNb, space->poolNb,

View file

@ -1,7 +1,7 @@
#include "libnazgul.h" #include "libnazgul.h"
#include "ids.h" #include "ids.h"
msgQueue * queueInit(msgSpaceId externId, int queueIdx) { msgQueue * msgQueueInit(msgSpaceId externId, int queueIdx) {
int queueFd; int queueFd;
msgQueue * queue; msgQueue * queue;
sem_t * semProtectFd; sem_t * semProtectFd;
@ -12,9 +12,11 @@ msgQueue * queueInit(msgSpaceId externId, int queueIdx) {
queue = NULL; queue = NULL;
printf("ploped init queue ?\n");
msgQueueProtSemIdIntern(queueSemProtectId,externId,queueIdx); msgQueueProtSemIdIntern(queueSemProtectId,externId,queueIdx);
msgQueueReadSemIdIntern(queueSemReadableId,externId,queueIdx); msgQueueReadSemIdIntern(queueSemReadableId,externId,queueIdx);
// creation du semaphore de lecture // creation du semaphore de lecture
semReadableFd = sem_open(queueSemReadableId, semReadableFd = sem_open(queueSemReadableId,
O_CREAT|O_EXCL, SEM_DEFAULT_MODE, 0); O_CREAT|O_EXCL, SEM_DEFAULT_MODE, 0);

View file

@ -49,14 +49,13 @@ msgSpace * msgSpaceCreate(
); );
if (mSFd == -1 ) { if (mSFd == -1 ) {
NZG_ERROR("shm_open : msgSpace creation",nzgId); NZG_ERROR("shm_open : msgSpace creation",nzgId);
return NULL; goto ERROR;
} }
/* on redimentionne l'element */ /* on redimentionne l'element */
if (ftruncate(mSFd, sizeof(* space)) == -1){ if (ftruncate(mSFd, sizeof(* space)) == -1){
fprintf( stderr, "msgSpace resizing failed: %s\n", NZG_ERROR("ftruncate",nzgId);
strerror( errno ) ); goto ERROR;
return NULL;
} }
/* Map the memory object */ /* Map the memory object */
@ -64,9 +63,8 @@ msgSpace * msgSpaceCreate(
PROT_READ | PROT_WRITE, PROT_READ | PROT_WRITE,
MAP_SHARED, mSFd, 0 ); MAP_SHARED, mSFd, 0 );
if( space == MAP_FAILED ) { if( space == MAP_FAILED ) {
fprintf( stderr, "mmap failed: %s\n", NZG_ERROR("mmap",nzgId);
strerror( errno ) ); goto ERROR;
return NULL;
} }
printf( "CREAT: msgSpace mapped to 0x%08x in %d\n", (int)space,(int)getpid()); printf( "CREAT: msgSpace mapped to 0x%08x in %d\n", (int)space,(int)getpid());
@ -90,7 +88,7 @@ msgSpace * msgSpaceCreate(
if (mSDataTabSemFd == SEM_FAILED){ if (mSDataTabSemFd == SEM_FAILED){
NZG_ERROR("sem_open : creation de la ressource", NZG_ERROR("sem_open : creation de la ressource",
space->poolDataTabSemId); space->poolDataTabSemId);
return NULL; goto ERROR;
} else { } else {
NZG_ERROR("sem_open : creation oki", NZG_ERROR("sem_open : creation oki",
space->poolDataTabSemId); space->poolDataTabSemId);
@ -100,7 +98,11 @@ msgSpace * msgSpaceCreate(
// msgPoolDataTabLock(space); // msgPoolDataTabLock(space);
/* attacher le tableau des msgPoolData */ /* attacher le tableau des msgPoolData */
poolDataTabAddr=msgPoolDataTabCreate(space); poolDataTabAddr=msgPoolDataTabCreate(space);
if (poolDataTabAddr == NULL){
NZG_ERROR("msgPoolDataTabCreate",space->poolDataTabId);
goto ERROR;
}
for (i=0;i<poolNb;i++){ for (i=0;i<poolNb;i++){
/* Pour chacun des poolData /* Pour chacun des poolData
@ -131,6 +133,16 @@ msgSpace * msgSpaceCreate(
} }
printf("Creating queues:\n");
for (i=0; i<queueNb;i++){
printf("- queue %i...",i); fflush(stdout);
if (msgQueueInit(space->externId,i) < 0){
printf("fail.\n");
NZG_ERROR("msgQueueInit : queue ?? for",space->externId);
goto ERROR;
}
printf("ok.\n");
}
msgPoolDataTabClose(space,poolDataTabAddr); msgPoolDataTabClose(space,poolDataTabAddr);
/* TODO: on ajoute spaceId a la liste des msgSpace connus */ /* TODO: on ajoute spaceId a la liste des msgSpace connus */
/* TODO: on crée queueNb files de messages */ /* TODO: on crée queueNb files de messages */

View file

@ -22,7 +22,11 @@ int main(void) {
printf("RequestedId: %s\n",testId); printf("RequestedId: %s\n",testId);
printf("Void size: %d\n",sizeof(void)); printf("Void size: %d\n",sizeof(void));
mSPAC=msgSpaceCreate(testId,0,3,poolInfos); mSPAC=msgSpaceCreate(testId,0,3,poolInfos);
if (mSPAC ==NULL) {
NZG_ERROR("msgSpaceCreate",testId);
exit(0);
}
pid_t pid=fork(); pid_t pid=fork();

View file

@ -20,7 +20,12 @@ int main(void) {
printf("Void size: %d\n",sizeof(void)); printf("Void size: %d\n",sizeof(void));
//creation de l'espace de messages //creation de l'espace de messages
mSPAC=msgSpaceCreate(testId,1,2,poolInfos); mSPAC=msgSpaceCreate(testId,1,2,poolInfos);
if (mSPAC ==NULL) {
NZG_ERROR("msgSpaceCreate",testId);
exit(0);
}
printf("CREATION ------------------ ok\n");
pid_t pid=fork(); pid_t pid=fork();
if (pid ==0){ if (pid ==0){