Fixed DragonFly BSD shared memory implementation.
This commit is contained in:
20
auto/os/conf
20
auto/os/conf
@@ -167,6 +167,26 @@ case "$NXT_SYSTEM" in
|
||||
NXT_LIBS="$NXT_PTHREAD"
|
||||
;;
|
||||
|
||||
DragonFly)
|
||||
nxt_have=NXT_DRAGONFLY . auto/have
|
||||
|
||||
NXT_STATIC_LINK="ar -r -c"
|
||||
NXT_SHARED_LINK="\$(CC) -shared"
|
||||
NXT_SHARED_LOCAL_LINK="\$(CC) -shared"
|
||||
NXT_MODULE_LINK="\$(CC) -shared"
|
||||
|
||||
# "-Wl,-E" exports symbols of executable file.
|
||||
NXT_EXEC_LINK="\$(CC) -Wl,-E"
|
||||
NXT_SHARED_LOCAL_EXEC_LINK=
|
||||
|
||||
NXT_LIB_STATIC="libnxt.a"
|
||||
NXT_LIB_SHARED="libnxt.so"
|
||||
NXT_LIB_SHARED_LOCAL="$NXT_BUILD_DIR/libnxt.so"
|
||||
|
||||
NXT_LIBM="-lm"
|
||||
NXT_LIBS="$NXT_LIBRT $NXT_PTHREAD"
|
||||
;;
|
||||
|
||||
AIX)
|
||||
nxt_have=NXT_AIX . auto/have
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ case "$NXT_SYSTEM" in
|
||||
CC=${CC:-cc}
|
||||
;;
|
||||
|
||||
FreeBSD | NetBSD | OpenBSD)
|
||||
FreeBSD | NetBSD | OpenBSD | DragonFly)
|
||||
NXT_SYSTEM_VERSION=`uname -r 2>/dev/null`
|
||||
NXT_SYSTEM_PLATFORM=`uname -m 2>/dev/null`
|
||||
echo=echo
|
||||
|
||||
49
auto/shmem
49
auto/shmem
@@ -3,6 +3,8 @@
|
||||
# Copyright (C) NGINX, Inc.
|
||||
|
||||
|
||||
NXT_SHM_PREFIX="/"
|
||||
|
||||
# FreeBSD, Solaris, MacOSX
|
||||
|
||||
nxt_feature="shm_open()"
|
||||
@@ -12,10 +14,12 @@ nxt_feature_incs=
|
||||
nxt_feature_libs=
|
||||
nxt_feature_test="#include <sys/mman.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
int main() {
|
||||
int ret;
|
||||
static char name[] = \"/unit.configure\";
|
||||
|
||||
shm_unlink(name);
|
||||
@@ -25,8 +29,10 @@ nxt_feature_test="#include <sys/mman.h>
|
||||
if (fd == -1)
|
||||
return 1;
|
||||
|
||||
ret = (access(name, F_OK) == 0);
|
||||
shm_unlink(name);
|
||||
return 0;
|
||||
|
||||
return ret;
|
||||
}"
|
||||
. auto/feature
|
||||
|
||||
@@ -45,6 +51,40 @@ if [ $nxt_found = no ]; then
|
||||
fi
|
||||
|
||||
|
||||
if [ $nxt_found = no ]; then
|
||||
|
||||
# DragonFly has no separate namespace for shm_open().
|
||||
|
||||
nxt_feature="shm_open() in /tmp directory"
|
||||
nxt_feature_libs=
|
||||
nxt_feature_test="#include <sys/mman.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
int main() {
|
||||
static char name[] = \"/tmp/unit.configure\";
|
||||
|
||||
shm_unlink(name);
|
||||
|
||||
int fd = shm_open(name, O_CREAT | O_EXCL | O_RDWR,
|
||||
S_IRUSR | S_IWUSR);
|
||||
if (fd == -1)
|
||||
return 1;
|
||||
|
||||
shm_unlink(name);
|
||||
return 0;
|
||||
}"
|
||||
. auto/feature
|
||||
|
||||
if [ $nxt_found = yes ]; then
|
||||
NXT_SHM_PREFIX="/tmp/"
|
||||
fi
|
||||
fi
|
||||
|
||||
nxt_shm_open_found=$nxt_found
|
||||
|
||||
|
||||
# Linux
|
||||
|
||||
nxt_feature="memfd_create()"
|
||||
@@ -67,3 +107,10 @@ nxt_feature_test="#include <linux/memfd.h>
|
||||
}"
|
||||
. auto/feature
|
||||
|
||||
|
||||
if [ "$nxt_shm_open_found$nxt_found" = nono ]; then
|
||||
$echo
|
||||
$echo $0: error: no shared memory implementation found.
|
||||
$echo
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
2
configure
vendored
2
configure
vendored
@@ -145,6 +145,8 @@ cat << END >> $NXT_AUTO_CONFIG_H
|
||||
#define NXT_DEBUG $nxt_debug
|
||||
#endif
|
||||
|
||||
#define NXT_SHM_PREFIX "$NXT_SHM_PREFIX"
|
||||
|
||||
END
|
||||
|
||||
. auto/test_build
|
||||
|
||||
@@ -49,7 +49,8 @@ nxt_go_new_port_mmap(nxt_go_process_t *process, nxt_port_id_t id,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
name_len = snprintf(name, sizeof(name) - 1, "/unit.go.%p", name);
|
||||
name_len = snprintf(name, sizeof(name) - 1,
|
||||
NXT_SHM_PREFIX "unit.go.%p", name);
|
||||
|
||||
#if (NXT_HAVE_MEMFD_CREATE)
|
||||
|
||||
|
||||
@@ -280,7 +280,7 @@ nxt_port_new_port_mmap(nxt_task_t *task, nxt_process_t *process,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
p = nxt_sprintf(name, name + sizeof(name), "/unit.%PI.%uxD",
|
||||
p = nxt_sprintf(name, name + sizeof(name), NXT_SHM_PREFIX "unit.%PI.%uxD",
|
||||
nxt_pid, nxt_random(&task->thread->random));
|
||||
*p = '\0';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user