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

Commit0ac5e5a

Browse files
committed
Allow dynamic allocation of shared memory segments.
Patch by myself and Amit Kapila. Design help from Noah Misch. Reviewby Andres Freund.
1 parentf566515 commit0ac5e5a

File tree

18 files changed

+2470
-29
lines changed

18 files changed

+2470
-29
lines changed

‎configure

Lines changed: 176 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8384,6 +8384,180 @@ if test "$ac_res" != no; then
83848384

83858385
fi
83868386

8387+
{ $as_echo "$as_me:$LINENO: checking for library containing shm_open" >&5
8388+
$as_echo_n "checking for library containing shm_open... " >&6; }
8389+
if test "${ac_cv_search_shm_open+set}" = set; then
8390+
$as_echo_n "(cached) " >&6
8391+
else
8392+
ac_func_search_save_LIBS=$LIBS
8393+
cat >conftest.$ac_ext <<_ACEOF
8394+
/* confdefs.h. */
8395+
_ACEOF
8396+
cat confdefs.h >>conftest.$ac_ext
8397+
cat >>conftest.$ac_ext <<_ACEOF
8398+
/* end confdefs.h. */
8399+
8400+
/* Override any GCC internal prototype to avoid an error.
8401+
Use char because int might match the return type of a GCC
8402+
builtin and then its argument prototype would still apply. */
8403+
#ifdef __cplusplus
8404+
extern "C"
8405+
#endif
8406+
char shm_open ();
8407+
int
8408+
main ()
8409+
{
8410+
return shm_open ();
8411+
;
8412+
return 0;
8413+
}
8414+
_ACEOF
8415+
for ac_lib in '' rt; do
8416+
if test -z "$ac_lib"; then
8417+
ac_res="none required"
8418+
else
8419+
ac_res=-l$ac_lib
8420+
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
8421+
fi
8422+
rm -f conftest.$ac_objext conftest$ac_exeext
8423+
if { (ac_try="$ac_link"
8424+
case "(($ac_try" in
8425+
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
8426+
*) ac_try_echo=$ac_try;;
8427+
esac
8428+
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
8429+
$as_echo "$ac_try_echo") >&5
8430+
(eval "$ac_link") 2>conftest.er1
8431+
ac_status=$?
8432+
grep -v '^ *+' conftest.er1 >conftest.err
8433+
rm -f conftest.er1
8434+
cat conftest.err >&5
8435+
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
8436+
(exit $ac_status); } && {
8437+
test -z "$ac_c_werror_flag" ||
8438+
test ! -s conftest.err
8439+
} && test -s conftest$ac_exeext && {
8440+
test "$cross_compiling" = yes ||
8441+
$as_test_x conftest$ac_exeext
8442+
}; then
8443+
ac_cv_search_shm_open=$ac_res
8444+
else
8445+
$as_echo "$as_me: failed program was:" >&5
8446+
sed 's/^/| /' conftest.$ac_ext >&5
8447+
8448+
8449+
fi
8450+
8451+
rm -rf conftest.dSYM
8452+
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
8453+
conftest$ac_exeext
8454+
if test "${ac_cv_search_shm_open+set}" = set; then
8455+
break
8456+
fi
8457+
done
8458+
if test "${ac_cv_search_shm_open+set}" = set; then
8459+
:
8460+
else
8461+
ac_cv_search_shm_open=no
8462+
fi
8463+
rm conftest.$ac_ext
8464+
LIBS=$ac_func_search_save_LIBS
8465+
fi
8466+
{ $as_echo "$as_me:$LINENO: result: $ac_cv_search_shm_open" >&5
8467+
$as_echo "$ac_cv_search_shm_open" >&6; }
8468+
ac_res=$ac_cv_search_shm_open
8469+
if test "$ac_res" != no; then
8470+
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
8471+
8472+
fi
8473+
8474+
{ $as_echo "$as_me:$LINENO: checking for library containing shm_unlink" >&5
8475+
$as_echo_n "checking for library containing shm_unlink... " >&6; }
8476+
if test "${ac_cv_search_shm_unlink+set}" = set; then
8477+
$as_echo_n "(cached) " >&6
8478+
else
8479+
ac_func_search_save_LIBS=$LIBS
8480+
cat >conftest.$ac_ext <<_ACEOF
8481+
/* confdefs.h. */
8482+
_ACEOF
8483+
cat confdefs.h >>conftest.$ac_ext
8484+
cat >>conftest.$ac_ext <<_ACEOF
8485+
/* end confdefs.h. */
8486+
8487+
/* Override any GCC internal prototype to avoid an error.
8488+
Use char because int might match the return type of a GCC
8489+
builtin and then its argument prototype would still apply. */
8490+
#ifdef __cplusplus
8491+
extern "C"
8492+
#endif
8493+
char shm_unlink ();
8494+
int
8495+
main ()
8496+
{
8497+
return shm_unlink ();
8498+
;
8499+
return 0;
8500+
}
8501+
_ACEOF
8502+
for ac_lib in '' rt; do
8503+
if test -z "$ac_lib"; then
8504+
ac_res="none required"
8505+
else
8506+
ac_res=-l$ac_lib
8507+
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
8508+
fi
8509+
rm -f conftest.$ac_objext conftest$ac_exeext
8510+
if { (ac_try="$ac_link"
8511+
case "(($ac_try" in
8512+
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
8513+
*) ac_try_echo=$ac_try;;
8514+
esac
8515+
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
8516+
$as_echo "$ac_try_echo") >&5
8517+
(eval "$ac_link") 2>conftest.er1
8518+
ac_status=$?
8519+
grep -v '^ *+' conftest.er1 >conftest.err
8520+
rm -f conftest.er1
8521+
cat conftest.err >&5
8522+
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
8523+
(exit $ac_status); } && {
8524+
test -z "$ac_c_werror_flag" ||
8525+
test ! -s conftest.err
8526+
} && test -s conftest$ac_exeext && {
8527+
test "$cross_compiling" = yes ||
8528+
$as_test_x conftest$ac_exeext
8529+
}; then
8530+
ac_cv_search_shm_unlink=$ac_res
8531+
else
8532+
$as_echo "$as_me: failed program was:" >&5
8533+
sed 's/^/| /' conftest.$ac_ext >&5
8534+
8535+
8536+
fi
8537+
8538+
rm -rf conftest.dSYM
8539+
rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
8540+
conftest$ac_exeext
8541+
if test "${ac_cv_search_shm_unlink+set}" = set; then
8542+
break
8543+
fi
8544+
done
8545+
if test "${ac_cv_search_shm_unlink+set}" = set; then
8546+
:
8547+
else
8548+
ac_cv_search_shm_unlink=no
8549+
fi
8550+
rm conftest.$ac_ext
8551+
LIBS=$ac_func_search_save_LIBS
8552+
fi
8553+
{ $as_echo "$as_me:$LINENO: result: $ac_cv_search_shm_unlink" >&5
8554+
$as_echo "$ac_cv_search_shm_unlink" >&6; }
8555+
ac_res=$ac_cv_search_shm_unlink
8556+
if test "$ac_res" != no; then
8557+
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
8558+
8559+
fi
8560+
83878561
# Solaris:
83888562
{ $as_echo "$as_me:$LINENO: checking for library containing fdatasync" >&5
83898563
$as_echo_n "checking for library containing fdatasync... " >&6; }
@@ -19763,7 +19937,8 @@ LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
1976319937

1976419938

1976519939

19766-
for ac_func in cbrt dlopen fdatasync getifaddrs getpeerucred getrlimit mbstowcs_l memmove poll pstat readlink setproctitle setsid sigprocmask symlink sync_file_range towlower utime utimes wcstombs wcstombs_l
19940+
19941+
for ac_func in cbrt dlopen fdatasync getifaddrs getpeerucred getrlimit mbstowcs_l memmove poll pstat readlink setproctitle setsid shm_open sigprocmask symlink sync_file_range towlower utime utimes wcstombs wcstombs_l
1976719942
do
1976819943
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
1976919944
{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5

‎configure.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,8 @@ case $host_os in
883883
esac
884884
AC_SEARCH_LIBS(getopt_long, [getopt gnugetopt])
885885
AC_SEARCH_LIBS(crypt, crypt)
886+
AC_SEARCH_LIBS(shm_open, rt)
887+
AC_SEARCH_LIBS(shm_unlink, rt)
886888
# Solaris:
887889
AC_SEARCH_LIBS(fdatasync, [rt posix4])
888890
# Required for thread_test.c on Solaris 2.5:
@@ -1230,7 +1232,7 @@ PGAC_FUNC_GETTIMEOFDAY_1ARG
12301232
LIBS_including_readline="$LIBS"
12311233
LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
12321234

1233-
AC_CHECK_FUNCS([cbrt dlopen fdatasync getifaddrs getpeerucred getrlimit mbstowcs_l memmove poll pstat readlink setproctitle setsid sigprocmask symlink sync_file_range towlower utime utimes wcstombs wcstombs_l])
1235+
AC_CHECK_FUNCS([cbrt dlopen fdatasync getifaddrs getpeerucred getrlimit mbstowcs_l memmove poll pstat readlink setproctitle setsidshm_opensigprocmask symlink sync_file_range towlower utime utimes wcstombs wcstombs_l])
12341236

12351237
AC_REPLACE_FUNCS(fseeko)
12361238
case $host_os in

‎doc/src/sgml/config.sgml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,6 +1194,32 @@ include 'filename'
11941194
</listitem>
11951195
</varlistentry>
11961196

1197+
<varlistentry id="guc-dynamic-shared-memory-type" xreflabel="dynamic_shared_memory_type">
1198+
<term><varname>dynamic_shared_memory_type</varname> (<type>enum</type>)</term>
1199+
<indexterm>
1200+
<primary><varname>dynamic_shared_memory_type</> configuration parameter</primary>
1201+
</indexterm>
1202+
<listitem>
1203+
<para>
1204+
Specifies the dynamic shared memory implementation that the server
1205+
should use. Possible values are <literal>posix</> (for POSIX shared
1206+
memory allocated using <literal>shm_open</>), <literal>sysv</literal>
1207+
(for System V shared memory allocated via <literal>shmget</>),
1208+
<literal>windows</> (for Windows shared memory), <literal>mmap</>
1209+
(to simulate shared memory using memory-mapped files stored in the
1210+
data directory), and <literal>none</> (to disable this feature).
1211+
Not all values are supported on all platforms; the first supported
1212+
option is the default for that platform. The use of the
1213+
<literal>mmap</> option, which is not the default on any platform,
1214+
is generally discouraged because the operating system may write
1215+
modified pages back to disk repeatedly, increasing system I/O load;
1216+
however, it may be useful for debugging, when the
1217+
<literal>pg_dynshmem</> directory is stored on a RAM disk, or when
1218+
other shared memory facilities are not available.
1219+
</para>
1220+
</listitem>
1221+
</varlistentry>
1222+
11971223
</variablelist>
11981224
</sect2>
11991225

‎src/backend/port/sysv_shmem.c

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,38 +29,14 @@
2929
#endif
3030

3131
#include"miscadmin.h"
32+
#include"portability/mem.h"
3233
#include"storage/ipc.h"
3334
#include"storage/pg_shmem.h"
3435

3536

3637
typedefkey_tIpcMemoryKey;/* shared memory key passed to shmget(2) */
3738
typedefintIpcMemoryId;/* shared memory ID returned by shmget(2) */
3839

39-
#defineIPCProtection(0600)/* access/modify by user only */
40-
41-
#ifdefSHM_SHARE_MMU/* use intimate shared memory on Solaris */
42-
#definePG_SHMAT_FLAGSSHM_SHARE_MMU
43-
#else
44-
#definePG_SHMAT_FLAGS0
45-
#endif
46-
47-
/* Linux prefers MAP_ANONYMOUS, but the flag is called MAP_ANON on other systems. */
48-
#ifndefMAP_ANONYMOUS
49-
#defineMAP_ANONYMOUSMAP_ANON
50-
#endif
51-
52-
/* BSD-derived systems have MAP_HASSEMAPHORE, but it's not present (or needed) on Linux. */
53-
#ifndefMAP_HASSEMAPHORE
54-
#defineMAP_HASSEMAPHORE0
55-
#endif
56-
57-
#definePG_MMAP_FLAGS(MAP_SHARED|MAP_ANONYMOUS|MAP_HASSEMAPHORE)
58-
59-
/* Some really old systems don't define MAP_FAILED. */
60-
#ifndefMAP_FAILED
61-
#defineMAP_FAILED ((void *) -1)
62-
#endif
63-
6440

6541
unsigned longUsedShmemSegID=0;
6642
void*UsedShmemSegAddr=NULL;

‎src/backend/storage/ipc/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ override CFLAGS+= -fno-inline
1515
endif
1616
endif
1717

18-
OBJS =ipc.oipci.opmsignal.oprocarray.oprocsignal.oshmem.oshmqueue.o\
19-
sinval.o sinvaladt.o standby.o
18+
OBJS =dsm_impl.odsm.oipc.oipci.opmsignal.oprocarray.oprocsignal.o\
19+
shmem.o shmqueue.osinval.o sinvaladt.o standby.o
2020

2121
include$(top_srcdir)/src/backend/common.mk

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp