*** empty log message ***

This commit is contained in:
glenux 2004-03-07 12:26:42 +00:00
parent 7c42f1cf47
commit 3d75566a88
15 changed files with 71 additions and 33 deletions

View file

@ -15,6 +15,7 @@ void * msgAllocate(msgSpace *space,
int option int option
){ ){
void * resultAddr=NULL; void * resultAddr=NULL;
int bufferFreeSize;
int i; int i;
msgPoolId resultPoolId; msgPoolId resultPoolId;
/* tableau des valeurs des semPoolCoef/pool pour identifier le pool /* tableau des valeurs des semPoolCoef/pool pour identifier le pool
@ -183,7 +184,6 @@ if (mSPoolDataTabAddr==NULL){
/* mapper le buffer libre dans l'esp addr du proc */ /* mapper le buffer libre dans l'esp addr du proc */
strcpy(resultPoolId,mSPoolDataTabAddr[selectedPoolIndex].poolId); strcpy(resultPoolId,mSPoolDataTabAddr[selectedPoolIndex].poolId);
int bufferFreeSize;
bufferFreeSize=mSPoolDataTabAddr[selectedPoolIndex].bufferSize; bufferFreeSize=mSPoolDataTabAddr[selectedPoolIndex].bufferSize;
printf("BufferSize : %d\n", bufferFreeSize); printf("BufferSize : %d\n", bufferFreeSize);

View file

@ -14,6 +14,7 @@ int msgBufferGetProcAttach(
bool found=false; bool found=false;
int pIdx=0; int pIdx=0;
int bIdx;
while ((!found) && (pIdx < poolNb)){ while ((!found) && (pIdx < poolNb)){
/* Pour chaque pool */ /* Pour chaque pool */
//récuperer l'ID du BufferInfoTab; //récuperer l'ID du BufferInfoTab;
@ -29,7 +30,7 @@ int msgBufferGetProcAttach(
PROT_READ,MAP_SHARED,bufferInfoTabFd,(off_t)0); PROT_READ,MAP_SHARED,bufferInfoTabFd,(off_t)0);
/* on cherche dans chacun des buffers */ /* on cherche dans chacun des buffers */
int bIdx=0; bIdx=0;
while((!found) && bIdx<bufferInfoNb){ while((!found) && bIdx<bufferInfoNb){
if (bufferInfoTabAddr[bIdx].addr == addr){ if (bufferInfoTabAddr[bIdx].addr == addr){
found=true; found=true;

View file

@ -1,14 +1,18 @@
#include "libnazgul.h" #include "libnazgul.h"
int msgFree(msgSpace * space, void * addr){ int msgFree(msgSpace * space, void * addr){
printf("[ FREE 0x%08x ]\n",(int)addr);
int poolIndex; int poolIndex;
int bufferIndex; int bufferIndex;
msgPoolData * poolDataTabAddr; msgPoolData * poolDataTabAddr;
sem_t * ressourceSemFd; sem_t * ressourceSemFd;
msgPoolDataTabSemId ressourceSemId; msgPoolDataTabSemId ressourceSemId;
/* on acquiert le droit de modifier les infos sur la ressource */ int err;
int bufferNb;
int bufferSize;
void * realAddr;
printf("[ FREE 0x%08x ]\n",(int)addr);
/* on acquiert le droit de modifier les infos sur la ressource */
/* on protege le tableau des associations */ /* on protege le tableau des associations */
if (msgPoolDataTabLock(space) <0){ if (msgPoolDataTabLock(space) <0){
NZG_ERROR("msgPoolDataTabLock",space->poolDataTabSemId); NZG_ERROR("msgPoolDataTabLock",space->poolDataTabSemId);
@ -20,7 +24,6 @@ int msgFree(msgSpace * space, void * addr){
poolDataTabAddr = msgPoolDataTabOpen(space); poolDataTabAddr = msgPoolDataTabOpen(space);
// TODO: verouiller semaphore DataInfo ?? // TODO: verouiller semaphore DataInfo ??
int err;
poolIndex=-1; bufferIndex=-1; poolIndex=-1; bufferIndex=-1;
err=msgBufferGetProcAttach( err=msgBufferGetProcAttach(
@ -36,17 +39,17 @@ int msgFree(msgSpace * space, void * addr){
msgBufferDetachProc(poolDataTabAddr,poolIndex,bufferIndex,addr); msgBufferDetachProc(poolDataTabAddr,poolIndex,bufferIndex,addr);
/* unmapper le buffer */ /* unmapper le buffer */
void * realAddr=addr; realAddr=addr;
int bufferSize=poolDataTabAddr[poolIndex].bufferSize; bufferSize=poolDataTabAddr[poolIndex].bufferSize;
int bufferNb=poolDataTabAddr[poolIndex].bufferNb; bufferNb=poolDataTabAddr[poolIndex].bufferNb;
realAddr=realAddr-poolIndex*bufferSize; realAddr=realAddr-poolIndex*bufferSize;
munmap(realAddr,bufferSize*bufferNb); munmap(realAddr,bufferSize*bufferNb);
msgPoolDataTabClose(space,poolDataTabAddr); msgPoolDataTabClose(space,poolDataTabAddr);
// deverouiller semaphore DataInfo // deverouiller semaphore DataInfo
msgPoolDataTabUnlock(space); msgPoolDataTabUnlock(space);
// deverouiller semaphore ressource. // deverouiller semaphore ressource.
msgPoolSemIdIntern(ressourceSemId,space->externId,poolIndex); msgPoolSemIdIntern(ressourceSemId,space->externId,poolIndex);
ressourceSemFd = sem_open(ressourceSemId,O_CREAT,SEM_DEFAULT_MODE,0); ressourceSemFd = sem_open(ressourceSemId,O_CREAT,SEM_DEFAULT_MODE,0);

View file

@ -8,6 +8,7 @@ void * msgGet(msgSpace * space,int queueIndex,int option){
msgQueue * queue; msgQueue * queue;
msgQueueElemId oldElemId; msgQueueElemId oldElemId;
msgQueueElem * oldElem; msgQueueElem * oldElem;
msgPoolData * poolDataTab;
// on teste la possibilité de lecture sur la liste... // on teste la possibilité de lecture sur la liste...
if (option == NONBLOCK){ if (option == NONBLOCK){
if (msgQueueReadTryLock(space->externId,queueIndex) <0){ if (msgQueueReadTryLock(space->externId,queueIndex) <0){
@ -39,7 +40,6 @@ void * msgGet(msgSpace * space,int queueIndex,int option){
goto ERROR; goto ERROR;
} }
/* on récupere la taille des buffer dans la pool du buffer */ /* on récupere la taille des buffer dans la pool du buffer */
msgPoolData * poolDataTab;
poolDataTab=msgPoolDataTabOpen(space); poolDataTab=msgPoolDataTabOpen(space);
// mapper le buffer dans l'espace mémoire du processus // mapper le buffer dans l'espace mémoire du processus
resultAddr=msgBufferMap(poolDataTab,oldElem->poolIndex,oldElem->bufferIndex); resultAddr=msgBufferMap(poolDataTab,oldElem->poolIndex,oldElem->bufferIndex);

View file

@ -26,6 +26,11 @@
#endif #endif
#ifndef MAP_FAILED
#define MAP_FAILED ((void *)-1)
#endif
#ifdef _NZG_REALFILEID #ifdef _NZG_REALFILEID
#define DEFAULT_MSGSPACELISTID "/tmp/nzgSpaceList" #define DEFAULT_MSGSPACELISTID "/tmp/nzgSpaceList"
#else #else

View file

@ -4,10 +4,12 @@
#define DEBUG 0 #define DEBUG 0
int msgPoolDataTabLock(msgSpace * space){ int msgPoolDataTabLock(msgSpace * space){
int semval;
sem_t * poolDataTabSemFd; sem_t * poolDataTabSemFd;
if (DEBUG) {printf("Locking %s\n",space->poolDataTabSemId);} semval=0;
if (DEBUG) {printf("Locking %s\n",space->poolDataTabSemId);}
poolDataTabSemFd=sem_open( poolDataTabSemFd=sem_open(
space->poolDataTabSemId space->poolDataTabSemId
,O_CREAT, ,O_CREAT,
SEM_DEFAULT_MODE, SEM_DEFAULT_MODE,
@ -21,9 +23,9 @@ if (DEBUG) {printf("Locking %s\n",space->poolDataTabSemId);}
NZG_ERROR("sem_wait",space->poolDataTabSemId); NZG_ERROR("sem_wait",space->poolDataTabSemId);
goto ERROR; goto ERROR;
} }
int semval=0;
sem_getvalue(poolDataTabSemFd,&semval); sem_getvalue(poolDataTabSemFd,&semval);
if (DEBUG) { printf("(AfternValue:%d)\n",semval);} if (DEBUG) { printf("(AfternValue:%d)\n",semval);}
sem_close(poolDataTabSemFd); sem_close(poolDataTabSemFd);

View file

@ -4,6 +4,7 @@
#define DEBUG 0 #define DEBUG 0
int msgPoolDataTabUnlock(msgSpace * space){ int msgPoolDataTabUnlock(msgSpace * space){
int semval;
sem_t * poolDataTabSemFd; sem_t * poolDataTabSemFd;
if (DEBUG) { printf("Unlocking %s\n",space->poolDataTabSemId); } if (DEBUG) { printf("Unlocking %s\n",space->poolDataTabSemId); }
poolDataTabSemFd=sem_open( poolDataTabSemFd=sem_open(
@ -20,7 +21,8 @@ int msgPoolDataTabUnlock(msgSpace * space){
NZG_ERROR("sem_post",space->poolDataTabSemId); NZG_ERROR("sem_post",space->poolDataTabSemId);
goto ERROR; goto ERROR;
} }
int semval=0;
semval=0;
sem_getvalue(poolDataTabSemFd,&semval); sem_getvalue(poolDataTabSemFd,&semval);
if (DEBUG) { printf("(AfternValue:%d)\n",semval); } if (DEBUG) { printf("(AfternValue:%d)\n",semval); }

View file

@ -6,8 +6,10 @@ int msgPut(msgSpace * space,int queueIndex, void * addr){
int poolIndex; int poolIndex;
int bufferIndex; int bufferIndex;
int err; int err;
msgQueueElemId newElemId; msgQueueElemId newElemId;
msgQueueElem * queueElem; msgQueueElem * queueElem;
msgQueueId queueId;
msgQueue * queue;
msgPoolDataTabLock(space); msgPoolDataTabLock(space);
poolDataTabAddr=msgPoolDataTabOpen(space); poolDataTabAddr=msgPoolDataTabOpen(space);
@ -24,15 +26,13 @@ int msgPut(msgSpace * space,int queueIndex, void * addr){
); );
// ouvrir la queue avec le bon index // ouvrir la queue avec le bon index
msgQueueId queueId;
msgQueue * queue;
msgQueueIdIntern(queueId,space->externId,queueIndex); msgQueueIdIntern(queueId,space->externId,queueIndex);
msgQueueProtLock(space->externId,queueIndex); msgQueueProtLock(space->externId,queueIndex);
queue = msgQueueOpen(queueId); queue = msgQueueOpen(queueId);
// creer un element vide // creer un element vide
msgQueueElemCreate(newElemId,queueId,queue->elemCounter); msgQueueElemCreate(newElemId,queueId,queue->elemCounter);
// ouvrir l'element // ouvrir l'element
queueElem=msgQueueElemOpen(newElemId); queueElem=msgQueueElemOpen(newElemId);
@ -40,7 +40,7 @@ int msgPut(msgSpace * space,int queueIndex, void * addr){
// modifier les index pour retrouver le buffer // modifier les index pour retrouver le buffer
queueElem->poolIndex=poolIndex; queueElem->poolIndex=poolIndex;
queueElem->bufferIndex=bufferIndex; queueElem->bufferIndex=bufferIndex;
// fermer l'element // fermer l'element
if (msgQueueElemClose(queueElem) <0 ){ if (msgQueueElemClose(queueElem) <0 ){
NZG_ERROR("msgQueueElemClose",""); NZG_ERROR("msgQueueElemClose","");

View file

@ -3,6 +3,8 @@
int msgQueueDelete(msgQueueId externId,int queueIdx){ int msgQueueDelete(msgQueueId externId,int queueIdx){
msgQueue * queue; msgQueue * queue;
msgQueueId queueId; msgQueueId queueId;
msgQueueSemId queueProtLockSemId;
msgQueueSemId queueReadLockSemId;
msgQueueIdIntern(queueId,externId,queueIdx); msgQueueIdIntern(queueId,externId,queueIdx);
queue = msgQueueOpen(queueId); queue = msgQueueOpen(queueId);
@ -15,8 +17,6 @@ int msgQueueDelete(msgQueueId externId,int queueIdx){
} }
} }
msgQueueSemId queueProtLockSemId;
msgQueueSemId queueReadLockSemId;
msgQueueProtSemIdIntern(queueProtLockSemId,externId,queueIdx); msgQueueProtSemIdIntern(queueProtLockSemId,externId,queueIdx);
msgQueueReadSemIdIntern(queueReadLockSemId,externId,queueIdx); msgQueueReadSemIdIntern(queueReadLockSemId,externId,queueIdx);
sem_unlink(queueProtLockSemId); sem_unlink(queueProtLockSemId);

View file

@ -6,11 +6,11 @@ int msgQueueElemCreate(
msgQueueId queueId, msgQueueId queueId,
int counter){ int counter){
msgQueueElemId queueElemId; msgQueueElemId queueElemId;
int queueElemFd;
msgQueueElemIdIntern(queueElemId,queueId,counter); msgQueueElemIdIntern(queueElemId,queueId,counter);
strcpy(finalQueueElemId,queueElemId); strcpy(finalQueueElemId,queueElemId);
int queueElemFd;
queueElemFd=shm_open(queueElemId, queueElemFd=shm_open(queueElemId,
O_RDWR|O_CREAT|O_EXCL|O_TRUNC, O_RDWR|O_CREAT|O_EXCL|O_TRUNC,
SHM_DEFAULT_MODE); SHM_DEFAULT_MODE);

View file

@ -24,21 +24,26 @@ CC=gcc
CFLAGS=-Wall -O2 -ggdb CFLAGS=-Wall -O2 -ggdb
#-O2 -ggdb #-O2 -ggdb
INCLUDES=-I /usr/include/ -I /usr/include/sys -I ../src/ INCLUDES=-I /usr/include/ -I ../src/
LIBINC=-L /usr/lib -L ../src LIBINC=-L /usr/lib -L ../src
BASELIBS=-lnazgul BASELIBS=-lnazgul
LIBS=$(BASELIBS) LIBS=$(BASELIBS)
DEFS=
ifeq "HP-UX" "${OS}" ifeq "HP-UX" "${OS}"
DEFS=-D_NZG_HPUX
LIBS=$(BASELIBS) -lpthread -lrt LIBS=$(BASELIBS) -lpthread -lrt
endif endif
ifeq "SunOS" "${OS}" ifeq "SunOS" "${OS}"
DEFS=-D_NZG_SUNOS
LIBS=$(BASELIBS) -lrt LIBS=$(BASELIBS) -lrt
endif endif
ifeq "Linux" "${OS}" ifeq "Linux" "${OS}"
DEFS=-D_NZG_LINUX
LIBS=$(BASELIBS) -lrt -lpthread LIBS=$(BASELIBS) -lrt -lpthread
endif endif
@ -61,7 +66,7 @@ clean:
@rm -f $(FILES) @rm -f $(FILES)
% : %.c % : %.c
$(CC) -o $* $< $(INCLUDES) $(LIBINC) $(LIBS) $(CFLAGS) $(CC) -o $* $< $(INCLUDES) $(LIBINC) $(LIBS) $(CFLAGS) $(DEFS)
edit: edit:
gvim *.h *.c gvim *.h *.c

View file

@ -1,4 +1,9 @@
#ifdef _NZG_HPUX
#include <sys/wait.h>
#else
#include <wait.h> #include <wait.h>
#endif
#include "libnazgul.h" #include "libnazgul.h"
int main(void) { int main(void) {
@ -20,7 +25,7 @@ int main(void) {
sprintf(testId,"test%d",(int)getuid()); sprintf(testId,"test%d",(int)getuid());
printf("RequestedId: %s\n",testId); printf("RequestedId: %s\n",testId);
printf("Void size: %d\n",sizeof(void)); printf("Void size: %d\n",(int)sizeof(void));
mSPAC=msgSpaceCreate(testId,0,3,poolInfos); mSPAC=msgSpaceCreate(testId,0,3,poolInfos);
if (mSPAC ==NULL) { if (mSPAC ==NULL) {
NZG_ERROR("msgSpaceCreate",testId); NZG_ERROR("msgSpaceCreate",testId);

View file

@ -1,4 +1,9 @@
#ifdef _NZG_HPUX
#include <sys/wait.h>
#else
#include <wait.h> #include <wait.h>
#endif
#include "libnazgul.h" #include "libnazgul.h"
void usage(char * myname){ void usage(char * myname){

View file

@ -1,4 +1,9 @@
#ifdef _NZG_HPUX
#include <sys/wait.h>
#else
#include <wait.h> #include <wait.h>
#endif
#include "libnazgul.h" #include "libnazgul.h"
int main(void) { int main(void) {
@ -17,7 +22,7 @@ int main(void) {
sprintf(testId,"test%d",(int)getuid()); sprintf(testId,"test%d",(int)getuid());
printf("RequestedId: %s\n",testId); printf("RequestedId: %s\n",testId);
printf("Void size: %d\n",sizeof(void)); printf("Void size: %d\n",(int)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) { if (mSPAC ==NULL) {

View file

@ -1,4 +1,9 @@
#ifdef _NZG_HPUX
#include <sys/wait.h>
#else
#include <wait.h> #include <wait.h>
#endif
#include "libnazgul.h" #include "libnazgul.h"
int main(void) { int main(void) {
@ -17,7 +22,7 @@ int main(void) {
sprintf(testId,"test%d",(int)getuid()); sprintf(testId,"test%d",(int)getuid());
printf("RequestedId: %s\n",testId); printf("RequestedId: %s\n",testId);
printf("Void size: %d\n",sizeof(void)); printf("Void size: %d\n",(int)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) { if (mSPAC ==NULL) {