Tue May 19 12:00:30 CDT 2009 Pekka Pessi <first.last@nokia.com>

* su_uniqueid.c: Solaris misdefines PTHREAD_ONCE_INIT 
  Ignore-this: 9fe2247164d572901ed4a30b009353db
  
  Solaris defines pthread_once_t as a struct containing an array. The
  initializer PTHREAD_ONCE_INIT needs two levels of brackets it but only has
  one. Original patch from Mike Jerris <mike@jerris.com>.



git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13388 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2009-05-19 17:25:08 +00:00
parent c60535e7a8
commit ed9ddb3c56
2 changed files with 33 additions and 8 deletions

View File

@ -1 +1 @@
Tue May 19 12:23:01 CDT 2009 Tue May 19 12:24:21 CDT 2009

View File

@ -68,11 +68,38 @@ static char const __func__[] = "tport_tls";
#include <signal.h> #include <signal.h>
#endif #endif
#if SU_HAVE_PTHREADS
#include <pthread.h>
#if __sun
#undef PTHREAD_ONCE_INIT
#define PTHREAD_ONCE_INIT {{ 0, 0, 0, PTHREAD_ONCE_NOTDONE }}
#endif
static pthread_once_t once = PTHREAD_ONCE_INIT;
#define ONCE_INIT(f) pthread_once(&once, f)
#else
static int once;
#define ONCE_INIT(f) (!once ? (once = 1), f() : (void)0)
#endif
#include "tport_tls.h" #include "tport_tls.h"
char const tls_version[] = OPENSSL_VERSION_TEXT; char const tls_version[] = OPENSSL_VERSION_TEXT;
int tls_ex_data_idx = -1; /* see SSL_get_ex_new_index(3ssl) */ int tls_ex_data_idx = -1; /* see SSL_get_ex_new_index(3ssl) */
static void
tls_init_once(void)
{
SSL_library_init();
SSL_load_error_strings();
tls_ex_data_idx = SSL_get_ex_new_index(0, "sofia-sip private data", NULL, NULL, NULL);
}
enum { tls_master = 0, tls_slave = 1}; enum { tls_master = 0, tls_slave = 1};
struct tls_s { struct tls_s {
@ -218,15 +245,13 @@ int tls_verify_cb(int ok, X509_STORE_CTX *store)
static static
int tls_init_context(tls_t *tls, tls_issues_t const *ti) int tls_init_context(tls_t *tls, tls_issues_t const *ti)
{ {
static int initialized = 0;
int verify; int verify;
static int random_loaded;
if (!initialized) { ONCE_INIT(tls_init_once);
initialized = 1;
SSL_library_init(); if (!random_loaded) {
SSL_load_error_strings(); random_loaded = 1;
tls_ex_data_idx = SSL_get_ex_new_index(0, \
"sofia-sip private data", NULL, NULL, NULL);
if (ti->randFile && if (ti->randFile &&
!RAND_load_file(ti->randFile, 1024 * 1024)) { !RAND_load_file(ti->randFile, 1024 * 1024)) {