*** empty log message ***

This commit is contained in:
glenux 2004-02-25 11:12:03 +00:00 committed by Glenn Y. Rolland
parent f2fe507cee
commit 97ef840f3a
11 changed files with 62 additions and 30 deletions

View file

@ -19,6 +19,9 @@ printf("Locking %s\n",space->poolDataTabSemId);
NZG_ERROR("sem_wait",space->poolDataTabSemId);
goto ERROR;
}
int semval=0;
sem_getvalue(poolDataTabSemFd,&semval);
printf("(AfternValue:%d)\n",semval);
sem_close(poolDataTabSemFd);

View file

@ -4,15 +4,12 @@
int msgPoolDataTabUnlock(msgSpace * space){
sem_t * poolDataTabSemFd;
printf("Locking %s\n",space->poolDataTabSemId);
printf("Unlocking %s\n",space->poolDataTabSemId);
poolDataTabSemFd=sem_open(
space->poolDataTabSemId
,O_CREAT,
SEM_DEFAULT_MODE,
1);
int semval=0;
sem_getvalue(poolDataTabSemFd,&semval);
printf("(Value:%d)",semval);
if(poolDataTabSemFd==SEM_FAILED){
NZG_ERROR("sem_open",space->poolDataTabSemId);
goto ERROR;
@ -22,6 +19,9 @@ printf("Locking %s\n",space->poolDataTabSemId);
NZG_ERROR("sem_post",space->poolDataTabSemId);
goto ERROR;
}
int semval=0;
sem_getvalue(poolDataTabSemFd,&semval);
printf("(AfternValue:%d)\n",semval);
sem_close(poolDataTabSemFd);

View file

@ -6,6 +6,9 @@ int msgPut(msgSpace * space,int queueIndex, void * addr){
int poolIndex;
int bufferIndex;
int err;
msgQueueElemId newElemId;
msgQueueElem * queueElem;
msgPoolDataTabLock(space);
poolDataTabAddr=msgPoolDataTabOpen(space);
if (poolDataTabAddr == NULL){
@ -28,10 +31,8 @@ int msgPut(msgSpace * space,int queueIndex, void * addr){
msgQueueProtLock(space->externId,queueIndex);
queue = msgQueueOpen(queueId);
// TODO:creer un element vide
msgQueueElemId newElemId;
msgQueueElem * queueElem;
// creer un element vide
msgQueueElemCreate(newElemId,queueId,queue->elemCounter);
// ouvrir l'element
queueElem=msgQueueElemOpen(newElemId);

View file

@ -12,7 +12,6 @@ msgQueue * msgQueueInit(msgSpaceId externId, int queueIdx) {
queue = NULL;
printf("ploped init queue ?\n");
msgQueueProtSemIdIntern(queueSemProtectId,externId,queueIdx);
msgQueueReadSemIdIntern(queueSemReadableId,externId,queueIdx);
@ -27,16 +26,16 @@ msgQueue * msgQueueInit(msgSpaceId externId, int queueIdx) {
// creation du semaphore de protection
semProtectFd = sem_open(queueSemProtectId,
O_CREAT|O_EXCL, SEM_DEFAULT_MODE, 1);
O_CREAT|O_EXCL, SEM_DEFAULT_MODE, 0);
if(semProtectFd == SEM_FAILED) {
NZG_ERROR("sem_open", queueSemProtectId);
goto ERROR;
}
if(sem_wait(semProtectFd)==-1){
/* if(sem_wait(semProtectFd)==-1){
NZG_ERROR("sem_wait",queueSemProtectId);
goto ERROR;
}
} */
if(msgQueueIdIntern(queueId, externId, queueIdx) < 0) {
return NULL;
@ -44,27 +43,26 @@ msgQueue * msgQueueInit(msgSpaceId externId, int queueIdx) {
queueFd = shm_open(queueId, O_RDWR|O_CREAT|O_EXCL|O_TRUNC, MSGSPACE_DEFAULT_MODE);
if(queueFd == -1) {
fprintf(stderr, "queueInit : %s initialisation failed: %s\n", queueId, strerror(errno));
return NULL;
NZG_ERROR("shm_open : queueInit",queueId);
return NULL;
}
if(ftruncate(queueFd, sizeof(* queue)) == -1) {
fprintf( stderr, "Queue resizing failed: %s\n",
strerror( errno ) );
return NULL;
}
if(ftruncate(queueFd, sizeof(msgQueue)) == -1) {
fprintf( stderr, "Queue resizing failed: %s\n",
strerror( errno ) );
return NULL;
}
queue=msgQueueOpen(queueId);
/* on remplit la structure msgQueue */
queue->elemCounter = 0;
strcpy(queue->id,queueId);
strcpy(queue->headId,queue->id);
strcpy(queue->tailId,queue->id);
/* on ferme tout ce qu'il faut */
sem_close(semProtectFd);
close(queueFd);
msgQueueProtUnlock(externId,queueIdx);
return queue;
ERROR:

View file

@ -6,7 +6,8 @@ int msgQueueProtLock(msgSpaceId externId,int queueIdx){
msgQueueSemId queueSemId;
msgQueueProtSemIdIntern(queueSemId,externId,queueIdx);
queueSemFd=sem_open(queueSemId,O_CREAT|O_EXCL,SEM_DEFAULT_MODE,1);
printf("Locking %s\n",queueSemId);
queueSemFd=sem_open(queueSemId,O_CREAT,SEM_DEFAULT_MODE,1);
if(queueSemFd==SEM_FAILED){
NZG_ERROR("sem_open",queueSemId);
goto ERROR;
@ -16,6 +17,12 @@ int msgQueueProtLock(msgSpaceId externId,int queueIdx){
NZG_ERROR("sem_wait",queueSemId);
goto ERROR;
}
int semval=0;
sem_getvalue(queueSemFd,&semval);
printf("(AfterValue:%d)\n",semval);
sem_close(queueSemFd);
sem_close(queueSemFd);

View file

@ -6,7 +6,9 @@ int msgQueueProtUnlock(msgSpaceId externId,int queueIdx){
msgQueueSemId queueSemId;
msgQueueProtSemIdIntern(queueSemId,externId,queueIdx);
queueSemFd=sem_open(queueSemId,O_CREAT|O_EXCL,SEM_DEFAULT_MODE,1);
printf("Unlocking %s\n",queueSemId);
queueSemFd=sem_open(queueSemId,O_CREAT,SEM_DEFAULT_MODE,1);
if(queueSemFd==SEM_FAILED){
NZG_ERROR("sem_open",queueSemId);
goto ERROR;
@ -16,6 +18,9 @@ int msgQueueProtUnlock(msgSpaceId externId,int queueIdx){
NZG_ERROR("sem_post",queueSemId);
goto ERROR;
}
int semval=0;
sem_getvalue(queueSemFd,&semval);
printf("(AfterValue:%d)\n",semval);
sem_close(queueSemFd);

View file

@ -6,7 +6,8 @@ int msgQueueReadLock(msgSpaceId externId,int queueIdx){
msgQueueSemId queueSemId;
msgQueueReadSemIdIntern(queueSemId,externId,queueIdx);
queueSemFd=sem_open(queueSemId,O_CREAT|O_EXCL,SEM_DEFAULT_MODE,1);
printf("Locking %s\n",queueSemId);
queueSemFd=sem_open(queueSemId,O_CREAT,SEM_DEFAULT_MODE,1);
if(queueSemFd==SEM_FAILED){
NZG_ERROR("sem_open",queueSemId);
goto ERROR;
@ -16,6 +17,12 @@ int msgQueueReadLock(msgSpaceId externId,int queueIdx){
NZG_ERROR("sem_wait",queueSemId);
goto ERROR;
}
int semval=0;
sem_getvalue(queueSemFd,&semval);
printf("(AfterValue:%d)\n",semval);
sem_close(queueSemFd);
sem_close(queueSemFd);

View file

@ -6,7 +6,7 @@ int msgQueueReadTryLock(msgSpaceId externId,int queueIdx){
msgQueueSemId queueSemId;
msgQueueReadSemIdIntern(queueSemId,externId,queueIdx);
queueSemFd=sem_open(queueSemId,O_CREAT|O_EXCL,SEM_DEFAULT_MODE,1);
queueSemFd=sem_open(queueSemId,O_CREAT,SEM_DEFAULT_MODE,1);
if(queueSemFd==SEM_FAILED){
NZG_ERROR("sem_open",queueSemId);
goto ERROR;
@ -16,6 +16,13 @@ int msgQueueReadTryLock(msgSpaceId externId,int queueIdx){
NZG_ERROR("sem_wait",queueSemId);
goto ERROR;
}
printf("Locking %s\n",queueSemId);
int semval=0;
sem_getvalue(queueSemFd,&semval);
printf("(AfterValue:%d)\n",semval);
sem_close(queueSemFd);
sem_close(queueSemFd);

View file

@ -6,7 +6,8 @@ int msgQueueReadUnlock(msgSpaceId externId,int queueIdx){
msgQueueSemId queueSemId;
msgQueueReadSemIdIntern(queueSemId,externId,queueIdx);
queueSemFd=sem_open(queueSemId,O_CREAT|O_EXCL,SEM_DEFAULT_MODE,1);
printf("Unlocking %s\n",queueSemId);
queueSemFd=sem_open(queueSemId,O_CREAT,SEM_DEFAULT_MODE,1);
if(queueSemFd==SEM_FAILED){
NZG_ERROR("sem_open",queueSemId);
goto ERROR;
@ -16,6 +17,10 @@ int msgQueueReadUnlock(msgSpaceId externId,int queueIdx){
NZG_ERROR("sem_post",queueSemId);
goto ERROR;
}
int semval=0;
sem_getvalue(queueSemFd,&semval);
printf("(AfterValue:%d)\n",semval);
sem_close(queueSemFd);

View file

@ -95,8 +95,6 @@ msgSpace * msgSpaceCreate(
}
sem_close(mSDataTabSemFd);
// msgPoolDataTabLock(space);
/* attacher le tableau des msgPoolData */
poolDataTabAddr=msgPoolDataTabCreate(space);
if (poolDataTabAddr == NULL){

View file

@ -26,6 +26,7 @@ int main(void) {
}
printf("CREATION ------------------ ok\n");
sleep(1);
pid_t pid=fork();
if (pid ==0){