*** empty log message ***

This commit is contained in:
glenux 2004-02-25 17:54:51 +00:00
parent 19943dc5d3
commit 5ecb38599b
7 changed files with 94 additions and 34 deletions

View file

@ -1,6 +1,3 @@
#ifndef _NZG_IDS
#define _NZG_IDS 1
#include "libnazgul.h" #include "libnazgul.h"
#include "ids.h" #include "ids.h"
@ -143,7 +140,7 @@ int msgQueueElemIdIntern(
return 0; return 0;
} }
int spaceListElemIdIntern(msgSpaceListElemId elemListId,msgSpaceId externId){ int msgSpaceListElemIdIntern(msgSpaceListElemId elemListId,msgSpaceId externId){
if (strlen(externId)>MSGSPACE_ID_LEN){ if (strlen(externId)>MSGSPACE_ID_LEN){
return -1; return -1;
} }
@ -158,4 +155,4 @@ int spaceListElemIdIntern(msgSpaceListElemId elemListId,msgSpaceId externId){
} }
#endif

View file

@ -1,8 +1,14 @@
#ifndef _NZG_IDS #ifndef _NZG_IDS
#define _NZG_IDS 1 #define _NZG_IDS 1
#include "libnazgul.h" #include "libnazgul.h"
#ifdef _NZG_REALFILEID
#define msgSpaceListId "/tmp/nzgSpaceList"
#else
#define msgSpaceListId "/nzgSpaceList"
#endif
/* 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);

View file

@ -59,15 +59,18 @@ typedef struct MsgSpace {
typedef struct MsgSpaceListElem { typedef struct MsgSpaceListElem {
int ownerPid; msgSpaceListElemId id;
msgSpaceId spaceId; msgSpaceId spaceId;
msgSpaceListElemId next; msgSpaceListElemId next;
} msgSpaceListElem; } msgSpaceListElem;
typedef struct MsgSpaceList { typedef struct MsgSpaceList {
msgSpaceListId id;
int elemCounter; int elemCounter;
msgSpaceListElemId first; msgSpaceListElemId headId;
msgSpaceListElemId last; msgSpaceListElemId tailId;
} msgSpaceList; } msgSpaceList;
typedef struct MsgQueueElem { typedef struct MsgQueueElem {

View file

@ -34,7 +34,7 @@ int msgQueueProtSemIdIntern(msgQueueSemId dest, msgSpaceId externId, int queueId
int msgQueueReadSemIdIntern(msgQueueSemId dest, msgSpaceId externId, int queueIdx); int msgQueueReadSemIdIntern(msgQueueSemId dest, msgSpaceId externId, int queueIdx);
int msgQueueIdIntern(msgQueueId dest, msgSpaceId externId, int queueIdx); int msgQueueIdIntern(msgQueueId dest, msgSpaceId externId, int queueIdx);
int msgQueueElemIdIntern(msgQueueElemId dest, msgQueueId src, int counter); int msgQueueElemIdIntern(msgQueueElemId dest, msgQueueId src, int counter);
int spaceListElemIdIntern(msgSpaceListElemId elemListId, msgSpaceId externId); int msgSpaceListElemIdIntern(msgSpaceListElemId elemListId, msgSpaceId externId);
/* list.c */ /* list.c */
/* poolCreate.c */ /* poolCreate.c */
int msgPoolCreate(msgSpaceId externId, int poolIdx, int buffNb, int buffSize); int msgPoolCreate(msgSpaceId externId, int poolIdx, int buffNb, int buffSize);
@ -87,14 +87,23 @@ msgSpace *msgSpaceCreate(msgSpaceId externId, int queueNb, int poolNb, msgPool *
/* spaceDelete.c */ /* spaceDelete.c */
int msgSpaceDelete(msgSpaceId externId); int msgSpaceDelete(msgSpaceId externId);
/* spaceListAdd.c */ /* spaceListAdd.c */
int msgSpaceListAdd(msgSpaceListElemId newElemId);
/* spaceListClose.c */
int msgSpaceListClose(msgSpaceList *list);
/* spaceListElemClose.c */
int msgSpaceListElemClose(msgSpaceListElem *listElem);
/* spaceListElemCreate.c */ /* spaceListElemCreate.c */
int msgSpaceListElemCreate(msgSpaceListElemId elemenListId, msgSpace *space); int msgSpaceListElemCreate(msgSpaceListElemId elemenListId, msgSpace *space);
/* spaceListElemLink.c */ /* spaceListElemLink.c */
/* spaceListElemOpen.c */
void *msgSpaceListElemOpen(msgSpaceListElemId listElemId);
/* spaceListInit.c */ /* spaceListInit.c */
int msgSpaceListInit(void); int msgSpaceListInit(void);
/* spaceListLocking.c */ /* spaceListLocking.c */
int msgSpaceListLock(void); int msgSpaceListLock(void);
int msgSpaceListUnlock(void); int msgSpaceListUnlock(void);
/* spaceListOpen.c */
void *msgSpaceListOpen(void);
/* spaceListRem.c */ /* spaceListRem.c */
/* spaceOpen.c */ /* spaceOpen.c */
msgSpace *msgSpaceOpen(msgSpaceId externId); msgSpace *msgSpaceOpen(msgSpaceId externId);

View file

@ -1,6 +1,5 @@
#include "libnazgul.h" #include "libnazgul.h"
#include "ids.h" #include "ids.h"
#include "libnazgul.h"
int msgQueueClose(msgQueue * queue){ int msgQueueClose(msgQueue * queue){
msgQueueId qId; msgQueueId qId;

View file

@ -3,4 +3,50 @@
// ajoute un element en début de liste. // ajoute un element en début de liste.
// fait pointer l'ancien dernier vers lui // fait pointer l'ancien dernier vers lui
// il s'enregistre en tant que dernier chez la liste // il s'enregistre en tant que dernier chez la liste
int msgSpaceListAdd(msgSpaceListElemId ); int msgSpaceListAdd(msgSpaceListElemId newElemId){
msgSpaceListElem * listOldTailElem;
msgSpaceListElem * listNewTailElem;
msgSpaceList * list=NULL;
list=msgSpaceListOpen();
// on informe l'element qui est le dernier
listNewTailElem=msgSpaceListElemOpen(newElemId);
if (listNewTailElem==NULL){
}
strcpy(listNewTailElem->next,newElemId);
if (msgSpaceListElemClose(listNewTailElem) <0 ){
NZG_ERROR("msgQueueElemClose",newElemId);
goto ERROR;
}
/* TODO: verifier si la liste n'est pas vide... */
if((strcmp(list->headId,list->id)==0)
&& (strcmp(list->tailId,list->id)==0)) {
printf("- premier elem de queue -\n");
// on donne a la queue l'id de l'element
strcpy(list->headId,newElemId);
strcpy(list->tailId,newElemId);
} else {
/* on informe son prédecesseur qu'il a un suivant */
listOldTailElem=msgSpaceListElemOpen(list->tailId);
if (listOldTailElem == NULL){
NZG_ERROR("msgQueueElemOpen",list->tailId);
goto ERROR;
}
strcpy(listOldTailElem->next,newElemId);
if (msgSpaceListElemClose(listOldTailElem) < 0){
NZG_ERROR("msgQueueElemClose",list->tailId);
goto ERROR;
}
// on donne a la queue l'id du dernier element
strcpy(list->tailId,newElemId);
}
// on incremente elemCounter
list->elemCounter++;
msgSpaceListClose(list);
return 0;
ERROR:
return -1;
}

View file

@ -2,33 +2,33 @@
#include "ids.h" #include "ids.h"
// cree un nouvel elemen // cree un nouvel elemen
int msgSpaceListElemCreate(msgSpaceListElemId elemenListId,msgSpace * space){ int msgSpaceListElemCreate(
msgSpaceListElemId elemenListId,
msgSpace * space)
{
int shmElemenList; msgSpaceId listElemId;
/*Creation de lid pour lespace de message*/
spaceListElemIdIntern(elemenListId,space->externId); strcpy(listElemId,space->id);
int listElemFd;
listElemFd=shm_open(listElemId,
O_RDWR|O_CREAT|O_EXCL|O_TRUNC,
SHM_DEFAULT_MODE);
if ((shmElemenList=shm_open(elemenListId, if (listElemFd == -1 ) {
O_RDWR|O_CREAT|O_EXCL|O_TRUNC, NZG_ERROR("shm_open : msgSpaceListElem creation",listElemId);
MSGSPACE_DEFAULT_MODE))==-1){ goto ERROR;
NZG_ERROR("shm_open:Space list creation",elemenListId); }
goto ERROR;
}
if(ftruncate(shmElemenList,sizeof(elemenListId) ) <0) { if (ftruncate(listElemFd, sizeof(msgQueueElem)) < 0){
NZG_ERROR("ftruncate",elemenListId); NZG_ERROR("ftruncate", listElemId);
goto ERROR; goto ERROR;
}; }
close (shmElemenList); close(listElemFd);
//TODO: mapper le shm en mémoire et remplir avec des informations return 0;
//strcpy(spaceListElem->spaceId,space->id);
return 0;
ERROR: ERROR:
return-1; return -1;
}; };