Commit 3c951b6d authored by unknown's avatar unknown

Fixed compilation problems when HAVE_OPENSSL is not defined

parent 39fdbbbb
...@@ -377,6 +377,9 @@ sig_handler mysql_end(int sig) ...@@ -377,6 +377,9 @@ sig_handler mysql_end(int sig)
{ {
if (connected) if (connected)
mysql_close(&mysql); mysql_close(&mysql);
else
mysql_ssl_clear(&mysql); /* SSL data structres should be freed
even if connection was not made */
#ifdef HAVE_READLINE #ifdef HAVE_READLINE
if (!status.batch && !quick && !opt_html && !opt_xml) if (!status.batch && !quick && !opt_html && !opt_xml)
{ {
...@@ -2204,6 +2207,9 @@ sql_real_connect(char *host,char *database,char *user,char *password, ...@@ -2204,6 +2207,9 @@ sql_real_connect(char *host,char *database,char *user,char *password,
mysql_close(&mysql); mysql_close(&mysql);
connected= 0; connected= 0;
} }
else
mysql_ssl_clear(&mysql); /* SSL data structres should be freed
even if connection was not made */
mysql_init(&mysql); mysql_init(&mysql);
if (opt_connect_timeout) if (opt_connect_timeout)
{ {
......
...@@ -256,13 +256,10 @@ unsigned long STDCALL mysql_thread_id(MYSQL *mysql); ...@@ -256,13 +256,10 @@ unsigned long STDCALL mysql_thread_id(MYSQL *mysql);
const char * STDCALL mysql_character_set_name(MYSQL *mysql); const char * STDCALL mysql_character_set_name(MYSQL *mysql);
MYSQL * STDCALL mysql_init(MYSQL *mysql); MYSQL * STDCALL mysql_init(MYSQL *mysql);
#ifdef HAVE_OPENSSL
int STDCALL mysql_ssl_set(MYSQL *mysql, const char *key, int STDCALL mysql_ssl_set(MYSQL *mysql, const char *key,
const char *cert, const char *ca, const char *cert, const char *ca,
const char *capath); const char *capath);
char * STDCALL mysql_ssl_cipher(MYSQL *mysql);
int STDCALL mysql_ssl_clear(MYSQL *mysql); int STDCALL mysql_ssl_clear(MYSQL *mysql);
#endif /* HAVE_OPENSSL */
my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user, my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,
const char *passwd, const char *db); const char *passwd, const char *db);
MYSQL * STDCALL mysql_real_connect(MYSQL *mysql, const char *host, MYSQL * STDCALL mysql_real_connect(MYSQL *mysql, const char *host,
......
...@@ -1359,16 +1359,19 @@ static void mysql_once_init() ...@@ -1359,16 +1359,19 @@ static void mysql_once_init()
#endif #endif
} }
#ifdef HAVE_OPENSSL
/************************************************************************** /**************************************************************************
** Fill in SSL part of MYSQL structure and set 'use_ssl' flag. ** Fill in SSL part of MYSQL structure and set 'use_ssl' flag.
** NB! Errors are not reported until you do mysql_real_connect. ** NB! Errors are not reported until you do mysql_real_connect.
**************************************************************************/ **************************************************************************/
int STDCALL int STDCALL
mysql_ssl_set(MYSQL *mysql, const char *key, const char *cert, mysql_ssl_set(MYSQL *mysql __attribute__((unused)) ,
const char *ca, const char *capath) const char *key __attribute__((unused)),
const char *cert __attribute__((unused)),
const char *ca __attribute__((unused)),
const char *capath __attribute__((unused)))
{ {
#ifdef HAVE_OPENSSL
mysql->options.ssl_key = key==0 ? 0 : my_strdup(key,MYF(0)); mysql->options.ssl_key = key==0 ? 0 : my_strdup(key,MYF(0));
mysql->options.ssl_cert = cert==0 ? 0 : my_strdup(cert,MYF(0)); mysql->options.ssl_cert = cert==0 ? 0 : my_strdup(cert,MYF(0));
mysql->options.ssl_ca = ca==0 ? 0 : my_strdup(ca,MYF(0)); mysql->options.ssl_ca = ca==0 ? 0 : my_strdup(ca,MYF(0));
...@@ -1376,28 +1379,20 @@ mysql_ssl_set(MYSQL *mysql, const char *key, const char *cert, ...@@ -1376,28 +1379,20 @@ mysql_ssl_set(MYSQL *mysql, const char *key, const char *cert,
mysql->options.use_ssl = TRUE; mysql->options.use_ssl = TRUE;
mysql->connector_fd = (gptr)new_VioSSLConnectorFd(key, cert, ca, capath); mysql->connector_fd = (gptr)new_VioSSLConnectorFd(key, cert, ca, capath);
DBUG_PRINT("info",("mysql_ssl_set, context: %p",((struct st_VioSSLConnectorFd *)(mysql->connector_fd))->ssl_context_)); DBUG_PRINT("info",("mysql_ssl_set, context: %p",((struct st_VioSSLConnectorFd *)(mysql->connector_fd))->ssl_context_));
#endif
return 0; return 0;
} }
/************************************************************************** /*
************************************************************************** ***************************************************************************
char * STDCALL
mysql_ssl_cipher(MYSQL *mysql)
{
return (char *)mysql->net.vio->cipher_description();
}
**************************************************************************
** Free strings in the SSL structure and clear 'use_ssl' flag. ** Free strings in the SSL structure and clear 'use_ssl' flag.
** NB! Errors are not reported until you do mysql_real_connect. ** NB! Errors are not reported until you do mysql_real_connect.
************************************************************************** **************************************************************************
*/ */
int STDCALL int STDCALL
mysql_ssl_clear(MYSQL *mysql) mysql_ssl_clear(MYSQL *mysql __attribute__((unused)))
{ {
#ifdef HAVE_OPENSSL
my_free(mysql->options.ssl_key, MYF(MY_ALLOW_ZERO_PTR)); my_free(mysql->options.ssl_key, MYF(MY_ALLOW_ZERO_PTR));
my_free(mysql->options.ssl_cert, MYF(MY_ALLOW_ZERO_PTR)); my_free(mysql->options.ssl_cert, MYF(MY_ALLOW_ZERO_PTR));
my_free(mysql->options.ssl_ca, MYF(MY_ALLOW_ZERO_PTR)); my_free(mysql->options.ssl_ca, MYF(MY_ALLOW_ZERO_PTR));
...@@ -1409,9 +1404,9 @@ mysql_ssl_clear(MYSQL *mysql) ...@@ -1409,9 +1404,9 @@ mysql_ssl_clear(MYSQL *mysql)
mysql->options.use_ssl = FALSE; mysql->options.use_ssl = FALSE;
my_free(mysql->connector_fd,MYF(MY_ALLOW_ZERO_PTR)); my_free(mysql->connector_fd,MYF(MY_ALLOW_ZERO_PTR));
mysql->connector_fd = 0; mysql->connector_fd = 0;
#endif /* HAVE_OPENSSL */
return 0; return 0;
} }
#endif /* HAVE_OPENSSL */
/************************************************************************** /**************************************************************************
** Connect to sql server ** Connect to sql server
......
...@@ -1991,7 +1991,9 @@ The server will not act as a slave."); ...@@ -1991,7 +1991,9 @@ The server will not act as a slave.");
if(hEventShutdown) CloseHandle(hEventShutdown); if(hEventShutdown) CloseHandle(hEventShutdown);
} }
#endif #endif
#ifdef HAVE_OPENSSL
my_free((gptr)ssl_acceptor_fd,MYF(0)); my_free((gptr)ssl_acceptor_fd,MYF(0));
#endif /* HAVE_OPENSSL */
/* Wait until cleanup is done */ /* Wait until cleanup is done */
(void) pthread_mutex_lock(&LOCK_thread_count); (void) pthread_mutex_lock(&LOCK_thread_count);
while (!ready_to_exit) while (!ready_to_exit)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment