*** empty log message ***

This commit is contained in:
glenux 2004-02-22 12:51:17 +00:00 committed by Glenn Y. Rolland
parent 41b9ea4414
commit 79cf5e95d7
3 changed files with 60 additions and 22 deletions

View file

@ -59,5 +59,20 @@ int msgPoolIdIntern(msgPoolId dest,msgPoolId src, int num){
return 0; return 0;
} }
int msgBufferInfoTabIdIntern(
msgBufferInfoTabId dest,
msgSpaceId src,
int num){
if (strlen(src)>MSGSPACE_ID_LEN){
return -1;
}
#ifdef _NZG_REALFILEID
sprintf(dest,"/tmp/nzgBufferInfo-%s-%d",(char *)src,num);
#else
sprintf(dest,"/nzgBufferInfo-%s-%d",(char *)src,num);
#endif
return 0;
}
#endif #endif

View file

@ -1,9 +1,6 @@
#include "libnazgul.h" #include "libnazgul.h"
#include "nzg_ids.h" #include "nzg_ids.h"
/* pid[]
liste process demandeurs */
int msgPoolCreate( int msgPoolCreate(
msgSpaceId spaceId, msgSpaceId spaceId,
int poolIdx, int poolIdx,
@ -12,38 +9,61 @@ int msgPoolCreate(
) { ) {
int poolFd; int poolFd;
static int poolNb; int bufferTabFd;
sem_t * sem; sem_t * ressourceSem;
msgPoolId poolId; msgPoolId poolId;
msgPoolSemId poolSemId; msgBufferInfoTabId bufferInfoTabId;
if (msgPoolIdIntern(poolId,spaceId,poolIdx) == -1){ msgPoolSemId poolRessourceSemId;
fprintf( stderr, "msgPoolId creation failed for id %s\n",
(char*)poolId );
/* creation des infos sur buffers DEBUT */
if (msgBufferInfoTabIdIntern(bufferInfoTabId,spaceId,poolIdx) == -1){
fprintf( stderr, "msgPoolId creation failed for id %s\n", (char*)poolId );
return -1;
}
bufferTabFd=shm_open(bufferInfoTabId,O_RDWR|O_CREAT|O_EXCL|O_TRUNC,MSGSPACE_DEFAULT_MODE);
if (bufferTabFd == -1 ) {
fprintf( stderr, "msgInfoTab : %s creation failed: %s\n",bufferInfoTabId,
strerror( errno ) );
return -1;
}
if (ftruncate(bufferTabFd, buffNb*sizeof(msgBufferInfo)) == -1){
fprintf( stderr, "msgBufferInfoTab resizing failed: %s\n",
strerror( errno ) );
return -1;
}
/* creation des infos sur buffers FIN */
/* creation des buffers DEBUT */
if (msgPoolIdIntern(poolId,spaceId,poolIdx) == -1){
fprintf( stderr, "msgPoolId creation failed for id %s\n", (char*)poolId );
return -1; return -1;
} }
poolFd=shm_open(poolId,O_RDWR|O_CREAT|O_EXCL|O_TRUNC,MSGSPACE_DEFAULT_MODE); poolFd=shm_open(poolId,O_RDWR|O_CREAT|O_EXCL|O_TRUNC,MSGSPACE_DEFAULT_MODE);
if (poolFd == -1 ) { if (poolFd == -1 ) {
fprintf( stderr, "msgPool : %s creation failed: %s\n",poolId, fprintf( stderr, "msgPool : %s creation failed: %s\n",poolId,
strerror( errno ) ); strerror( errno ) );
return -1; return -1;
} }
if (msgPoolSemIdIntern(poolSemId,spaceId,poolIdx) == -1){
fprintf( stderr, "msgPoolId creation failed for id %s\n",
(char*)poolSemId );
return -1;
}
// on met un semaphore sur le pool
sem = sem_open(poolSemId, O_CREAT|O_EXCL, 0666, buffNb);
// on met le pool a la taille voulue pour qu'il
// puisse contenir les buffs
if (ftruncate(poolFd, (buffSize*buffNb)) == -1){ if (ftruncate(poolFd, (buffSize*buffNb)) == -1){
fprintf( stderr, "msgPool resizing failed: %s\n", fprintf( stderr, "msgPool resizing failed: %s\n",
strerror( errno ) ); strerror( errno ) );
return -1; return -1;
} }
/* creation des buffers FIN */
if (msgPoolSemIdIntern(poolRessourceSemId,spaceId,poolIdx) == -1){
fprintf( stderr, "msgPoolId creation failed for id %s\n",
(char*)poolRessourceSemId );
return -1;
}
// on met un semaphore sur le pool
ressourceSem = sem_open(poolRessourceSemId, O_CREAT|O_EXCL, 0666, buffNb);
//TODO: verrifier les erreurs sur l'ouverture de la sem
// on met le pool a la taille voulue pour qu'il
// puisse contenir les buffs
close(poolFd); close(poolFd);

View file

@ -15,6 +15,9 @@ int msgSpaceDelete(msgSpaceId spaceId);
/* src/nzg_buffer.c */ /* src/nzg_buffer.c */
int msgBufferGetFreeIndex(msgPoolData * poolDataTab, int poolIndex); int msgBufferGetFreeIndex(msgPoolData * poolDataTab, int poolIndex);
int msgBufferAttachProc(msgPoolData * poolDataTab, int poolIndex, int bufferIndex,void *addr); int msgBufferAttachProc(msgPoolData * poolDataTab, int poolIndex, int bufferIndex,void *addr);
int msgBufferInfoTabIdIntern(
msgBufferInfoTabId dest,
msgSpaceId src,
int num);
#endif #endif