Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4bd983b

Browse files
committed
Patches from Cyril Velter to make shared-memory-conflict-detection code
work in BeOS port.
1 parent5c1b004 commit4bd983b

File tree

4 files changed

+40
-9
lines changed

4 files changed

+40
-9
lines changed

‎src/backend/port/beos/shm.c

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
* shm.c
44
* BeOS System V Shared Memory Emulation
55
*
6-
* Copyright (c) 1999-2000, Cyril VELTER
6+
* Copyright (c) 1999-2001, Cyril VELTER
77
*
88
*-------------------------------------------------------------------------
99
*/
1010

1111
#include"postgres.h"
1212
#include<stdio.h>
1313
#include<OS.h>
14+
#include<errno.h>
1415

1516
/* Emulating SYS shared memory with beos areas. WARNING : fork clone
1617
areas in copy on write mode */
@@ -68,11 +69,30 @@ int shmctl(int shmid, int flag, struct shmid_ds* dummy)
6869
}
6970
if (flag==IPC_STAT)
7071
{
71-
/* Is there a way to check existence of an area given its ID?
72-
* For now, punt and assume it does not exist.
73-
*/
74-
errno=EINVAL;
75-
return-1;
72+
/* Find any SYSV area with the shmid in its name */
73+
74+
area_infoinf;
75+
team_infoinfteam;
76+
int32cookteam=0;
77+
charname[50];
78+
sprintf(name,"SYSV_IPC %d",shmid);
79+
80+
dummy->shm_nattch=0;
81+
82+
while (get_next_team_info(&cookteam,&infteam)==B_OK)
83+
{
84+
int32cook=0;
85+
while (get_next_area_info(infteam.team,&cook,&inf)==B_OK)
86+
{
87+
if (strcmp(name,inf.name)==0)
88+
{
89+
dummy->shm_nattch++;
90+
}
91+
}
92+
}
93+
94+
errno=0;
95+
return0;
7696
}
7797
errno=EINVAL;
7898
return-1;

‎src/backend/port/beos/support.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* support.c
44
* BeOS Support functions
55
*
6-
* Copyright (c) 1999-2000, Cyril VELTER
6+
* Copyright (c) 1999-2001, Cyril VELTER
77
*
88
*-------------------------------------------------------------------------
99
*/
@@ -279,6 +279,8 @@ void beos_backend_startup(void)
279279
delete_area(inf.area);
280280
/* Find the postmaster area */
281281
area_postmaster=find_area(inf.name);
282+
/* Compute new area name */
283+
sprintf(nvnom,"SYSV_IPC %d",area_postmaster);
282284
/* Clone it at the exact same address */
283285
clone_area(nvnom,&area_address,B_CLONE_ADDRESS,B_READ_AREA|B_WRITE_AREA,area_postmaster);
284286
}

‎src/backend/utils/init/miscinit.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.62 2001/03/13 01:17:06 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.63 2001/03/18 18:22:08 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -540,11 +540,18 @@ CreateLockFile(const char *filename, bool amPostmaster,
540540

541541
/*
542542
* Check to see if the other process still exists
543+
*
544+
* Normally kill() will fail with ESRCH if the given PID doesn't
545+
* exist. BeOS returns EINVAL for some silly reason, however.
543546
*/
544547
if (other_pid!=my_pid)
545548
{
546549
if (kill(other_pid,0)==0||
547-
errno!=ESRCH)
550+
(errno!=ESRCH
551+
#ifdef__BEOS__
552+
&&errno!=EINVAL
553+
#endif
554+
))
548555
{
549556
/* lockfile belongs to a live process */
550557
fprintf(stderr,"Lock file \"%s\" already exists.\n",

‎src/include/port/beos.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ typedef unsigned char slock_t;
2020
#defineIPC_EXCL 1024
2121
#defineIPC_PRIVATE 234564
2222
#defineIPC_NOWAIT2048
23+
#defineIPC_STAT 4096
2324

2425
#defineEACCESS 2048
2526
#defineEIDRM 4096
@@ -47,6 +48,7 @@ struct sembuf
4748
structshmid_ds
4849
{
4950
intdummy;
51+
intshm_nattch;
5052
};
5153

5254
intsemctl(intsemId,intsemNum,intflag,unionsemun);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp