Skip to content

Commit

Permalink
Bug#14547920 I_MAIN.BUG13115401 CAUSING VALGRIND REPORT FAILURE ON PB2
Browse files Browse the repository at this point in the history
Fix various platform-specific problems.
  • Loading branch information
Tor Didriksen committed Oct 30, 2012
1 parent f015f26 commit 427f331
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 13 deletions.
7 changes: 4 additions & 3 deletions configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 <pthread.h>
void foo(void) {}
Expand Down
2 changes: 2 additions & 0 deletions extra/yassl/src/buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
*/


// First include (the generated) my_config.h, to get correct platform defines.
#include "my_config.h"
#include <string.h> // memcpy
#include "runtime.hpp"
#include "buffer.hpp"
Expand Down
27 changes: 17 additions & 10 deletions extra/yassl/src/yassl_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Windows.h>
#else
#include <pthread.h>
#endif

#include "runtime.hpp"
#include "yassl_int.hpp"
#include "handshake.hpp"
#include "timer.hpp"

#ifdef _POSIX_THREADS
#include "pthread.h"
#endif

#ifdef __WIN__
#include<Windows.h>
#endif
#ifdef HAVE_LIBZ
#include "zlib.h"
#endif
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 */)
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions unittest/gunit/yassl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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})
6 changes: 6 additions & 0 deletions unittest/gunit/yassl/yassl-t.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
#include "my_config.h"
#include <gtest/gtest.h>

#ifdef __WIN__
#include<Windows.h>
#else
#include <pthread.h>
#endif

#include "runtime.hpp"
#include "yassl_int.hpp"

Expand Down

0 comments on commit 427f331

Please sign in to comment.