From 5e49515bf1a6a7527e4cd35a355bf42018ebeffe Mon Sep 17 00:00:00 2001 From: glenux Date: Wed, 25 Feb 2004 12:46:46 +0000 Subject: [PATCH] *** empty log message *** --- src/bufferDetachProc.c | 2 ++ src/get.c | 11 ++++++- test/{put_get.c => put_get_mono.c} | 0 test/put_get_multi.c | 48 ++++++++++++++++++++++++++++++ 4 files changed, 60 insertions(+), 1 deletion(-) rename test/{put_get.c => put_get_mono.c} (100%) create mode 100644 test/put_get_multi.c diff --git a/src/bufferDetachProc.c b/src/bufferDetachProc.c index 2572eed..457fcab 100644 --- a/src/bufferDetachProc.c +++ b/src/bufferDetachProc.c @@ -13,6 +13,8 @@ int msgBufferDetachProc( printf("Detaching %d,%d\n",poolIndex,bufferIndex); //récuperer l'ID du BufferInfoTab; + + strcpy(bufferInfoTabId, poolDataTabAddr[poolIndex].bufferInfoTabId); bufferInfoTabFd=shm_open(bufferInfoTabId,O_RDWR,SHM_DEFAULT_MODE); diff --git a/src/get.c b/src/get.c index fa714dd..9006eed 100644 --- a/src/get.c +++ b/src/get.c @@ -40,10 +40,19 @@ void * msgGet(msgSpace * space,int queueIndex,int option){ poolDataTab=msgPoolDataTabOpen(space); // mapper le buffer dans l'espace mémoire du processus resultAddr=msgBufferMap(poolDataTab,oldElem->poolIndex,oldElem->bufferIndex); + // attacher au buffer... + if (msgBufferAttachProc(poolDataTab, + oldElem->poolIndex, + oldElem->bufferIndex, + resultAddr) <0){ + NZG_ERROR("msgBufferAttachProc",oldElemId); + goto ERROR; + } + msgPoolDataTabClose(space,poolDataTab); - // attacher au buffer... + // fermer la file msgQueueClose(queue); diff --git a/test/put_get.c b/test/put_get_mono.c similarity index 100% rename from test/put_get.c rename to test/put_get_mono.c diff --git a/test/put_get_multi.c b/test/put_get_multi.c new file mode 100644 index 0000000..7dcac05 --- /dev/null +++ b/test/put_get_multi.c @@ -0,0 +1,48 @@ +#include +#include "libnazgul.h" + +int main(void) { + // msgSpace mS=0; + + msgSpaceId testId; + msgSpace * mSPAC; + msgPool poolInfos[3]; + char * montext; + + poolInfos[0].bufferNb=4; + poolInfos[0].bufferSize=200; + + poolInfos[1].bufferNb=5; + poolInfos[1].bufferSize=250; + + sprintf(testId,"test%d",(int)getuid()); + printf("RequestedId: %s\n",testId); + printf("Void size: %d\n",sizeof(void)); + //creation de l'espace de messages + mSPAC=msgSpaceCreate(testId,1,2,poolInfos); + if (mSPAC ==NULL) { + NZG_ERROR("msgSpaceCreate",testId); + exit(0); + } + + printf("CREATION ------------------ ok\n"); +pid_t pid=fork(); +if (pid==0){ + sleep(2); + mSPAC=msgSpaceOpen(testId); + montext=msgAllocate(mSPAC,1,280,0); + *montext=42; + printf("### test Valeur0 %d ###\n",(int)*montext); + printf("Put1..."); fflush(stdout); + msgPut(mSPAC,0,montext); + printf("put1-ok\n"); +} else { + mSPAC=msgSpaceOpen(testId); + printf("Get..."); fflush(stdout); + montext=msgGet(mSPAC,0,0); + printf("get-ok\n"); + printf("### test Reception %d ###\n",(int)*montext); + msgFree(mSPAC,montext); +} + return 0; +}