*** empty log message ***

This commit is contained in:
glenux 2004-02-24 09:22:26 +00:00 committed by Glenn Y. Rolland
parent d78d181ef5
commit 7811f7c3df
3 changed files with 51 additions and 20 deletions

View file

@ -87,7 +87,7 @@ int msgBufferInfoTabIdIntern(
return 0;
}
int msgQueueSemIdIntern(
int msgQueueProtSemIdIntern(
msgQueueSemId dest,
msgSpaceId externId,
int queueIdx){
@ -95,9 +95,24 @@ int msgQueueSemIdIntern(
return -1;
}
#ifdef _NZG_REALFILEID
sprintf(dest,"/tmp/nzgQueue-%s-%d",(char *)externId,queueIdx);
sprintf(dest,"/tmp/nzgQueueProtSem-%s-%d",(char *)externId,queueIdx);
#else
sprintf(dest,"/nzgQueue-%s-%d",(char *)externId,queueIdx);
sprintf(dest,"/nzgQueueProtSem-%s-%d",(char *)externId,queueIdx);
#endif
return 0;
}
int msgQueueReadSemIdIntern(
msgQueueSemId dest,
msgSpaceId externId,
int queueIdx){
if (strlen(externId)>MSGSPACE_ID_LEN){
return -1;
}
#ifdef _NZG_REALFILEID
sprintf(dest,"/tmp/nzgQueueReadSem-%s-%d",(char *)externId,queueIdx);
#else
sprintf(dest,"/nzgQueueReadSem-%s-%d",(char *)externId,queueIdx);
#endif
return 0;
}

View file

@ -26,7 +26,8 @@ int msgPoolSemIdIntern(msgPoolSemId destSemId, const msgSpaceId srcPoolId, int p
int msgPoolDataIdIntern(msgPoolDataTabId dest, const msgSpaceId src);
int msgPoolIdIntern(msgPoolId dest, msgPoolId src, int num);
int msgBufferInfoTabIdIntern(msgBufferInfoTabId dest, msgSpaceId src, int num);
int msgQueueSemIdIntern(msgQueueSemId dest, msgSpaceId externId, int queueIdx);
int msgQueueProtSemIdIntern(msgQueueSemId dest, msgSpaceId externId, int queueIdx);
int msgQueueReadSemIdIntern(msgQueueSemId dest, msgSpaceId externId, int queueIdx);
int msgQueueIdIntern(msgQueueId dest, msgSpaceId externId, int queueIdx);
int msgQueueElemIdIntern(msgQueueElemId dest, msgQueueId src, int counter);
int spaceListElemIdIntern(msgSpaceListElemId elemListId, msgSpaceId externId);

View file

@ -4,11 +4,38 @@
msgQueue * queueInit(msgSpaceId externId, int queueIdx) {
int queueFd;
msgQueue * queue;
sem_t * semaphore;
sem_t * semProtectFd;
msgQueueSemId queueSemProtectId;
sem_t * semReadableFd;
msgQueueSemId queueSemReadableId;
msgQueueId queueId;
queue = NULL;
msgQueueProtSemIdIntern(queueSemProtectId,externId,queueIdx);
msgQueueReadSemIdIntern(queueSemReadableId,externId,queueIdx);
// creation du semaphore de lecture
semReadableFd = sem_open(queueSemReadableId,
O_CREAT|O_EXCL, SEM_DEFAULT_MODE, 0);
if(semReadableFd == SEM_FAILED) {
NZG_ERROR("sem_open", queueSemReadableId);
goto ERROR;
}
// creation du semaphore de protection
semProtectFd = sem_open(queueSemProtectId,
O_CREAT|O_EXCL, SEM_DEFAULT_MODE, 1);
if(semProtectFd == SEM_FAILED) {
NZG_ERROR("sem_open", queueSemProtectId);
goto ERROR;
}
if(sem_wait(semProtectFd)==-1){
NZG_ERROR("sem_wait",queueSemProtectId);
goto ERROR;
}
if(msgQueueIdIntern(queueId, externId, queueIdx) < 0) {
return NULL;
}
@ -32,25 +59,13 @@ msgQueue * queueInit(msgSpaceId externId, int queueIdx) {
strcpy(queue->tailId,queue->id);
// creation du semaphore
semaphore = sem_open(queueId, O_CREAT|O_EXCL, SEM_DEFAULT_MODE, 1);
if(semaphore == SEM_FAILED) {
NZG_ERROR("sem_open", queueId);
goto ERROR;
}
if(sem_wait(semaphore)==-1){
NZG_ERROR("sem_wait",queueId);
goto ERROR;
}
/* on ferme tout ce qu'il faut */
sem_close(semaphore);
sem_close(semProtectFd);
close(queueFd);
return queue;
ERROR:
return NULL;
}