Skip to content

Commit 102cabf

Browse files
author
tonu@x153.internalnet
committed
Fixed compilation problems when HAVE_OPENSSL is not defined
1 parent 6e68504 commit 102cabf

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

client/mysql.cc

+6
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,9 @@ sig_handler mysql_end(int sig)
377377
{
378378
if (connected)
379379
mysql_close(&mysql);
380+
else
381+
mysql_ssl_clear(&mysql); /* SSL data structres should be freed
382+
even if connection was not made */
380383
#ifdef HAVE_READLINE
381384
if (!status.batch && !quick && !opt_html && !opt_xml)
382385
{
@@ -2204,6 +2207,9 @@ sql_real_connect(char *host,char *database,char *user,char *password,
22042207
mysql_close(&mysql);
22052208
connected= 0;
22062209
}
2210+
else
2211+
mysql_ssl_clear(&mysql); /* SSL data structres should be freed
2212+
even if connection was not made */
22072213
mysql_init(&mysql);
22082214
if (opt_connect_timeout)
22092215
{

include/mysql.h

-3
Original file line numberDiff line numberDiff line change
@@ -256,13 +256,10 @@ unsigned long STDCALL mysql_thread_id(MYSQL *mysql);
256256
const char * STDCALL mysql_character_set_name(MYSQL *mysql);
257257

258258
MYSQL * STDCALL mysql_init(MYSQL *mysql);
259-
#ifdef HAVE_OPENSSL
260259
int STDCALL mysql_ssl_set(MYSQL *mysql, const char *key,
261260
const char *cert, const char *ca,
262261
const char *capath);
263-
char * STDCALL mysql_ssl_cipher(MYSQL *mysql);
264262
int STDCALL mysql_ssl_clear(MYSQL *mysql);
265-
#endif /* HAVE_OPENSSL */
266263
my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user,
267264
const char *passwd, const char *db);
268265
MYSQL * STDCALL mysql_real_connect(MYSQL *mysql, const char *host,

libmysql/libmysql.c

+12-17
Original file line numberDiff line numberDiff line change
@@ -1359,45 +1359,40 @@ static void mysql_once_init()
13591359
#endif
13601360
}
13611361

1362-
#ifdef HAVE_OPENSSL
13631362
/**************************************************************************
13641363
** Fill in SSL part of MYSQL structure and set 'use_ssl' flag.
13651364
** NB! Errors are not reported until you do mysql_real_connect.
13661365
**************************************************************************/
13671366

13681367
int STDCALL
1369-
mysql_ssl_set(MYSQL *mysql, const char *key, const char *cert,
1370-
const char *ca, const char *capath)
1368+
mysql_ssl_set(MYSQL *mysql __attribute__((unused)) ,
1369+
const char *key __attribute__((unused)),
1370+
const char *cert __attribute__((unused)),
1371+
const char *ca __attribute__((unused)),
1372+
const char *capath __attribute__((unused)))
13711373
{
1374+
#ifdef HAVE_OPENSSL
13721375
mysql->options.ssl_key = key==0 ? 0 : my_strdup(key,MYF(0));
13731376
mysql->options.ssl_cert = cert==0 ? 0 : my_strdup(cert,MYF(0));
13741377
mysql->options.ssl_ca = ca==0 ? 0 : my_strdup(ca,MYF(0));
13751378
mysql->options.ssl_capath = capath==0 ? 0 : my_strdup(capath,MYF(0));
13761379
mysql->options.use_ssl = TRUE;
13771380
mysql->connector_fd = (gptr)new_VioSSLConnectorFd(key, cert, ca, capath);
13781381
DBUG_PRINT("info",("mysql_ssl_set, context: %p",((struct st_VioSSLConnectorFd *)(mysql->connector_fd))->ssl_context_));
1379-
1382+
#endif
13801383
return 0;
13811384
}
13821385

1383-
/**************************************************************************
1384-
**************************************************************************
1385-
1386-
char * STDCALL
1387-
mysql_ssl_cipher(MYSQL *mysql)
1388-
{
1389-
return (char *)mysql->net.vio->cipher_description();
1390-
}
1391-
1392-
1393-
**************************************************************************
1386+
/*
1387+
***************************************************************************
13941388
** Free strings in the SSL structure and clear 'use_ssl' flag.
13951389
** NB! Errors are not reported until you do mysql_real_connect.
13961390
**************************************************************************
13971391
*/
13981392
int STDCALL
1399-
mysql_ssl_clear(MYSQL *mysql)
1393+
mysql_ssl_clear(MYSQL *mysql __attribute__((unused)))
14001394
{
1395+
#ifdef HAVE_OPENSSL
14011396
my_free(mysql->options.ssl_key, MYF(MY_ALLOW_ZERO_PTR));
14021397
my_free(mysql->options.ssl_cert, MYF(MY_ALLOW_ZERO_PTR));
14031398
my_free(mysql->options.ssl_ca, MYF(MY_ALLOW_ZERO_PTR));
@@ -1409,9 +1404,9 @@ mysql_ssl_clear(MYSQL *mysql)
14091404
mysql->options.use_ssl = FALSE;
14101405
my_free(mysql->connector_fd,MYF(MY_ALLOW_ZERO_PTR));
14111406
mysql->connector_fd = 0;
1407+
#endif /* HAVE_OPENSSL */
14121408
return 0;
14131409
}
1414-
#endif /* HAVE_OPENSSL */
14151410

14161411
/**************************************************************************
14171412
** Connect to sql server

sql/mysqld.cc

+2
Original file line numberDiff line numberDiff line change
@@ -1991,7 +1991,9 @@ The server will not act as a slave.");
19911991
if(hEventShutdown) CloseHandle(hEventShutdown);
19921992
}
19931993
#endif
1994+
#ifdef HAVE_OPENSSL
19941995
my_free((gptr)ssl_acceptor_fd,MYF(0));
1996+
#endif /* HAVE_OPENSSL */
19951997
/* Wait until cleanup is done */
19961998
(void) pthread_mutex_lock(&LOCK_thread_count);
19971999
while (!ready_to_exit)

0 commit comments

Comments
 (0)