8000 Patches from Cyril Velter to make shared-memory-conflict-detection code · postgrespro/postgres_cluster@4bd983b · GitHub
[go: up one dir, main page]

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

Appearance settings

Commit 4bd983b

Browse files
committed
Patches from Cyril Velter to make shared-memory-conflict-detection code
work in BeOS port.
1 parent 5c1b004 commit 4bd983b

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_info inf;
75+
team_info infteam;
76+
int32 cookteam=0;
77+
char name[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+
int32 cook=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+
return 0;
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
#define IPC_EXCL 1024
2121
#define IPC_PRIVATE 234564
2222
#define IPC_NOWAIT 2048
23+
#define IPC_STAT 4096
2324

2425
#define EACCESS 2048
2526
#define EIDRM 4096
@@ -47,6 +48,7 @@ struct sembuf
4748
struct shmid_ds
4849
{
4950
int dummy;
51+
int shm_nattch;
5052
};
5153

5254
int semctl(int semId,int semNum,int flag,union semun);

0 commit comments

Comments
 (0)
0