Re: IPC on win32 - additions for 6.5.2 and current trees

From: yutaka tanida <yutaka(at)marin(dot)or(dot)jp>
To: pgsql-hackers(at)hub(dot)org
Cc: inoue(at)tpf(dot)co(dot)jp
Subject: Re: IPC on win32 - additions for 6.5.2 and current trees
Date: 1999-08-31 08:38:59
Message-ID: 37CB94A31ED.C8A2YUTAKA@malgate.marin.or.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Daniel Horak wrote:

> Hi,
>
> please add the file ipc.patch (patch for the cygipc library) into src/win32
> directory and apply the patch for README.NT (readme.patch). I think it
> should go into both the 6.5.2 and current trees.
>
> I have no reaction from the author of the cygipc library yet, so it will be
> better to include the patch into the sources of PostgreSQL

I propose more patch against cygipc.

Hiroshi Inoue (inoue(at)tpf(dot)co(dot)jp) found another backend freezing problem.
He also found semop() in cygipc can't decrement semaphore value
correctly (Only -1 is supported).

I create follwing patch fixes these issues.

I'm sorry for my poor English.

*** sem.c.orig_ Tue Aug 17 14:19:37 1999
--- sem.c Tue Aug 31 16:59:49 1999
***************
*** 204,210 ****
{
CloseHandle ( LHandle ) ;
}
! LHandle = CreateSemaphore(NULL, 0, 0x7FFFFFFF, LBuff) ;
if( LHandle == NULL )
{
printf( "Creation de Semaphore \"Sem\" impossible\n" ) ;
--- 204,210 ----
{
CloseHandle ( LHandle ) ;
}
! LHandle = CreateSemaphore(NULL, 0, 1, LBuff) ;
if( LHandle == NULL )
{
printf( "Creation de Semaphore \"Sem\" impossible\n" ) ;
***************
*** 374,388 ****
debug_printf("do_semop : return -EACCES\n");
CYGWIN32_IPCNT_RETURN (-EACCES) ;
}
! ReleaseSemaphore(LHandle, sop->sem_op, &LVal) ;
! shareadrsem->current_nb[id].current_nb[sop->sem_num] +=
! sop->sem_op ;
sem_deconnect() ;
} else {
if( sop->sem_flg == IPC_NOWAIT )
{
! LRet = WaitForSingleObject(LHandle, 0) ;
! if( LRet == WAIT_TIMEOUT )
{
debug_printf("do_semop : return -EAGAIN\n");
CYGWIN32_IPCNT_RETURN (-EAGAIN) ;
--- 374,387 ----
debug_printf("do_semop : return -EACCES\n");
CYGWIN32_IPCNT_RETURN (-EACCES) ;
}
! shareadrsem->current_nb[id].current_nb[sop->sem_num] +=
! sop->sem_op ;
sem_deconnect() ;
+ ReleaseSemaphore(LHandle, 1 , &LVal) ;
} else {
if( sop->sem_flg == IPC_NOWAIT )
{
! if( sop->sem_op + shareadrsem->current_nb[id].current_nb[sop->sem_num] <0 )
{
debug_printf("do_semop : return -EAGAIN\n");
CYGWIN32_IPCNT_RETURN (-EAGAIN) ;
***************
*** 392,407 ****
debug_printf("do_semop : return -EACCES\n");
CYGWIN32_IPCNT_RETURN (-EACCES) ;
}
! shareadrsem->current_nb[id].current_nb[sop->sem_num] -= 1 ;
sem_deconnect() ;
} else {
! LRet = WaitForSingleObject(LHandle, INFINITE) ;
if (sem_connect() == 0)
{
debug_printf("do_semop : return -EACCES\n");
CYGWIN32_IPCNT_RETURN (-EACCES) ;
}
! shareadrsem->current_nb[id].current_nb[sop->sem_num] -= 1 ;
sem_deconnect() ;
}
}
--- 391,408 ----
debug_printf("do_semop : return -EACCES\n");
CYGWIN32_IPCNT_RETURN (-EACCES) ;
}
! shareadrsem->current_nb[id].current_nb[sop->sem_num] += sop->sem_op;
sem_deconnect() ;
} else {
! while(sop->sem_op + shareadrsem->current_nb[id].current_nb[sop->sem_num] <0)
! LRet = WaitForSingleObject(LHandle, INFINITE) ;
!
if (sem_connect() == 0)
{
debug_printf("do_semop : return -EACCES\n");
CYGWIN32_IPCNT_RETURN (-EACCES) ;
}
! shareadrsem->current_nb[id].current_nb[sop->sem_num] += sop->sem_op ;
sem_deconnect() ;
}
}
***************
*** 452,458 ****
char LBuff[100] ;
HANDLE LHandle ;
long LPrevious ;
- int LIndex;

debug_printf("semctl : semid=%X semnum=%X cmd=0x%02X arg=%p\n",semid,semnum,cmd,arg);
if (semid < 0 || semnum < 0 || cmd < 0)
--- 453,458 ----
***************
*** 585,606 ****
if( LHandle != NULL )
{
if( arg.val > shareadrsem->current_nb[id].current_nb[semnum] )
! {
! ReleaseSemaphore(LHandle,
! arg.val-shareadrsem->current_nb[id].current_nb[semnum],
! &LPrevious) ;
! }
! else if (arg.val <
! shareadrsem->current_nb[id].current_nb[semnum] )
! {
! for( LIndex = arg.val;
! LIndex < shareadrsem->current_nb[id].current_nb[semnum];
! LIndex++ )
! {
! WaitForSingleObject(LHandle, 0) ;
! }
! }
! shareadrsem->current_nb[id].current_nb[semnum] = arg.val ;
}
debug_printf("semctl : SETVAL : return 0\n");
CYGWIN32_IPCNT_RETURN_DECONNECT (0);
--- 585,592 ----
if( LHandle != NULL )
{
if( arg.val > shareadrsem->current_nb[id].current_nb[semnum] )
! ReleaseSemaphore(LHandle,1,&LPrevious) ;
! shareadrsem->current_nb[id].current_nb[semnum] = arg.val ;
}
debug_printf("semctl : SETVAL : return 0\n");
CYGWIN32_IPCNT_RETURN_DECONNECT (0);

--
Yutaka tanida / S34 Co., Ltd.
tanida(at)s34(dot)co(dot)jp (Office)
yutaka(at)marin(dot)or(dot)jp(Private, or if you *HATE* Microsoft Outlook)

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tatsuo Ishii 1999-08-31 09:29:21 Re: [HACKERS] Implications of multi-byte support in a distribution
Previous Message Oleg Broytmann 1999-08-31 08:36:04 Re: [HACKERS] Implications of multi-byte support in a distribution