*** empty log message ***
This commit is contained in:
parent
634e65599b
commit
bdf79f3600
3 changed files with 60 additions and 22 deletions
|
@ -59,5 +59,20 @@ int msgPoolIdIntern(msgPoolId dest,msgPoolId src, int num){
|
|||
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
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
#include "libnazgul.h"
|
||||
#include "nzg_ids.h"
|
||||
|
||||
/* pid[]
|
||||
liste process demandeurs */
|
||||
|
||||
int msgPoolCreate(
|
||||
msgSpaceId spaceId,
|
||||
int poolIdx,
|
||||
|
@ -12,38 +9,61 @@ int msgPoolCreate(
|
|||
) {
|
||||
|
||||
int poolFd;
|
||||
static int poolNb;
|
||||
sem_t * sem;
|
||||
int bufferTabFd;
|
||||
sem_t * ressourceSem;
|
||||
msgPoolId poolId;
|
||||
msgPoolSemId poolSemId;
|
||||
if (msgPoolIdIntern(poolId,spaceId,poolIdx) == -1){
|
||||
fprintf( stderr, "msgPoolId creation failed for id %s\n",
|
||||
(char*)poolId );
|
||||
msgBufferInfoTabId bufferInfoTabId;
|
||||
msgPoolSemId poolRessourceSemId;
|
||||
|
||||
|
||||
/* 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;
|
||||
}
|
||||
poolFd=shm_open(poolId,O_RDWR|O_CREAT|O_EXCL|O_TRUNC,MSGSPACE_DEFAULT_MODE);
|
||||
if (poolFd == -1 ) {
|
||||
fprintf( stderr, "msgPool : %s creation failed: %s\n",poolId,
|
||||
strerror( errno ) );
|
||||
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){
|
||||
fprintf( stderr, "msgPool resizing failed: %s\n",
|
||||
strerror( errno ) );
|
||||
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);
|
||||
|
||||
|
|
|
@ -15,6 +15,9 @@ int msgSpaceDelete(msgSpaceId spaceId);
|
|||
/* src/nzg_buffer.c */
|
||||
int msgBufferGetFreeIndex(msgPoolData * poolDataTab, int poolIndex);
|
||||
int msgBufferAttachProc(msgPoolData * poolDataTab, int poolIndex, int bufferIndex,void *addr);
|
||||
|
||||
int msgBufferInfoTabIdIntern(
|
||||
msgBufferInfoTabId dest,
|
||||
msgSpaceId src,
|
||||
int num);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue