enhanced configure.ac for selective ssl inclusion.

renamed MPI_NODE to MPI_HOST
This commit is contained in:
hyung-hwan 2012-09-05 13:46:11 +00:00
parent 870ee3e362
commit 464f763307
5 changed files with 103 additions and 25 deletions

45
qse/configure vendored
View File

@ -16623,9 +16623,6 @@ fi
fi fi
$as_echo "#define HAVE_EPOLL /**/" >>confdefs.h
for ac_func in epoll_create epoll_create1 for ac_func in epoll_create epoll_create1
do : do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
@ -16640,6 +16637,7 @@ done
if test "$ac_cv_func_epoll_create" = "yes" if test "$ac_cv_func_epoll_create" = "yes"
then then
$as_echo "#define HAVE_EPOLL 1" >>confdefs.h $as_echo "#define HAVE_EPOLL 1" >>confdefs.h
fi fi
@ -16680,13 +16678,26 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for SSL_library_init in -lssl" >&5 for ac_func in SSL_library_init
$as_echo_n "checking for SSL_library_init in -lssl... " >&6; } do :
if ${ac_cv_lib_ssl_SSL_library_init+:} false; then : ac_fn_c_check_func "$LINENO" "SSL_library_init" "ac_cv_func_SSL_library_init"
if test "x$ac_cv_func_SSL_library_init" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_SSL_LIBRARY_INIT 1
_ACEOF
fi
done
if test "$ac_cv_func_SSL_library_init" = "no"
then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sendfile in -lsendfile" >&5
$as_echo_n "checking for sendfile in -lsendfile... " >&6; }
if ${ac_cv_lib_sendfile_sendfile+:} false; then :
$as_echo_n "(cached) " >&6 $as_echo_n "(cached) " >&6
else else
ac_check_lib_save_LIBS=$LIBS ac_check_lib_save_LIBS=$LIBS
LIBS="-lssl $LIBS" LIBS="-lsendfile $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */ /* end confdefs.h. */
@ -16696,30 +16707,36 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
#endif #endif
char SSL_library_init (); char sendfile ();
int int
main () main ()
{ {
return SSL_library_init (); return sendfile ();
; ;
return 0; return 0;
} }
_ACEOF _ACEOF
if ac_fn_c_try_link "$LINENO"; then : if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_ssl_SSL_library_init=yes ac_cv_lib_sendfile_sendfile=yes
else else
ac_cv_lib_ssl_SSL_library_init=no ac_cv_lib_sendfile_sendfile=no
fi fi
rm -f core conftest.err conftest.$ac_objext \ rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS LIBS=$ac_check_lib_save_LIBS
fi fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ssl_SSL_library_init" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sendfile_sendfile" >&5
$as_echo "$ac_cv_lib_ssl_SSL_library_init" >&6; } $as_echo "$ac_cv_lib_sendfile_sendfile" >&6; }
if test "x$ac_cv_lib_ssl_SSL_library_init" = xyes; then : if test "x$ac_cv_lib_sendfile_sendfile" = xyes; then :
SSL_LIBS="-lssl" SSL_LIBS="-lssl"
$as_echo "#define HAVE_SSL 1" >>confdefs.h
fi fi
fi

View File

@ -178,11 +178,10 @@ then
fi fi
AC_SUBST(SENDFILE_LIBS) AC_SUBST(SENDFILE_LIBS)
AC_DEFINE(HAVE_EPOLL, [], [epoll support])
AC_CHECK_FUNCS([epoll_create epoll_create1]) AC_CHECK_FUNCS([epoll_create epoll_create1])
if test "$ac_cv_func_epoll_create" = "yes" if test "$ac_cv_func_epoll_create" = "yes"
then then
AC_DEFINE(HAVE_EPOLL, 1) AC_DEFINE(HAVE_EPOLL, 1, [epoll support])
fi fi
dnl check is the import library for unicows.dll exists dnl check is the import library for unicows.dll exists
@ -193,7 +192,14 @@ AC_CHECK_LIB([unicows], [main], [UNICOWS_LIBS="-lunicows"])
AC_SUBST(UNICOWS_LIBS) AC_SUBST(UNICOWS_LIBS)
dnl check for an SSL library dnl check for an SSL library
AC_CHECK_LIB([ssl], [SSL_library_init], [SSL_LIBS="-lssl"]) AC_CHECK_FUNCS([SSL_library_init])
if test "$ac_cv_func_SSL_library_init" = "no"
then
AC_CHECK_LIB([sendfile], [sendfile], [
SSL_LIBS="-lssl"
AC_DEFINE(HAVE_SSL, 1, [ssl support])
])
fi
AC_SUBST(SSL_LIBS) AC_SUBST(SSL_LIBS)
dnl MPI dnl MPI

View File

@ -250,6 +250,12 @@
/* Define to 1 if you have the `sqrtl' function. */ /* Define to 1 if you have the `sqrtl' function. */
#undef HAVE_SQRTL #undef HAVE_SQRTL
/* ssl support */
#undef HAVE_SSL
/* Define to 1 if you have the `SSL_library_init' function. */
#undef HAVE_SSL_LIBRARY_INIT
/* Define to 1 if you have the `stat64' function. */ /* Define to 1 if you have the `stat64' function. */
#undef HAVE_STAT64 #undef HAVE_STAT64

View File

@ -19,6 +19,7 @@
*/ */
#include <qse/awk/mpi.h> #include <qse/awk/mpi.h>
#include <qse/cmn/mbwc.h>
#include "../cmn/mem.h" #include "../cmn/mem.h"
#include <mpi.h> #include <mpi.h>
@ -58,7 +59,7 @@ qse_awk_t* qse_awk_openmpiwithmmgr (qse_mmgr_t* mmgr, qse_size_t xtnsize)
xtn = (xtn_t*) qse_awk_getxtnstd (awk); xtn = (xtn_t*) qse_awk_getxtnstd (awk);
QSE_MEMSET (xtn, 0, QSE_SIZEOF(*xtn)); QSE_MEMSET (xtn, 0, QSE_SIZEOF(*xtn));
xtn->gbl_mpi[0] = qse_awk_addgbl (awk, QSE_T("MPI_NODE"), 8); xtn->gbl_mpi[0] = qse_awk_addgbl (awk, QSE_T("MPI_HOST"), 8);
xtn->gbl_mpi[1] = qse_awk_addgbl (awk, QSE_T("MPI_RANK"), 8); xtn->gbl_mpi[1] = qse_awk_addgbl (awk, QSE_T("MPI_RANK"), 8);
xtn->gbl_mpi[2] = qse_awk_addgbl (awk, QSE_T("MPI_SIZE"), 8); xtn->gbl_mpi[2] = qse_awk_addgbl (awk, QSE_T("MPI_SIZE"), 8);
@ -131,7 +132,7 @@ qse_awk_rtx_t* qse_awk_rtx_openmpi (
switch (i) switch (i)
{ {
case 0: /* MPI_NODE */ case 0: /* MPI_HOST */
{ {
char buf[MPI_MAX_PROCESSOR_NAME]; char buf[MPI_MAX_PROCESSOR_NAME];
int len; int len;
@ -273,8 +274,22 @@ softfail:
return 0; return 0;
} }
static int fnc_barrier (qse_awk_rtx_t* rtx, const qse_cstr_t* fnm)
{
int x;
qse_awk_val_t* tmp;
x = (MPI_Barrier (MPI_COMM_WORLD) == MPI_SUCCESS)? 0: -1;
tmp = qse_awk_rtx_makeintval (rtx, x);
if (tmp == QSE_NULL) return -1;
qse_awk_rtx_setretval (rtx, tmp);
return 0;
}
static int add_functions (qse_awk_t* awk) static int add_functions (qse_awk_t* awk)
{ {
if (qse_awk_addfnc (awk, QSE_T("mpi_reduce"), 10, 0, 2, 2, QSE_NULL, fnc_reduce) == QSE_NULL) return -1; if (qse_awk_addfnc (awk, QSE_T("mpi_reduce"), 10, 0, 2, 2, QSE_NULL, fnc_reduce) == QSE_NULL) return -1;
if (qse_awk_addfnc (awk, QSE_T("mpi_barrier"), 11, 0, 0, 0, QSE_NULL, fnc_barrier) == QSE_NULL) return -1;
return 0; return 0;
} }

View File

@ -33,9 +33,11 @@
# include <linux/netfilter_ipv4.h> # include <linux/netfilter_ipv4.h>
#endif #endif
#if defined(HAVE_SSL)
# include <openssl/ssl.h> # include <openssl/ssl.h>
# include <openssl/err.h> # include <openssl/err.h>
# include <openssl/engine.h> # include <openssl/engine.h>
#endif
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */
@ -117,6 +119,7 @@ static qse_ssize_t xsendfile (
} }
#endif #endif
#if defined(HAVE_SSL)
static qse_ssize_t xsendfile_ssl ( static qse_ssize_t xsendfile_ssl (
SSL* out, int in_fd, qse_foff_t* offset, qse_size_t count) SSL* out, int in_fd, qse_foff_t* offset, qse_size_t count)
{ {
@ -135,6 +138,8 @@ static qse_ssize_t xsendfile_ssl (
return n; return n;
} }
#endif
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */
static qse_httpd_errnum_t syserr_to_errnum (int e) static qse_httpd_errnum_t syserr_to_errnum (int e)
{ {
@ -172,11 +177,14 @@ static qse_httpd_errnum_t syserr_to_errnum (int e)
typedef struct httpd_xtn_t httpd_xtn_t; typedef struct httpd_xtn_t httpd_xtn_t;
struct httpd_xtn_t struct httpd_xtn_t
{ {
#if defined(HAVE_SSL)
SSL_CTX* ssl_ctx; SSL_CTX* ssl_ctx;
#endif
}; };
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */
#if defined(HAVE_SSL)
static int init_xtn_ssl ( static int init_xtn_ssl (
httpd_xtn_t* xtn, httpd_xtn_t* xtn,
const qse_mchar_t* pemfile, const qse_mchar_t* pemfile,
@ -229,6 +237,7 @@ static void fini_xtn_ssl (httpd_xtn_t* xtn)
EVP_cleanup (); EVP_cleanup ();
CRYPTO_cleanup_all_ex_data (); CRYPTO_cleanup_all_ex_data ();
} }
#endif
/* ------------------------------------------------------------------- */ /* ------------------------------------------------------------------- */
@ -924,6 +933,7 @@ static qse_ssize_t client_recv (
{ {
if (client->secure) if (client->secure)
{ {
#if defined(HAVE_SSL)
int ret = SSL_read (client->handle2.ptr, buf, bufsize); int ret = SSL_read (client->handle2.ptr, buf, bufsize);
if (ret <= -1) if (ret <= -1)
{ {
@ -933,6 +943,9 @@ static qse_ssize_t client_recv (
qse_httpd_seterrnum (httpd, QSE_HTTPD_ESYSERR); qse_httpd_seterrnum (httpd, QSE_HTTPD_ESYSERR);
} }
return ret; return ret;
#else
return -1;
#endif
} }
else else
{ {
@ -948,6 +961,7 @@ static qse_ssize_t client_send (
{ {
if (client->secure) if (client->secure)
{ {
#if defined(HAVE_SSL)
int ret = SSL_write (client->handle2.ptr, buf, bufsize); int ret = SSL_write (client->handle2.ptr, buf, bufsize);
if (ret <= -1) if (ret <= -1)
{ {
@ -957,6 +971,9 @@ static qse_ssize_t client_send (
qse_httpd_seterrnum (httpd, QSE_HTTPD_ESYSERR); qse_httpd_seterrnum (httpd, QSE_HTTPD_ESYSERR);
} }
return ret; return ret;
#else
return -1;
#endif
} }
else else
{ {
@ -972,7 +989,11 @@ static qse_ssize_t client_sendfile (
{ {
if (client->secure) if (client->secure)
{ {
#if defined(HAVE_SSL)
return xsendfile_ssl (client->handle2.ptr, handle.i, offset, count); return xsendfile_ssl (client->handle2.ptr, handle.i, offset, count);
#else
return -1;
#endif
} }
else else
{ {
@ -986,6 +1007,7 @@ static int client_accepted (qse_httpd_t* httpd, qse_httpd_client_t* client)
if (client->secure) if (client->secure)
{ {
#if defined(HAVE_SSL)
int ret; int ret;
SSL* ssl; SSL* ssl;
@ -1030,6 +1052,9 @@ qse_fflush (QSE_STDOUT);
/* SSL_free (ssl); */ /* SSL_free (ssl); */
return -1; return -1;
} }
#else
return -1;
#endif
} }
return 1; /* accept completed */ return 1; /* accept completed */
@ -1039,11 +1064,13 @@ static void client_closed (qse_httpd_t* httpd, qse_httpd_client_t* client)
{ {
if (client->secure) if (client->secure)
{ {
#if defined(HAVE_SSL)
if (client->handle2.ptr) if (client->handle2.ptr)
{ {
SSL_shutdown ((SSL*)client->handle2.ptr); /* is this needed? */ SSL_shutdown ((SSL*)client->handle2.ptr); /* is this needed? */
SSL_free ((SSL*)client->handle2.ptr); SSL_free ((SSL*)client->handle2.ptr);
} }
#endif
} }
} }
@ -1463,8 +1490,10 @@ int httpd_main (int argc, qse_char_t* argv[])
} }
xtn = (httpd_xtn_t*)qse_httpd_getxtn (httpd); xtn = (httpd_xtn_t*)qse_httpd_getxtn (httpd);
#if defined(HAVE_SSL)
xtn->ssl_ctx = QSE_NULL; xtn->ssl_ctx = QSE_NULL;
init_xtn_ssl (xtn, "http01.pem", "http01.key"); init_xtn_ssl (xtn, "http01.pem", "http01.key");
#endif
for (i = 1; i < argc; i++) for (i = 1; i < argc; i++)
{ {
@ -1490,7 +1519,12 @@ int httpd_main (int argc, qse_char_t* argv[])
if (ret <= -1) qse_fprintf (QSE_STDERR, QSE_T("Httpd error\n")); if (ret <= -1) qse_fprintf (QSE_STDERR, QSE_T("Httpd error\n"));
oops: oops:
if (xtn && xtn->ssl_ctx) fini_xtn_ssl (xtn); if (xtn)
{
#if defined(HAVE_SSL)
if (xtn->ssl_ctx) fini_xtn_ssl (xtn);
#endif
}
if (httpd) qse_httpd_close (httpd); if (httpd) qse_httpd_close (httpd);
return ret; return ret;
} }