# HG changeset patch # User Maxim Dounin # Date 1454599821 -10800 # Node ID 7142b04337d6e273f55b0886eefafeecd9ed4e14 # Parent cf5e822cf470579b74bf5c3f2b5460f9909ab84e Dynamic modules: dlopen() support. diff -r cf5e822cf470 -r 7142b04337d6 auto/lib/openssl/conf --- a/auto/lib/openssl/conf Thu Feb 04 18:30:21 2016 +0300 +++ b/auto/lib/openssl/conf Thu Feb 04 18:30:21 2016 +0300 @@ -32,7 +32,6 @@ CORE_DEPS="$CORE_DEPS $OPENSSL/.openssl/include/openssl/ssl.h" CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libssl.a" CORE_LIBS="$CORE_LIBS $OPENSSL/.openssl/lib/libcrypto.a" - CORE_LIBS="$CORE_LIBS $NGX_LIBDL" if [ "$NGX_PLATFORM" = win32 ]; then CORE_LIBS="$CORE_LIBS -lgdi32 -lcrypt32 -lws2_32" @@ -106,7 +105,7 @@ if [ $ngx_found = yes ]; then have=NGX_SSL . auto/have CORE_INCS="$CORE_INCS $ngx_feature_path" - CORE_LIBS="$CORE_LIBS $ngx_feature_libs $NGX_LIBDL" + CORE_LIBS="$CORE_LIBS $ngx_feature_libs" OPENSSL=YES fi fi diff -r cf5e822cf470 -r 7142b04337d6 auto/sources --- a/auto/sources Thu Feb 04 18:30:21 2016 +0300 +++ b/auto/sources Thu Feb 04 18:30:21 2016 +0300 @@ -152,6 +152,7 @@ src/os/unix/ngx_socket.h \ src/os/unix/ngx_os.h \ src/os/unix/ngx_user.h \ + src/os/unix/ngx_dlopen.h \ src/os/unix/ngx_process_cycle.h" # add to UNIX_DEPS @@ -183,6 +184,7 @@ src/os/unix/ngx_setproctitle.c \ src/os/unix/ngx_posix_init.c \ src/os/unix/ngx_user.c \ + src/os/unix/ngx_dlopen.c \ src/os/unix/ngx_process_cycle.c" POSIX_DEPS=src/os/unix/ngx_posix_config.h @@ -228,6 +230,7 @@ src/os/win32/ngx_socket.h \ src/os/win32/ngx_os.h \ src/os/win32/ngx_user.h \ + src/os/win32/ngx_dlopen.h \ src/os/win32/ngx_process_cycle.h" WIN32_CONFIG=src/os/win32/ngx_win32_config.h @@ -248,6 +251,7 @@ src/os/win32/ngx_wsasend_chain.c \ src/os/win32/ngx_win32_init.c \ src/os/win32/ngx_user.c \ + src/os/win32/ngx_dlopen.c \ src/os/win32/ngx_event_log.c \ src/os/win32/ngx_process_cycle.c \ src/event/ngx_event_acceptex.c" diff -r cf5e822cf470 -r 7142b04337d6 auto/unix --- a/auto/unix Thu Feb 04 18:30:21 2016 +0300 +++ b/auto/unix Thu Feb 04 18:30:21 2016 +0300 @@ -255,7 +255,7 @@ ngx_feature="dlopen()" -ngx_feature_name= +ngx_feature_name="NGX_HAVE_DLOPEN" ngx_feature_run=no ngx_feature_incs="#include " ngx_feature_path= @@ -271,7 +271,7 @@ . auto/feature if [ $ngx_found = yes ]; then - NGX_LIBDL="-ldl" + CORE_LIBS="$CORE_LIBS -ldl" fi fi diff -r cf5e822cf470 -r 7142b04337d6 src/core/ngx_core.h --- a/src/core/ngx_core.h Thu Feb 04 18:30:21 2016 +0300 +++ b/src/core/ngx_core.h Thu Feb 04 18:30:21 2016 +0300 @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include diff -r cf5e822cf470 -r 7142b04337d6 src/os/unix/ngx_darwin_config.h --- a/src/os/unix/ngx_darwin_config.h Thu Feb 04 18:30:21 2016 +0300 +++ b/src/os/unix/ngx_darwin_config.h Thu Feb 04 18:30:21 2016 +0300 @@ -48,6 +48,8 @@ #include #include +#include + #ifndef IOV_MAX #define IOV_MAX 64 diff -r cf5e822cf470 -r 7142b04337d6 src/os/unix/ngx_dlopen.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/os/unix/ngx_dlopen.c Thu Feb 04 18:30:21 2016 +0300 @@ -0,0 +1,28 @@ + +/* + * Copyright (C) Maxim Dounin + * Copyright (C) Nginx, Inc. + */ + + +#include +#include + + +#if (NGX_HAVE_DLOPEN) + +char * +ngx_dlerror(void) +{ + char *err; + + err = (char *) dlerror(); + + if (err == NULL) { + return ""; + } + + return err; +} + +#endif diff -r cf5e822cf470 -r 7142b04337d6 src/os/unix/ngx_dlopen.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/os/unix/ngx_dlopen.h Thu Feb 04 18:30:21 2016 +0300 @@ -0,0 +1,31 @@ + +/* + * Copyright (C) Maxim Dounin + * Copyright (C) Nginx, Inc. + */ + + +#ifndef _NGX_DLOPEN_H_INCLUDED_ +#define _NGX_DLOPEN_H_INCLUDED_ + + +#include +#include + + +#define ngx_dlopen(path) dlopen((char *) path, RTLD_NOW | RTLD_GLOBAL) +#define ngx_dlopen_n "dlopen()" + +#define ngx_dlsym(handle, symbol) dlsym(handle, symbol) +#define ngx_dlsym_n "dlsym()" + +#define ngx_dlclose(handle) dlclose(handle) +#define ngx_dlclose_n "dlclose()" + + +#if (NGX_HAVE_DLOPEN) +char *ngx_dlerror(void); +#endif + + +#endif /* _NGX_DLOPEN_H_INCLUDED_ */ diff -r cf5e822cf470 -r 7142b04337d6 src/os/unix/ngx_freebsd_config.h --- a/src/os/unix/ngx_freebsd_config.h Thu Feb 04 18:30:21 2016 +0300 +++ b/src/os/unix/ngx_freebsd_config.h Thu Feb 04 18:30:21 2016 +0300 @@ -49,6 +49,8 @@ #include #include +#include + #if __FreeBSD_version < 400017 diff -r cf5e822cf470 -r 7142b04337d6 src/os/unix/ngx_linux_config.h --- a/src/os/unix/ngx_linux_config.h Thu Feb 04 18:30:21 2016 +0300 +++ b/src/os/unix/ngx_linux_config.h Thu Feb 04 18:30:21 2016 +0300 @@ -55,6 +55,8 @@ #include #include /* uname() */ +#include + #include diff -r cf5e822cf470 -r 7142b04337d6 src/os/unix/ngx_posix_config.h --- a/src/os/unix/ngx_posix_config.h Thu Feb 04 18:30:21 2016 +0300 +++ b/src/os/unix/ngx_posix_config.h Thu Feb 04 18:30:21 2016 +0300 @@ -108,6 +108,11 @@ #include +#if (NGX_HAVE_DLOPEN) +#include +#endif + + #if (NGX_HAVE_POSIX_SEM) #include #endif diff -r cf5e822cf470 -r 7142b04337d6 src/os/unix/ngx_solaris_config.h --- a/src/os/unix/ngx_solaris_config.h Thu Feb 04 18:30:21 2016 +0300 +++ b/src/os/unix/ngx_solaris_config.h Thu Feb 04 18:30:21 2016 +0300 @@ -55,6 +55,8 @@ #include #include +#include + #define NGX_ALIGNMENT _MAX_ALIGNMENT #include diff -r cf5e822cf470 -r 7142b04337d6 src/os/win32/ngx_dlopen.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/os/win32/ngx_dlopen.c Thu Feb 04 18:30:21 2016 +0300 @@ -0,0 +1,22 @@ + +/* + * Copyright (C) Maxim Dounin + * Copyright (C) Nginx, Inc. + */ + + +#include +#include + + +char * +ngx_dlerror(void) +{ + u_char *p; + static u_char errstr[NGX_MAX_ERROR_STR]; + + p = ngx_strerror(ngx_errno, errstr, NGX_MAX_ERROR_STR); + *p = '\0'; + + return (char *) errstr; +} diff -r cf5e822cf470 -r 7142b04337d6 src/os/win32/ngx_dlopen.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/os/win32/ngx_dlopen.h Thu Feb 04 18:30:21 2016 +0300 @@ -0,0 +1,32 @@ + +/* + * Copyright (C) Maxim Dounin + * Copyright (C) Nginx, Inc. + */ + + +#ifndef _NGX_DLOPEN_H_INCLUDED_ +#define _NGX_DLOPEN_H_INCLUDED_ + + +#include +#include + + +#define NGX_HAVE_DLOPEN 1 + + +#define ngx_dlopen(path) LoadLibrary((char *) path) +#define ngx_dlopen_n "LoadLibrary()" + +#define ngx_dlsym(handle, symbol) (void *) GetProcAddress(handle, symbol) +#define ngx_dlsym_n "GetProcAddress()" + +#define ngx_dlclose(handle) (FreeLibrary(handle) ? 0 : -1) +#define ngx_dlclose_n "FreeLibrary()" + + +char *ngx_dlerror(void); + + +#endif /* _NGX_DLOPEN_H_INCLUDED_ */