*** 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 MSGSPACE_ID_LEN 32
#define ERR_UNHANDLED "Gérer mieu les erreurs"
#ifndef SEM_FAILED
#define SEM_FAILED ((sem_t *)0)
#endif
#endif

View file

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

View file

@ -7,7 +7,7 @@
/* nzg_ids.c */
int msgSpaceIdIntern(msgSpaceId dest, const msgSpaceId src);
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);

View file

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

View file

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

View file

@ -28,7 +28,7 @@ msgSpace * msgSpaceCreate(
static int mSIdNum=-1;
msgSpace * mSAddr;
msgPoolId poolDataId;
msgPoolId poolDataTabId;
msgPoolData * mSPoolDataAddr;
fprintf(stderr,"Creating msgSpace with id : %s\n",spaceId);
@ -85,16 +85,17 @@ msgSpace * msgSpaceCreate(
mSAddr->pid=getpid();
/* creation du poolData */
msgPoolDataIdIntern(poolDataId,spaceId);
msgPoolDataIdIntern(poolDataTabId,spaceId);
strcpy(mSAddr->poolDataTabId,poolDataTabId);
mSPoolDataFd=shm_open(
poolDataId,
poolDataTabId,
O_RDWR|O_CREAT|O_EXCL|O_TRUNC,
MSGSPACE_DEFAULT_MODE
);
if (mSPoolDataFd == -1 ) {
fprintf( stderr, "poolData %s creation failed: %s\n",
(char*)poolDataId,
(char*)poolDataTabId,
strerror( errno ) );
return NULL;
}
@ -126,8 +127,10 @@ msgSpace * msgSpaceCreate(
mSPoolDataAddr[i].bufferNb=poolInfos[i].bufferNb;
mSPoolDataAddr[i].bufferSize=poolInfos[i].bufferSize;
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){
int shmId;
int shmFd;
msgSpaceId nzgId;
msgSpace * mSAddr;
if (msgSpaceIdIntern(nzgId,spaceId) < 0){
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");
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){
fprintf(stderr,"Deleting msgSpace with id : %s\n",spaceId);
//int shmId;
msgSpaceId nzgId;
msgSpace * space;
if (msgSpaceIdIntern(nzgId,spaceId) == -1){
//TODO: message d'erreur
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){
perror("shm_unlink");
return -1;

View file

@ -9,18 +9,24 @@
OS=$(shell uname -s)
CC=gcc
CFLAGS=-Wall --static -O2 -ggdb
CFLAGS=-Wall -O2 -ggdb
#-O2 -ggdb
INCLUDES=-I /usr/include -I ../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}"
LIBS=-lnazgul -lrt
LIBS=$(BASELIBS) -lrt
endif
ifeq "Linux" "${OS}"
LIBS=-lnazgul -lrt -lpthread
LIBS=$(BASELIBS) -lrt -lpthread
endif
PRJNAME=Libnazgul