Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 72a3902

Browse files
committed
Create an internal semaphore API that is not tied to SysV semaphores.
As proof of concept, provide an alternate implementation based on POSIX semaphores. Also push the SysV shared-memory implementation into a separate file so that it can be replaced conveniently.
1 parent 91fc10f commit 72a3902

37 files changed

+1660
-1371
lines changed

configure

+39-1
Original file line numberDiff line numberDiff line change
@@ -15664,6 +15664,42 @@ HAVE_POSIX_SIGNALS=$pgac_cv_func_posix_signals
1566415664
1566515665
1566615666
15667+
# Select semaphore implementation type.
15668+
if test x"$USE_NAMED_POSIX_SEMAPHORES" = x"1" ; then
15669+
15670+
cat >>confdefs.h <<\_ACEOF
15671+
#define USE_NAMED_POSIX_SEMAPHORES 1
15672+
_ACEOF
15673+
15674+
SEMA_IMPLEMENTATION="src/backend/port/posix_sema.c"
15675+
else
15676+
if test x"$USE_UNNAMED_POSIX_SEMAPHORES" = x"1" ; then
15677+
15678+
cat >>confdefs.h <<\_ACEOF
15679+
#define USE_UNNAMED_POSIX_SEMAPHORES 1
15680+
_ACEOF
15681+
15682+
SEMA_IMPLEMENTATION="src/backend/port/posix_sema.c"
15683+
else
15684+
15685+
cat >>confdefs.h <<\_ACEOF
15686+
#define USE_SYSV_SEMAPHORES 1
15687+
_ACEOF
15688+
15689+
SEMA_IMPLEMENTATION="src/backend/port/sysv_sema.c"
15690+
fi
15691+
fi
15692+
15693+
15694+
# Select shared-memory implementation type.
15695+
15696+
cat >>confdefs.h <<\_ACEOF
15697+
#define USE_SYSV_SHARED_MEMORY 1
15698+
_ACEOF
15699+
15700+
SHMEM_IMPLEMENTATION="src/backend/port/sysv_shmem.c"
15701+
15702+
1566715703
if test "$enable_nls" = yes ; then
1566815704
1566915705
echo "$as_me:$LINENO: checking for library containing gettext" >&5
@@ -16724,7 +16760,7 @@ fi
1672416760
ac_config_files="$ac_config_files GNUmakefile src/Makefile.global"
1672516761
1672616762
16727-
ac_config_links="$ac_config_links src/backend/port/dynloader.c:src/backend/port/dynloader/${template}.c src/include/dynloader.h:src/backend/port/dynloader/${template}.h src/include/pg_config_os.h:src/include/port/${template}.h src/Makefile.port:src/makefiles/Makefile.${template}"
16763+
ac_config_links="$ac_config_links src/backend/port/dynloader.c:src/backend/port/dynloader/${template}.c src/backend/port/pg_sema.c:${SEMA_IMPLEMENTATION} src/backend/port/pg_shmem.c:${SHMEM_IMPLEMENTATION} src/include/dynloader.h:src/backend/port/dynloader/${template}.h src/include/pg_config_os.h:src/include/port/${template}.h src/Makefile.port:src/makefiles/Makefile.${template}"
1672816764
1672916765
1673016766
ac_config_headers="$ac_config_headers src/include/pg_config.h"
@@ -17207,6 +17243,8 @@ do
1720717243
"src/Makefile.global" ) CONFIG_FILES="$CONFIG_FILES src/Makefile.global" ;;
1720817244
"src/backend/port/tas.s" ) CONFIG_LINKS="$CONFIG_LINKS src/backend/port/tas.s:src/backend/port/tas/${tas_file}" ;;
1720917245
"src/backend/port/dynloader.c" ) CONFIG_LINKS="$CONFIG_LINKS src/backend/port/dynloader.c:src/backend/port/dynloader/${template}.c" ;;
17246+
"src/backend/port/pg_sema.c" ) CONFIG_LINKS="$CONFIG_LINKS src/backend/port/pg_sema.c:${SEMA_IMPLEMENTATION}" ;;
17247+
"src/backend/port/pg_shmem.c" ) CONFIG_LINKS="$CONFIG_LINKS src/backend/port/pg_shmem.c:${SHMEM_IMPLEMENTATION}" ;;
1721017248
"src/include/dynloader.h" ) CONFIG_LINKS="$CONFIG_LINKS src/include/dynloader.h:src/backend/port/dynloader/${template}.h" ;;
1721117249
"src/include/pg_config_os.h" ) CONFIG_LINKS="$CONFIG_LINKS src/include/pg_config_os.h:src/include/port/${template}.h" ;;
1721217250
"src/Makefile.port" ) CONFIG_LINKS="$CONFIG_LINKS src/Makefile.port:src/makefiles/Makefile.${template}" ;;

configure.in

+23-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dnl Process this file with autoconf to produce a configure script.
2-
dnl $Header: /cvsroot/pgsql/configure.in,v 1.183 2002/04/26 19:47:35 tgl Exp $
2+
dnl $Header: /cvsroot/pgsql/configure.in,v 1.184 2002/05/05 00:03:28 tgl Exp $
33

44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -1168,6 +1168,26 @@ AC_CHECK_TYPES([sig_atomic_t], [], [], [#include <signal.h>])
11681168
PGAC_FUNC_POSIX_SIGNALS
11691169

11701170

1171+
# Select semaphore implementation type.
1172+
if test x"$USE_NAMED_POSIX_SEMAPHORES" = x"1" ; then
1173+
AC_DEFINE(USE_NAMED_POSIX_SEMAPHORES, 1, [Define to select named POSIX semaphores])
1174+
SEMA_IMPLEMENTATION="src/backend/port/posix_sema.c"
1175+
else
1176+
if test x"$USE_UNNAMED_POSIX_SEMAPHORES" = x"1" ; then
1177+
AC_DEFINE(USE_UNNAMED_POSIX_SEMAPHORES, 1, [Define to select unnamed POSIX semaphores])
1178+
SEMA_IMPLEMENTATION="src/backend/port/posix_sema.c"
1179+
else
1180+
AC_DEFINE(USE_SYSV_SEMAPHORES, 1, [Define to select SysV-style semaphores])
1181+
SEMA_IMPLEMENTATION="src/backend/port/sysv_sema.c"
1182+
fi
1183+
fi
1184+
1185+
1186+
# Select shared-memory implementation type.
1187+
AC_DEFINE(USE_SYSV_SHARED_MEMORY, 1, [Define to select SysV-style shared memory])
1188+
SHMEM_IMPLEMENTATION="src/backend/port/sysv_shmem.c"
1189+
1190+
11711191
if test "$enable_nls" = yes ; then
11721192
PGAC_CHECK_GETTEXT
11731193
fi
@@ -1222,6 +1242,8 @@ AC_CONFIG_FILES([GNUmakefile src/Makefile.global])
12221242

12231243
AC_CONFIG_LINKS([
12241244
src/backend/port/dynloader.c:src/backend/port/dynloader/${template}.c
1245+
src/backend/port/pg_sema.c:${SEMA_IMPLEMENTATION}
1246+
src/backend/port/pg_shmem.c:${SHMEM_IMPLEMENTATION}
12251247
src/include/dynloader.h:src/backend/port/dynloader/${template}.h
12261248
src/include/pg_config_os.h:src/include/port/${template}.h
12271249
src/Makefile.port:src/makefiles/Makefile.${template}

src/backend/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Copyright (c) 1994, Regents of the University of California
66
#
7-
# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.77 2002/03/13 00:05:05 petere Exp $
7+
# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.78 2002/05/05 00:03:28 tgl Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -194,7 +194,7 @@ ifeq ($(enable_nls), yes)
194194
endif
195195

196196
distclean: clean
197-
rm -f port/tas.s port/dynloader.c
197+
rm -f port/tas.s port/dynloader.c port/pg_sema.c port/pg_shmem.c
198198

199199
maintainer-clean: distclean
200200
rm -f $(srcdir)/bootstrap/bootparse.c \

src/backend/bootstrap/bootstrap.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.127 2002/04/27 21:24:33 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.128 2002/05/05 00:03:28 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -33,6 +33,7 @@
3333
#include "catalog/pg_type.h"
3434
#include "libpq/pqsignal.h"
3535
#include "miscadmin.h"
36+
#include "storage/ipc.h"
3637
#include "storage/proc.h"
3738
#include "tcop/tcopprot.h"
3839
#include "utils/builtins.h"

src/backend/catalog/namespace.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Portions Copyright (c) 1994, Regents of the University of California
1414
*
1515
* IDENTIFICATION
16-
* $Header: /cvsroot/pgsql/src/backend/catalog/namespace.c,v 1.17 2002/05/01 23:06:41 tgl Exp $
16+
* $Header: /cvsroot/pgsql/src/backend/catalog/namespace.c,v 1.18 2002/05/05 00:03:28 tgl Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
@@ -36,6 +36,7 @@
3636
#include "miscadmin.h"
3737
#include "nodes/makefuncs.h"
3838
#include "storage/backendid.h"
39+
#include "storage/ipc.h"
3940
#include "utils/acl.h"
4041
#include "utils/builtins.h"
4142
#include "utils/catcache.h"

src/backend/commands/async.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.83 2002/03/06 06:09:29 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.84 2002/05/05 00:03:28 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -85,6 +85,7 @@
8585
#include "libpq/libpq.h"
8686
#include "libpq/pqformat.h"
8787
#include "miscadmin.h"
88+
#include "storage/ipc.h"
8889
#include "tcop/tcopprot.h"
8990
#include "utils/fmgroids.h"
9091
#include "utils/ps_status.h"

src/backend/libpq/auth.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.80 2002/04/04 04:25:47 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.81 2002/05/05 00:03:28 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -25,13 +25,16 @@
2525
#endif
2626
#include <netinet/in.h>
2727
#include <arpa/inet.h>
28+
2829
#include "libpq/auth.h"
2930
#include "libpq/crypt.h"
3031
#include "libpq/hba.h"
3132
#include "libpq/libpq.h"
3233
#include "libpq/password.h"
3334
#include "libpq/pqformat.h"
3435
#include "miscadmin.h"
36+
#include "storage/ipc.h"
37+
3538

3639
static void sendAuthRequest(Port *port, AuthRequest areq);
3740
static int old_be_recvauth(Port *port);

src/backend/libpq/pqcomm.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
3030
* Portions Copyright (c) 1994, Regents of the University of California
3131
*
32-
* $Id: pqcomm.c,v 1.132 2002/04/21 01:03:33 tgl Exp $
32+
* $Id: pqcomm.c,v 1.133 2002/05/05 00:03:28 tgl Exp $
3333
*
3434
*-------------------------------------------------------------------------
3535
*/
@@ -79,6 +79,7 @@
7979

8080
#include "libpq/libpq.h"
8181
#include "miscadmin.h"
82+
#include "storage/ipc.h"
8283

8384

8485
static void pq_close(void);

src/backend/port/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
# be converted to Method 2.
1414
#
1515
# IDENTIFICATION
16-
# $Header: /cvsroot/pgsql/src/backend/port/Makefile,v 1.11 2002/03/13 00:05:06 petere Exp $
16+
# $Header: /cvsroot/pgsql/src/backend/port/Makefile,v 1.12 2002/05/05 00:03:28 tgl Exp $
1717
#
1818
#-------------------------------------------------------------------------
1919

2020
subdir = src/backend/port
2121
top_builddir = ../../..
2222
include $(top_builddir)/src/Makefile.global
2323

24-
OBJS = dynloader.o
24+
OBJS = dynloader.o pg_sema.o pg_shmem.o
2525

2626
OBJS += $(GETHOSTNAME) $(GETRUSAGE) $(INET_ATON) $(ISINF) $(MEMCMP) \
2727
$(MISSING_RANDOM) $(SNPRINTF) $(SRANDOM) $(STRCASECMP) $(STRERROR) \

0 commit comments

Comments
 (0)