*** empty log message ***

This commit is contained in:
glenux 2004-02-21 18:50:38 +00:00
parent d54a729341
commit b54dc1c8ec
7 changed files with 49 additions and 20 deletions

View file

@ -17,4 +17,9 @@
#define SHM_DEFAULT_MODE 0600 #define SHM_DEFAULT_MODE 0600
#define MSGSPACE_ID_LEN 32 #define MSGSPACE_ID_LEN 32
#define ERR_UNHANDLED "Gérer mieu les erreurs" #define ERR_UNHANDLED "Gérer mieu les erreurs"
#ifndef SEM_FAILED
#define SEM_FAILED ((sem_t *)0)
#endif
#endif #endif

View file

@ -33,7 +33,7 @@ int msgPoolSemIdIntern(
return 0; return 0;
} }
int msgPoolDataIdIntern(msgPoolDataId dest,const msgSpaceId src ){ int msgPoolDataIdIntern(msgPoolDataTabId dest,const msgSpaceId src ){
if (strlen(src)>MSGSPACE_ID_LEN){ if (strlen(src)>MSGSPACE_ID_LEN){
return -1; return -1;
} }

View file

@ -7,7 +7,7 @@
/* nzg_ids.c */ /* nzg_ids.c */
int msgSpaceIdIntern(msgSpaceId dest, const msgSpaceId src); int msgSpaceIdIntern(msgSpaceId dest, const msgSpaceId src);
int msgPoolSemIdIntern(msgPoolSemId destSemId, const msgSpaceId srcPoolId, int poolIdx); int msgPoolSemIdIntern(msgPoolSemId destSemId, const msgSpaceId srcPoolId, int poolIdx);
int msgPoolDataIdIntern(msgPoolDataId dest, const msgSpaceId src); int msgPoolDataIdIntern(msgPoolDataTabId dest, const msgSpaceId src);
int msgSpacePoolId2nzgPoolId(msgPoolId dest, msgPoolId src, int num); int msgSpacePoolId2nzgPoolId(msgPoolId dest, msgPoolId src, int num);

View file

@ -10,8 +10,8 @@ typedef char msgSpaceId[MSGSPACE_ID_LEN];
typedef char msgSpaceListId[4*MSGSPACE_ID_LEN]; typedef char msgSpaceListId[4*MSGSPACE_ID_LEN];
typedef char msgSpaceListElemId[4*MSGSPACE_ID_LEN]; typedef char msgSpaceListElemId[4*MSGSPACE_ID_LEN];
typedef char msgPoolDataId[4*MSGSPACE_ID_LEN]; typedef char msgPoolDataTabId[4*MSGSPACE_ID_LEN];
typedef char msgPoolDataSemId[4*MSGSPACE_ID_LEN]; typedef char msgPoolDataTabSemId[4*MSGSPACE_ID_LEN];
typedef char msgPoolId[4*MSGSPACE_ID_LEN]; typedef char msgPoolId[4*MSGSPACE_ID_LEN];
typedef char msgPoolSemId[4*MSGSPACE_ID_LEN]; typedef char msgPoolSemId[4*MSGSPACE_ID_LEN];
@ -42,8 +42,8 @@ typedef struct MsgSpace {
int poolNb; int poolNb;
int queueNb; int queueNb;
int pid; int pid;
msgPoolDataId poolDataId; msgPoolDataTabId poolDataTabId;
msgPoolDataSemId poolDataSemId; msgPoolDataTabSemId poolDataTabSemId;
} msgSpace; } msgSpace;

View file

@ -1,4 +1,5 @@
#include "libnazgul.h" #include "libnazgul.h"
#include "nzg_ids.h"
/* pid[] /* pid[]
liste process demandeurs */ liste process demandeurs */

View file

@ -28,7 +28,7 @@ msgSpace * msgSpaceCreate(
static int mSIdNum=-1; static int mSIdNum=-1;
msgSpace * mSAddr; msgSpace * mSAddr;
msgPoolId poolDataId; msgPoolId poolDataTabId;
msgPoolData * mSPoolDataAddr; msgPoolData * mSPoolDataAddr;
fprintf(stderr,"Creating msgSpace with id : %s\n",spaceId); fprintf(stderr,"Creating msgSpace with id : %s\n",spaceId);
@ -85,16 +85,17 @@ msgSpace * msgSpaceCreate(
mSAddr->pid=getpid(); mSAddr->pid=getpid();
/* creation du poolData */ /* creation du poolData */
msgPoolDataIdIntern(poolDataId,spaceId); msgPoolDataIdIntern(poolDataTabId,spaceId);
strcpy(mSAddr->poolDataTabId,poolDataTabId);
mSPoolDataFd=shm_open( mSPoolDataFd=shm_open(
poolDataId, poolDataTabId,
O_RDWR|O_CREAT|O_EXCL|O_TRUNC, O_RDWR|O_CREAT|O_EXCL|O_TRUNC,
MSGSPACE_DEFAULT_MODE MSGSPACE_DEFAULT_MODE
); );
if (mSPoolDataFd == -1 ) { if (mSPoolDataFd == -1 ) {
fprintf( stderr, "poolData %s creation failed: %s\n", fprintf( stderr, "poolData %s creation failed: %s\n",
(char*)poolDataId, (char*)poolDataTabId,
strerror( errno ) ); strerror( errno ) );
return NULL; return NULL;
} }
@ -126,8 +127,10 @@ msgSpace * msgSpaceCreate(
mSPoolDataAddr[i].bufferNb=poolInfos[i].bufferNb; mSPoolDataAddr[i].bufferNb=poolInfos[i].bufferNb;
mSPoolDataAddr[i].bufferSize=poolInfos[i].bufferSize; mSPoolDataAddr[i].bufferSize=poolInfos[i].bufferSize;
mSPoolDataAddr[i].allocDispBuffer=0; mSPoolDataAddr[i].allocDispBuffer=0;
mSPoolDataAddr[i].allocOverload=false;
//TODO: remplir l'ID : mSPoolDataAddr[i].id msgPoolId poolId;
msgPoolCreate(poolId,poolInfos[i].bufferNb,poolInfos[i].bufferSize);
strcpy(mSPoolDataAddr[i].id,poolId);
} }
@ -143,27 +146,41 @@ msgSpace * msgSpaceCreate(
*/ */
msgSpace * msgSpaceOpen(msgSpaceId spaceId){ msgSpace * msgSpaceOpen(msgSpaceId spaceId){
int shmId; int shmFd;
msgSpaceId nzgId; msgSpaceId nzgId;
msgSpace * mSAddr;
if (msgSpaceIdIntern(nzgId,spaceId) < 0){ if (msgSpaceIdIntern(nzgId,spaceId) < 0){
return NULL; return NULL;
} }
if ((shmId=shm_open(nzgId,O_RDWR,MSGSPACE_DEFAULT_MODE)) < 0){ if ((shmFd=shm_open(nzgId,O_RDWR,MSGSPACE_DEFAULT_MODE)) < 0){
perror("shm_open"); perror("shm_open");
return NULL; return NULL;
} }
return NULL; mSAddr=mmap(NULL,sizeof(msgSpace),PROT_READ|PROT_WRITE,MAP_SHARED,shmFd,(off_t)0);
return mSAddr;
} }
int msgSpaceDelete(msgSpaceId spaceId){ int msgSpaceDelete(msgSpaceId spaceId){
fprintf(stderr,"Deleting msgSpace with id : %s\n",spaceId); fprintf(stderr,"Deleting msgSpace with id : %s\n",spaceId);
//int shmId; //int shmId;
msgSpaceId nzgId; msgSpaceId nzgId;
msgSpace * space;
if (msgSpaceIdIntern(nzgId,spaceId) == -1){ if (msgSpaceIdIntern(nzgId,spaceId) == -1){
//TODO: message d'erreur //TODO: message d'erreur
return -1; return -1;
} }
space = msgSpaceOpen(spaceId);
printf("openned successfully !\n");
printf("Unlinking DataTab... ");
if (shm_unlink(space->poolDataTabId) < 0){
perror("shm_unlink");
return -1;
}
printf("ok\n");
if (shm_unlink(nzgId)<0){ if (shm_unlink(nzgId)<0){
perror("shm_unlink"); perror("shm_unlink");
return -1; return -1;

View file

@ -9,18 +9,24 @@
OS=$(shell uname -s) OS=$(shell uname -s)
CC=gcc CC=gcc
CFLAGS=-Wall --static -O2 -ggdb CFLAGS=-Wall -O2 -ggdb
#-O2 -ggdb #-O2 -ggdb
INCLUDES=-I /usr/include -I ../src/ INCLUDES=-I /usr/include -I ../src/
LIBINC=-L /usr/lib -L ../src LIBINC=-L /usr/lib -L ../src
LIBS=-lnazgul BASELIBS=-lnazgul
LIBS=$(BASELIBS)
ifeq "HP-UX" "${OS}"
LIBS=$(BASELIBS) -lpthread -lrt
endif
ifeq "SunOS" "${OS}" ifeq "SunOS" "${OS}"
LIBS=-lnazgul -lrt LIBS=$(BASELIBS) -lrt
endif endif
ifeq "Linux" "${OS}" ifeq "Linux" "${OS}"
LIBS=-lnazgul -lrt -lpthread LIBS=$(BASELIBS) -lrt -lpthread
endif endif
PRJNAME=Libnazgul PRJNAME=Libnazgul