Merge pull request #288 from akopytov/gh-287

Fix #287: Issue of MYSQL_OPT_SSL_MODE
This commit is contained in:
Alexey Kopytov
2019-01-16 18:43:57 +03:00
committed by GitHub
2 changed files with 19 additions and 2 deletions

View File

@ -114,7 +114,24 @@ AC_DEFINE([USE_MYSQL], 1,
USE_MYSQL=1
AC_SUBST([MYSQL_LIBS])
AC_SUBST([MYSQL_CFLAGS])
AC_MSG_CHECKING([if mysql.h defines MYSQL_OPT_SSL_MODE])
SAVE_CFLAGS="${CFLAGS}"
CFLAGS="${CFLAGS} ${MYSQL_CFLAGS}"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[
#include <mysql.h>
enum mysql_option opt = MYSQL_OPT_SSL_MODE;
]])], [
AC_DEFINE([HAVE_MYSQL_OPT_SSL_MODE], 1,
[Define to 1 if mysql.h defines MYSQL_OPT_SSL_MODE])
AC_MSG_RESULT([yes])
], [AC_MSG_RESULT([no])])
])
CFLAGS="${SAVE_CFLAGS}"
AM_CONDITIONAL([USE_MYSQL], test "x$with_mysql" != xno)
AC_SUBST([USE_MYSQL])

View File

@ -323,10 +323,10 @@ static int mysql_drv_real_connect(db_mysql_conn_t *db_mysql_con)
mysql_ssl_set(con, ssl_key, ssl_cert, ssl_ca, NULL, args.ssl_cipher);
#ifdef MYSQL_OPT_SSL_MODE
#ifdef HAVE_MYSQL_OPT_SSL_MODE
unsigned int opt_ssl_mode = SSL_MODE_REQUIRED;
DEBUG("mysql_options(%p,%s,%u)", con, "MYSQL_OPT_SSL_MODE", opt_ssl_mode);
DEBUG("mysql_options(%p, %s, %u)", con, "MYSQL_OPT_SSL_MODE", opt_ssl_mode);
mysql_options(con, MYSQL_OPT_SSL_MODE, &opt_ssl_mode);
#endif
}