1
0
Fork 0

silenced compiler warnings

This commit is contained in:
Frank Celler 2016-10-15 09:31:34 +00:00
parent 2c7ff60e1e
commit 282b5ac8b8
10 changed files with 80 additions and 127 deletions

View File

@ -26,10 +26,9 @@
#include "Basics/Thread.h"
#include <boost/asio.hpp>
#include "Basics/ConditionVariable.h"
#include "Basics/Mutex.h"
#include "Basics/asio-helper.h"
#include "Cluster/AgencyComm.h"
#include "Cluster/DBServerAgencySync.h"
#include "Logger/Logger.h"

View File

@ -28,6 +28,7 @@
#include <openssl/ssl.h>
#include <boost/asio/ssl.hpp>
#include "Basics/asio-helper.h"
#include "Actions/RestActionHandler.h"
#include "VocBase/AuthInfo.h"

View File

@ -25,9 +25,9 @@
#include "Basics/Common.h"
#include <boost/asio.hpp>
#include <boost/lockfree/queue.hpp>
#include "Basics/asio-helper.h"
#include "Basics/ConditionVariable.h"
#include "Basics/Thread.h"
#include "Scheduler/Job.h"

View File

@ -29,6 +29,7 @@
#include <boost/asio/ssl.hpp>
#include "Basics/asio-helper.h"
#include "Basics/StringBuffer.h"
#include "Scheduler/Socket.h"
#include "Statistics/StatisticsAgent.h"

68
lib/Basics/asio-helper.h Normal file
View File

@ -0,0 +1,68 @@
////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///
/// Copyright 2016 ArangoDB GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
///
/// @author Dr. Frank Celler
////////////////////////////////////////////////////////////////////////////////
#include <boost/asio.hpp>
// these classes are only here in order to shutup compiler warning
// DO NOT USE THEM!
#ifndef ARANGODB_BASICS_ASIO_HELPER_H_1
#define ARANGODB_BASICS_ASIO_HELPER_H_1 1
namespace {
class Unused1 {
protected:
const boost::system::error_category& unused1
= boost::asio::error::system_category;
const boost::system::error_category& unused2
= boost::asio::error::netdb_category;
const boost::system::error_category& unused3
= boost::asio::error::addrinfo_category;
const boost::system::error_category& unused4
= boost::asio::error::misc_category;
const boost::system::error_category& unused5
= boost::system::posix_category;
const boost::system::error_category& unused6
= boost::system::errno_ecat;
const boost::system::error_category& unused7
= boost::system::native_ecat;
};
}
#endif
#ifdef BOOST_ASIO_SSL_HPP
#ifndef ARANGODB_BASICS_ASIO_HELPER_H_2
#define ARANGODB_BASICS_ASIO_HELPER_H_2 1
namespace {
class Unused2 {
protected:
const boost::system::error_category& unused1
= boost::asio::error::ssl_category;
};
}
#endif
#endif

View File

@ -26,8 +26,6 @@
#include "Basics/Common.h"
#include <boost/asio.hpp>
#ifdef TRI_HAVE_WINSOCK2_H
#include <WinSock2.h>
#include <WS2tcpip.h>
@ -35,6 +33,7 @@
#include <ostream>
#include "Basics/asio-helper.h"
#include "Basics/socket-utils.h"
namespace arangodb {

View File

@ -42,96 +42,6 @@ using namespace arangodb;
using namespace arangodb::basics;
using namespace arangodb::options;
// OPEN SSL support
namespace {
long* opensslLockCount;
TRI_mutex_t* opensslLocks;
#if OPENSSL_VERSION_NUMBER < 0x01000000L
unsigned long opensslThreadId() {
return (unsigned long)Thread::currentThreadId();
}
#else
// The compiler chooses the right one from the following two,
// according to the type of the return value of pthread_self():
#ifndef __sun
template <typename T>
void setter(CRYPTO_THREADID* id, T p) {
CRYPTO_THREADID_set_pointer(id, p);
}
#else
template <typename T>
void setter(CRYPTO_THREADID* id, T p) {
CRYPTO_THREADID_set_pointer(id, (void*)(intptr_t)p);
}
#endif
#ifndef __APPLE__
template <>
void setter(CRYPTO_THREADID* id, unsigned long val) {
CRYPTO_THREADID_set_numeric(id, val);
}
#endif
static void arango_threadid_func(CRYPTO_THREADID* id) {
auto self = Thread::currentThreadId();
setter<decltype(self)>(id, self);
}
#endif
void opensslLockingCallback(int mode, int type, char const* /* file */,
int /* line */) {
if (mode & CRYPTO_LOCK) {
TRI_LockMutex(&(opensslLocks[type]));
opensslLockCount[type]++;
} else {
TRI_UnlockMutex(&(opensslLocks[type]));
}
}
void opensslSetup() {
opensslLockCount = (long*)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(long));
opensslLocks =
(TRI_mutex_t*)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(TRI_mutex_t));
for (long i = 0; i < CRYPTO_num_locks(); ++i) {
opensslLockCount[i] = 0;
TRI_InitMutex(&(opensslLocks[i]));
}
#if OPENSSL_VERSION_NUMBER < 0x01000000L
CRYPTO_set_id_callback(opensslThreadId);
CRYPTO_set_locking_callback(opensslLockingCallback);
#else
CRYPTO_THREADID_set_callback(arango_threadid_func);
CRYPTO_set_locking_callback(opensslLockingCallback);
#endif
}
void opensslCleanup() {
CRYPTO_set_locking_callback(nullptr);
#if OPENSSL_VERSION_NUMBER < 0x01000000L
CRYPTO_set_id_callback(nullptr);
#else
CRYPTO_THREADID_set_callback(nullptr);
#endif
for (long i = 0; i < CRYPTO_num_locks(); ++i) {
TRI_DestroyMutex(&(opensslLocks[i]));
}
OPENSSL_free(opensslLocks);
OPENSSL_free(opensslLockCount);
}
}
const boost::asio::ssl::detail::openssl_init<true> SslFeature::sslBase{};
SslFeature::SslFeature(application_features::ApplicationServer* server)
@ -143,18 +53,7 @@ SslFeature::SslFeature(application_features::ApplicationServer* server)
}
void SslFeature::prepare() {
// SSL_library_init();
// SSL_load_error_strings();
// OpenSSL_add_all_algorithms();
// ERR_load_crypto_strings();
// opensslSetup();
}
void SslFeature::unprepare() {
// opensslCleanup();
// ERR_free_strings();
// EVP_cleanup();
// CRYPTO_cleanup_all_ex_data();
}

View File

@ -28,6 +28,8 @@
#include <openssl/ssl.h>
#include <boost/asio/ssl.hpp>
#include "Basics/asio-helper.h"
namespace arangodb {
class SslFeature final : public application_features::ApplicationFeature {
public:

View File

@ -28,6 +28,8 @@
#include <openssl/ssl.h>
#include <boost/asio/ssl.hpp>
#include "Basics/asio-helper.h"
namespace arangodb {
class SslServerFeature final : public application_features::ApplicationFeature {
public:

View File

@ -31,12 +31,10 @@
#include <boost/asio/ssl.hpp>
#include <boost/optional.hpp>
#include "Basics/asio-helper.h"
namespace arangodb {
////////////////////////////////////////////////////////////////////////////////
/// @brief SSL protocol methods
////////////////////////////////////////////////////////////////////////////////
// SSL protocol methods
enum protocol_e {
SSL_UNKNOWN = 0,
SSL_V2 = 1,
@ -48,33 +46,17 @@ enum protocol_e {
SSL_LAST
};
////////////////////////////////////////////////////////////////////////////////
/// @brief SSL_CONST
////////////////////////////////////////////////////////////////////////////////
#if (OPENSSL_VERSION_NUMBER < 0x00999999L)
#define SSL_CONST /* */
#else
#define SSL_CONST const
#endif
////////////////////////////////////////////////////////////////////////////////
/// @brief creates an SSL context
////////////////////////////////////////////////////////////////////////////////
boost::optional<boost::asio::ssl::context> sslContext(
protocol_e, std::string const& keyfile);
////////////////////////////////////////////////////////////////////////////////
/// @brief get the name of an SSL protocol version
////////////////////////////////////////////////////////////////////////////////
std::string protocolName(protocol_e protocol);
////////////////////////////////////////////////////////////////////////////////
/// @brief get last SSL error
////////////////////////////////////////////////////////////////////////////////
std::string lastSSLError();
}