From 427f3313aaee6ff679eb1628116a6051dedbbc3c Mon Sep 17 00:00:00 2001 From: Tor Didriksen Date: Tue, 30 Oct 2012 14:49:44 +0100 Subject: [PATCH] Bug#14547920 I_MAIN.BUG13115401 CAUSING VALGRIND REPORT FAILURE ON PB2 Fix various platform-specific problems. --- configure.cmake | 7 ++++--- extra/yassl/src/buffer.cpp | 2 ++ extra/yassl/src/yassl_int.cpp | 27 +++++++++++++++++---------- unittest/gunit/yassl/CMakeLists.txt | 2 ++ unittest/gunit/yassl/yassl-t.cc | 6 ++++++ 5 files changed, 31 insertions(+), 13 deletions(-) diff --git a/configure.cmake b/configure.cmake index 30324a4fdc53..d4cf19409107 100644 --- a/configure.cmake +++ b/configure.cmake @@ -325,13 +325,14 @@ ENDIF() # Figure out threading library # FIND_PACKAGE (Threads) +# Defines CMAKE_USE_PTHREADS_INIT and CMAKE_THREAD_LIBS_INIT. +INCLUDE(FindThreads) FUNCTION(MY_CHECK_PTHREAD_ONCE_INIT) CHECK_C_COMPILER_FLAG("-Werror" HAVE_WERROR_FLAG) - IF(NOT HAVE_WERROR_FLAG) - RETURN() + IF(HAVE_WERROR_FLAG) + SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror") ENDIF() - SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror") CHECK_C_SOURCE_COMPILES(" #include void foo(void) {} diff --git a/extra/yassl/src/buffer.cpp b/extra/yassl/src/buffer.cpp index f81740982494..433b3958b095 100644 --- a/extra/yassl/src/buffer.cpp +++ b/extra/yassl/src/buffer.cpp @@ -23,6 +23,8 @@ */ +// First include (the generated) my_config.h, to get correct platform defines. +#include "my_config.h" #include // memcpy #include "runtime.hpp" #include "buffer.hpp" diff --git a/extra/yassl/src/yassl_int.cpp b/extra/yassl/src/yassl_int.cpp index a97ccc779879..0507dc303c6e 100644 --- a/extra/yassl/src/yassl_int.cpp +++ b/extra/yassl/src/yassl_int.cpp @@ -17,18 +17,19 @@ * draft along with type conversion functions. */ +// First include (the generated) my_config.h, to get correct platform defines. +#include "my_config.h" +#ifdef __WIN__ +#include +#else +#include +#endif + #include "runtime.hpp" #include "yassl_int.hpp" #include "handshake.hpp" #include "timer.hpp" -#ifdef _POSIX_THREADS - #include "pthread.h" -#endif - -#ifdef __WIN__ - #include -#endif #ifdef HAVE_LIBZ #include "zlib.h" #endif @@ -1627,10 +1628,15 @@ void Session_initialize() sessionsInstance = NEW_YS Sessions; } +extern "C" +{ + static void c_session_initialize() { Session_initialize(); } +} + Sessions& GetSessions() { - yassl_pthread_once(&session_created, Session_initialize); + yassl_pthread_once(&session_created, c_session_initialize); return *sessionsInstance; } @@ -1886,6 +1892,8 @@ extern "C" char *yassl_mysql_strdup(const char *from, int) } +extern "C" +{ static int default_password_callback(char * buffer, int size_arg, int rwflag, void * /* unused: callback_data */) @@ -1914,7 +1922,7 @@ default_password_callback(char * buffer, int size_arg, int rwflag, free(passwd); return passwd_len; } - +} SSL_CTX::SSL_CTX(SSL_METHOD* meth) : method_(meth), certificate_(0), privateKey_(0), @@ -2689,7 +2697,6 @@ extern "C" void yaSSL_CleanUp() yaSSL::ysDelete(yaSSL::sslFactoryInstance); yaSSL::ysDelete(yaSSL::sessionsInstance); yaSSL::ysDelete(yaSSL::errorsInstance); - yaSSL::session_created= YASSL_PTHREAD_ONCE_INIT; // In case user calls more than once, prevent seg fault yaSSL::sslFactoryInstance = 0; diff --git a/unittest/gunit/yassl/CMakeLists.txt b/unittest/gunit/yassl/CMakeLists.txt index 321f0ab400e1..f496edf4b466 100644 --- a/unittest/gunit/yassl/CMakeLists.txt +++ b/unittest/gunit/yassl/CMakeLists.txt @@ -14,6 +14,7 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA INCLUDE_DIRECTORIES( + ${GTEST_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/unittest/gunit ${CMAKE_SOURCE_DIR}/extra/yassl/include @@ -29,3 +30,4 @@ SET(CMAKE_CXX_FLAGS ${nowerr_flags}) ADD_EXECUTABLE(yassl-t yassl-t.cc) TARGET_LINK_LIBRARIES(yassl-t gunit_small sqlgunitlib strings dbug regex) +TARGET_LINK_LIBRARIES(yassl-t ${LIBSOCKET}) diff --git a/unittest/gunit/yassl/yassl-t.cc b/unittest/gunit/yassl/yassl-t.cc index c4debb8c1c40..fa8ff3e94603 100644 --- a/unittest/gunit/yassl/yassl-t.cc +++ b/unittest/gunit/yassl/yassl-t.cc @@ -17,6 +17,12 @@ #include "my_config.h" #include +#ifdef __WIN__ +#include +#else +#include +#endif + #include "runtime.hpp" #include "yassl_int.hpp"