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

From: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
To: yutaka tanida <yutaka(at)marin(dot)or(dot)jp>
Cc: pgsql-hackers(at)hub(dot)org, inoue(at)tpf(dot)co(dot)jp
Subject: Re: [HACKERS] Re: IPC on win32 - additions for 6.5.2 and current trees
Date: 1999-09-27 20:49:08
Message-ID: 199909272049.QAA16695@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

NT folks, I assume this patch is no longer needed.

> 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)
>
>
> ************
>
>

--
Bruce Momjian | http://www.op.net/~candle
maillist(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 1999-09-27 20:54:12 Re: [HACKERS] PostgreSQL 6.5.2
Previous Message Bruce Momjian 1999-09-27 20:41:08 Re: [HACKERS] PostgreSQL 6.5.2