diff --git a/qse/configure b/qse/configure index 46930664..aa66750a 100755 --- a/qse/configure +++ b/qse/configure @@ -16623,9 +16623,6 @@ fi fi - -$as_echo "#define HAVE_EPOLL /**/" >>confdefs.h - for ac_func in epoll_create epoll_create1 do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` @@ -16640,7 +16637,8 @@ done if test "$ac_cv_func_epoll_create" = "yes" then - $as_echo "#define HAVE_EPOLL 1" >>confdefs.h + +$as_echo "#define HAVE_EPOLL 1" >>confdefs.h fi @@ -16680,13 +16678,26 @@ fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for SSL_library_init in -lssl" >&5 -$as_echo_n "checking for SSL_library_init in -lssl... " >&6; } -if ${ac_cv_lib_ssl_SSL_library_init+:} false; then : +for ac_func in SSL_library_init +do : + 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 else ac_check_lib_save_LIBS=$LIBS -LIBS="-lssl $LIBS" +LIBS="-lsendfile $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -16696,30 +16707,36 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext #ifdef __cplusplus extern "C" #endif -char SSL_library_init (); +char sendfile (); int main () { -return SSL_library_init (); +return sendfile (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_ssl_SSL_library_init=yes + ac_cv_lib_sendfile_sendfile=yes else - ac_cv_lib_ssl_SSL_library_init=no + ac_cv_lib_sendfile_sendfile=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ssl_SSL_library_init" >&5 -$as_echo "$ac_cv_lib_ssl_SSL_library_init" >&6; } -if test "x$ac_cv_lib_ssl_SSL_library_init" = xyes; then : - SSL_LIBS="-lssl" +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sendfile_sendfile" >&5 +$as_echo "$ac_cv_lib_sendfile_sendfile" >&6; } +if test "x$ac_cv_lib_sendfile_sendfile" = xyes; then : + + SSL_LIBS="-lssl" + +$as_echo "#define HAVE_SSL 1" >>confdefs.h + + fi +fi diff --git a/qse/configure.ac b/qse/configure.ac index 01f1fee6..f25f1540 100644 --- a/qse/configure.ac +++ b/qse/configure.ac @@ -178,11 +178,10 @@ then fi AC_SUBST(SENDFILE_LIBS) -AC_DEFINE(HAVE_EPOLL, [], [epoll support]) AC_CHECK_FUNCS([epoll_create epoll_create1]) if test "$ac_cv_func_epoll_create" = "yes" then - AC_DEFINE(HAVE_EPOLL, 1) + AC_DEFINE(HAVE_EPOLL, 1, [epoll support]) fi 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) 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) dnl MPI diff --git a/qse/include/qse/config.h.in b/qse/include/qse/config.h.in index 59585f10..7e02054e 100644 --- a/qse/include/qse/config.h.in +++ b/qse/include/qse/config.h.in @@ -250,6 +250,12 @@ /* Define to 1 if you have the `sqrtl' function. */ #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. */ #undef HAVE_STAT64 diff --git a/qse/lib/awk/mpi.c b/qse/lib/awk/mpi.c index 276dfbf0..1bab0c77 100644 --- a/qse/lib/awk/mpi.c +++ b/qse/lib/awk/mpi.c @@ -19,6 +19,7 @@ */ #include +#include #include "../cmn/mem.h" #include @@ -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); 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[2] = qse_awk_addgbl (awk, QSE_T("MPI_SIZE"), 8); @@ -131,7 +132,7 @@ qse_awk_rtx_t* qse_awk_rtx_openmpi ( switch (i) { - case 0: /* MPI_NODE */ + case 0: /* MPI_HOST */ { char buf[MPI_MAX_PROCESSOR_NAME]; int len; @@ -273,8 +274,22 @@ softfail: 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) { 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; } diff --git a/qse/samples/net/http01.c b/qse/samples/net/http01.c index 3e31e473..a3348565 100644 --- a/qse/samples/net/http01.c +++ b/qse/samples/net/http01.c @@ -33,9 +33,11 @@ # include #endif -#include -#include -#include +#if defined(HAVE_SSL) +# include +# include +# include +#endif /* ------------------------------------------------------------------- */ @@ -117,6 +119,7 @@ static qse_ssize_t xsendfile ( } #endif +#if defined(HAVE_SSL) static qse_ssize_t xsendfile_ssl ( 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; } +#endif + /* ------------------------------------------------------------------- */ 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; struct httpd_xtn_t { +#if defined(HAVE_SSL) SSL_CTX* ssl_ctx; +#endif }; /* ------------------------------------------------------------------- */ +#if defined(HAVE_SSL) static int init_xtn_ssl ( httpd_xtn_t* xtn, const qse_mchar_t* pemfile, @@ -229,6 +237,7 @@ static void fini_xtn_ssl (httpd_xtn_t* xtn) EVP_cleanup (); CRYPTO_cleanup_all_ex_data (); } +#endif /* ------------------------------------------------------------------- */ @@ -924,6 +933,7 @@ static qse_ssize_t client_recv ( { if (client->secure) { +#if defined(HAVE_SSL) int ret = SSL_read (client->handle2.ptr, buf, bufsize); if (ret <= -1) { @@ -933,6 +943,9 @@ static qse_ssize_t client_recv ( qse_httpd_seterrnum (httpd, QSE_HTTPD_ESYSERR); } return ret; +#else + return -1; +#endif } else { @@ -948,6 +961,7 @@ static qse_ssize_t client_send ( { if (client->secure) { +#if defined(HAVE_SSL) int ret = SSL_write (client->handle2.ptr, buf, bufsize); if (ret <= -1) { @@ -957,6 +971,9 @@ static qse_ssize_t client_send ( qse_httpd_seterrnum (httpd, QSE_HTTPD_ESYSERR); } return ret; +#else + return -1; +#endif } else { @@ -972,7 +989,11 @@ static qse_ssize_t client_sendfile ( { if (client->secure) { +#if defined(HAVE_SSL) return xsendfile_ssl (client->handle2.ptr, handle.i, offset, count); +#else + return -1; +#endif } else { @@ -986,6 +1007,7 @@ static int client_accepted (qse_httpd_t* httpd, qse_httpd_client_t* client) if (client->secure) { +#if defined(HAVE_SSL) int ret; SSL* ssl; @@ -1030,6 +1052,9 @@ qse_fflush (QSE_STDOUT); /* SSL_free (ssl); */ return -1; } +#else + return -1; +#endif } 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 defined(HAVE_SSL) if (client->handle2.ptr) { SSL_shutdown ((SSL*)client->handle2.ptr); /* is this needed? */ 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); +#if defined(HAVE_SSL) xtn->ssl_ctx = QSE_NULL; init_xtn_ssl (xtn, "http01.pem", "http01.key"); +#endif 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")); 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); return ret; }