From a8159c71bf5f1e156998956e94172248f3ee7527 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 18 Apr 2006 10:16:06 +0200 Subject: [PATCH 1/3] mysql.cc: revert bug#16855 "fix" per Monty's request client/mysql.cc: revert bug#16855 "fix" per Monty's request --- client/mysql.cc | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 2001056dea1..eb6970691bb 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -653,7 +653,7 @@ static struct my_option my_long_options[] = "Base name of shared memory.", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"socket", 'S', "Socket file to use for connection. (This will override --port unless --protocol=TCP is specified.)", + {"socket", 'S', "Socket file to use for connection.", (gptr*) &opt_mysql_unix_port, (gptr*) &opt_mysql_unix_port, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #include "sslopt-longopts.h" @@ -939,14 +939,7 @@ static int get_options(int argc, char **argv) opt_reconnect= 0; connect_flag= 0; /* Not in interactive mode */ } - - if (opt_mysql_port && (!opt_protocol) && (!opt_mysql_unix_port)) - { - /* Not checking return type since we are using a constant value */ - /* straight from the initialization of sql_protocol_typelib. */ - opt_protocol= find_type("TCP", &sql_protocol_typelib, 0); - } - + if (strcmp(default_charset, charset_info->csname) && !(charset_info= get_charset_by_csname(default_charset, MY_CS_PRIMARY, MYF(MY_WME)))) From 5db9db07a568c881e2dfcd48f8440d9fed027dc2 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 18 Apr 2006 12:08:06 +0200 Subject: [PATCH 2/3] Bug#18815 libmysql using yassl can't be linked with c program - Apply patch to remove dependency on C++ libs when linking "libmysql" from c extra/yassl/include/openssl/rsa.h: Fix spelling error extra/yassl/include/openssl/ssl.h: Fix spelling error extra/yassl/include/yassl_int.hpp: Remove static instance extra/yassl/include/yassl_types.hpp: Add CleanUp function for static singletons extra/yassl/src/handshake.cpp: Use buffered.reset(0) instead of null_buffer extra/yassl/src/template_instnt.cpp: Add instantiation of two new templates extra/yassl/src/yassl_int.cpp: Use static pointers for singletons extra/yassl/taocrypt/include/integer.hpp: Remove statoc singletons from class scope extra/yassl/taocrypt/include/misc.hpp: Add clenaup function extra/yassl/taocrypt/include/runtime.hpp: Add runtime for Solaris extra/yassl/taocrypt/src/algebra.cpp: Use mySTL::vector to avoid array of Element being on the stack extra/yassl/taocrypt/src/integer.cpp: Use static pointers for singletons Add cleanup function extra/yassl/taocrypt/src/template_instnt.cpp: Add instantiation of one new template --- extra/yassl/include/openssl/rsa.h | 2 +- extra/yassl/include/openssl/ssl.h | 2 +- extra/yassl/include/yassl_int.hpp | 4 --- extra/yassl/include/yassl_types.hpp | 5 ++++ extra/yassl/src/handshake.cpp | 17 +++++++------ extra/yassl/src/template_instnt.cpp | 2 ++ extra/yassl/src/yassl_int.cpp | 22 +++++++++++++---- extra/yassl/taocrypt/include/integer.hpp | 2 -- extra/yassl/taocrypt/include/misc.hpp | 5 ++++ extra/yassl/taocrypt/include/runtime.hpp | 26 ++++++++++++++++---- extra/yassl/taocrypt/src/algebra.cpp | 4 ++- extra/yassl/taocrypt/src/integer.cpp | 21 +++++++++++++--- extra/yassl/taocrypt/src/template_instnt.cpp | 1 + 13 files changed, 83 insertions(+), 30 deletions(-) diff --git a/extra/yassl/include/openssl/rsa.h b/extra/yassl/include/openssl/rsa.h index 1ab9d13b89f..fe64e655bdc 100644 --- a/extra/yassl/include/openssl/rsa.h +++ b/extra/yassl/include/openssl/rsa.h @@ -1,7 +1,7 @@ /* rsa.h for openSSL */ -#ifndef ysSSL_rsa_h__ +#ifndef yaSSL_rsa_h__ #define yaSSL_rsa_h__ enum { RSA_F4 = 1 }; diff --git a/extra/yassl/include/openssl/ssl.h b/extra/yassl/include/openssl/ssl.h index 1c8291c2f13..8a87196b7ed 100644 --- a/extra/yassl/include/openssl/ssl.h +++ b/extra/yassl/include/openssl/ssl.h @@ -23,7 +23,7 @@ * */ -#ifndef ysSSL_openssl_h__ +#ifndef yaSSL_openssl_h__ #define yaSSL_openssl_h__ #include /* ERR_print fp */ diff --git a/extra/yassl/include/yassl_int.hpp b/extra/yassl/include/yassl_int.hpp index 60a78a3970e..e75294ad073 100644 --- a/extra/yassl/include/yassl_int.hpp +++ b/extra/yassl/include/yassl_int.hpp @@ -123,8 +123,6 @@ public: friend sslFactory& GetSSL_Factory(); // singleton creator private: - static sslFactory instance_; - sslFactory(const sslFactory&); // hide copy sslFactory& operator=(const sslFactory&); // and assign }; @@ -216,8 +214,6 @@ public: friend Sessions& GetSessions(); // singleton creator private: - static Sessions instance_; - Sessions(const Sessions&); // hide copy Sessions& operator=(const Sessions&); // and assign }; diff --git a/extra/yassl/include/yassl_types.hpp b/extra/yassl/include/yassl_types.hpp index ec9e6fb7ceb..66cc6aa3c68 100644 --- a/extra/yassl/include/yassl_types.hpp +++ b/extra/yassl/include/yassl_types.hpp @@ -34,6 +34,11 @@ namespace yaSSL { + +// Delete static singleton memory holders +void CleanUp(); + + // library allocation struct new_t {}; // yaSSL New type extern new_t ys; // pass in parameter diff --git a/extra/yassl/src/handshake.cpp b/extra/yassl/src/handshake.cpp index d7df438b8df..16c9bde2003 100644 --- a/extra/yassl/src/handshake.cpp +++ b/extra/yassl/src/handshake.cpp @@ -648,8 +648,6 @@ void build_certHashes(SSL& ssl, Hashes& hashes) } -mySTL::auto_ptr null_buffer(ysDelete); - // do process input requests mySTL::auto_ptr DoProcessReply(SSL& ssl, mySTL::auto_ptr buffered) @@ -659,7 +657,8 @@ DoProcessReply(SSL& ssl, mySTL::auto_ptr buffered) if (!ready) { // Nothing to receive after blocking wait => error ssl.SetError(receive_error); - return buffered= null_buffer; + buffered.reset(0); + return buffered; } // add buffered data if its there @@ -667,10 +666,10 @@ DoProcessReply(SSL& ssl, mySTL::auto_ptr buffered) input_buffer buffer(buffSz + ready); if (buffSz) { buffer.assign(buffered.get()->get_buffer(), buffSz); - buffered = null_buffer; + buffered.reset(0); } - // add new (ys) data + // add new data uint read = ssl.getSocket().receive(buffer.get_buffer() + buffSz, ready); buffer.add_size(read); uint offset = 0; @@ -703,11 +702,15 @@ DoProcessReply(SSL& ssl, mySTL::auto_ptr buffered) mySTL::auto_ptr msg(mf.CreateObject(hdr.type_), ysDelete); if (!msg.get()) { ssl.SetError(factory_error); - return buffered = null_buffer; + buffered.reset(0); + return buffered; } buffer >> *msg; msg->Process(buffer, ssl); - if (ssl.GetError()) return buffered = null_buffer; + if (ssl.GetError()) { + buffered.reset(0); + return buffered; + } } offset += hdr.length_ + RECORD_HEADER; } diff --git a/extra/yassl/src/template_instnt.cpp b/extra/yassl/src/template_instnt.cpp index 5ee57e76aed..c55ca39bec2 100644 --- a/extra/yassl/src/template_instnt.cpp +++ b/extra/yassl/src/template_instnt.cpp @@ -87,6 +87,8 @@ template void ysDelete(BulkCipher*); template void ysDelete(Digest*); template void ysDelete(X509*); template void ysDelete(Message*); +template void ysDelete(sslFactory*); +template void ysDelete(Sessions*); template void ysArrayDelete(unsigned char*); template void ysArrayDelete(char*); } diff --git a/extra/yassl/src/yassl_int.cpp b/extra/yassl/src/yassl_int.cpp index 740618ce701..87d990b3506 100644 --- a/extra/yassl/src/yassl_int.cpp +++ b/extra/yassl/src/yassl_int.cpp @@ -1361,19 +1361,31 @@ SSL_SESSION::~SSL_SESSION() } -Sessions Sessions::instance_; // simple singleton +static Sessions* sessionsInstance = 0; Sessions& GetSessions() { - return Sessions::instance_; + if (!sessionsInstance) + sessionsInstance = new (ys) Sessions; + return *sessionsInstance; } -sslFactory sslFactory::instance_; // simple singleton +static sslFactory* sslFactoryInstance = 0; sslFactory& GetSSL_Factory() -{ - return sslFactory::instance_; +{ + if (!sslFactoryInstance) + sslFactoryInstance = new (ys) sslFactory; + return *sslFactoryInstance; +} + + +void CleanUp() +{ + TaoCrypt::CleanUp(); + ysDelete(sslFactoryInstance); + ysDelete(sessionsInstance); } diff --git a/extra/yassl/taocrypt/include/integer.hpp b/extra/yassl/taocrypt/include/integer.hpp index 76034c3ae8f..d3bd731e2bd 100644 --- a/extra/yassl/taocrypt/include/integer.hpp +++ b/extra/yassl/taocrypt/include/integer.hpp @@ -275,8 +275,6 @@ private: AlignedWordBlock reg_; Sign sign_; - static const Integer zero_; - static const Integer one_; }; inline bool operator==(const Integer& a, const Integer& b) diff --git a/extra/yassl/taocrypt/include/misc.hpp b/extra/yassl/taocrypt/include/misc.hpp index f705cc99970..26383d4c96b 100644 --- a/extra/yassl/taocrypt/include/misc.hpp +++ b/extra/yassl/taocrypt/include/misc.hpp @@ -34,6 +34,11 @@ namespace TaoCrypt { + +// Delete static singleton holders +void CleanUp(); + + // library allocation struct new_t {}; // TaoCrypt New type extern new_t tc; // pass in parameter diff --git a/extra/yassl/taocrypt/include/runtime.hpp b/extra/yassl/taocrypt/include/runtime.hpp index 254e67a7f64..d9d7877bd93 100644 --- a/extra/yassl/taocrypt/include/runtime.hpp +++ b/extra/yassl/taocrypt/include/runtime.hpp @@ -25,11 +25,27 @@ -#if !defined(yaSSL_NEW_HPP) && defined(__GNUC__) -#if !(defined(__ICC) || defined(__INTEL_COMPILER)) - +#ifndef yaSSL_NEW_HPP #define yaSSL_NEW_HPP + +#ifdef __sun + +#include + +// Handler for pure virtual functions +namespace __Crun { + static void pure_error(void) + { + assert("Pure virtual method called." == "Aborted"); + } +} // namespace __Crun + +#endif // __sun + + +#if defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER)) + #if __GNUC__ > 2 extern "C" { @@ -47,6 +63,6 @@ static int __cxa_pure_virtual() } // extern "C" #endif // __GNUC__ > 2 -#endif // ! _ICC -#endif // yaSSL_NEW_HPP && __GNUC__ +#endif // compiler check +#endif // yaSSL_NEW_HPP diff --git a/extra/yassl/taocrypt/src/algebra.cpp b/extra/yassl/taocrypt/src/algebra.cpp index 45bbcfa662a..8f4ce051a43 100644 --- a/extra/yassl/taocrypt/src/algebra.cpp +++ b/extra/yassl/taocrypt/src/algebra.cpp @@ -76,7 +76,9 @@ const Integer& AbstractEuclideanDomain::Mod(const Element &a, const Integer& AbstractEuclideanDomain::Gcd(const Element &a, const Element &b) const { - Element g[3]={b, a}; + mySTL::vector g(3); + g[0]= b; + g[1]= a; unsigned int i0=0, i1=1, i2=2; while (!Equal(g[i1], this->Identity())) diff --git a/extra/yassl/taocrypt/src/integer.cpp b/extra/yassl/taocrypt/src/integer.cpp index 71324b04b92..4ade5491530 100644 --- a/extra/yassl/taocrypt/src/integer.cpp +++ b/extra/yassl/taocrypt/src/integer.cpp @@ -2709,19 +2709,32 @@ unsigned int Integer::Encode(byte* output, unsigned int outputLen, } -const Integer Integer::zero_; +static Integer* zero = 0; const Integer &Integer::Zero() { - return zero_; + if (!zero) + zero = new (tc) Integer; + return *zero; } -const Integer Integer::one_(1,2); +static Integer* one = 0; const Integer &Integer::One() { - return one_; + if (!one) + one = new (tc) Integer(1,2); + return *one; +} + + +// Clean up static singleton holders, not a leak, but helpful to have gone +// when checking for leaks +void CleanUp() +{ + tcDelete(one); + tcDelete(zero); } diff --git a/extra/yassl/taocrypt/src/template_instnt.cpp b/extra/yassl/taocrypt/src/template_instnt.cpp index 9a3c12badfc..59814d03209 100644 --- a/extra/yassl/taocrypt/src/template_instnt.cpp +++ b/extra/yassl/taocrypt/src/template_instnt.cpp @@ -41,6 +41,7 @@ template class RSA_Decryptor; template class RSA_Encryptor; template class RSA_Encryptor; template void tcDelete(HASH*); +template void tcDelete(Integer*); template void tcArrayDelete(byte*); template AllocatorWithCleanup::pointer StdReallocate >(AllocatorWithCleanup&, byte*, AllocatorWithCleanup::size_type, AllocatorWithCleanup::size_type, bool); template void tcArrayDelete(word*); From d1200b4a64ca5ea1bd2cb0b69c316cb6b3cbf316 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 18 Apr 2006 13:26:41 +0200 Subject: [PATCH 3/3] configure.in: Stepped up version to 5.0.20a configure.in: Stepped up version to 5.0.20a --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 60e34eeb9f5..f527661169e 100644 --- a/configure.in +++ b/configure.in @@ -7,7 +7,7 @@ AC_INIT(sql/mysqld.cc) AC_CANONICAL_SYSTEM # The Docs Makefile.am parses this line! # remember to also change ndb version below and update version.c in ndb -AM_INIT_AUTOMAKE(mysql, 5.0.20) +AM_INIT_AUTOMAKE(mysql, 5.0.20a) AM_CONFIG_HEADER(config.h) PROTOCOL_VERSION=10