mirror of
https://github.com/codership/wsrep-lib.git
synced 2025-07-24 10:42:31 +03:00
Updated wsrep-API, added -Wconversion to compiler flags, fixed errors.
This commit is contained in:
@ -29,6 +29,7 @@
|
||||
#include <wsrep_api.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <climits>
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
@ -96,69 +97,51 @@ namespace
|
||||
inline uint32_t map_one(const int flags, const F from,
|
||||
const T to)
|
||||
{
|
||||
return ((flags & from) ? to : 0);
|
||||
// INT_MAX because GCC 4.4 does not eat numeric_limits<int>::max()
|
||||
// in static_assert
|
||||
static_assert(WSREP_FLAGS_LAST < INT_MAX,
|
||||
"WSREP_FLAGS_LAST < INT_MAX");
|
||||
return static_cast<uint32_t>((flags & static_cast<int>(from)) ?
|
||||
static_cast<int>(to) : 0);
|
||||
}
|
||||
|
||||
uint32_t map_flags_to_native(int flags)
|
||||
{
|
||||
using wsrep::provider;
|
||||
return (map_one(flags,
|
||||
provider::flag::start_transaction,
|
||||
WSREP_FLAG_TRX_START) |
|
||||
map_one(flags,
|
||||
provider::flag::commit,
|
||||
WSREP_FLAG_TRX_END) |
|
||||
map_one(flags,
|
||||
provider::flag::rollback,
|
||||
WSREP_FLAG_ROLLBACK) |
|
||||
map_one(flags,
|
||||
provider::flag::isolation,
|
||||
WSREP_FLAG_ISOLATION) |
|
||||
map_one(flags,
|
||||
provider::flag::pa_unsafe,
|
||||
WSREP_FLAG_PA_UNSAFE) |
|
||||
// map_one(flags, provider::flag::commutative, WSREP_FLAG_COMMUTATIVE) |
|
||||
// map_one(flags, provider::flag::native, WSREP_FLAG_NATIVE) |
|
||||
map_one(flags,
|
||||
provider::flag::prepare,
|
||||
WSREP_FLAG_TRX_PREPARE) |
|
||||
map_one(flags,
|
||||
provider::flag::snapshot,
|
||||
WSREP_FLAG_SNAPSHOT) |
|
||||
map_one(flags,
|
||||
provider::flag::implicit_deps,
|
||||
WSREP_FLAG_IMPLICIT_DEPS));
|
||||
using wsrep::provider;
|
||||
return static_cast<uint32_t>(
|
||||
map_one(flags, provider::flag::start_transaction,
|
||||
WSREP_FLAG_TRX_START) |
|
||||
map_one(flags, provider::flag::commit, WSREP_FLAG_TRX_END) |
|
||||
map_one(flags, provider::flag::rollback, WSREP_FLAG_ROLLBACK) |
|
||||
map_one(flags, provider::flag::isolation, WSREP_FLAG_ISOLATION) |
|
||||
map_one(flags, provider::flag::pa_unsafe, WSREP_FLAG_PA_UNSAFE) |
|
||||
// map_one(flags, provider::flag::commutative, WSREP_FLAG_COMMUTATIVE)
|
||||
// |
|
||||
// map_one(flags, provider::flag::native, WSREP_FLAG_NATIVE) |
|
||||
map_one(flags, provider::flag::prepare, WSREP_FLAG_TRX_PREPARE) |
|
||||
map_one(flags, provider::flag::snapshot, WSREP_FLAG_SNAPSHOT) |
|
||||
map_one(flags, provider::flag::implicit_deps,
|
||||
WSREP_FLAG_IMPLICIT_DEPS));
|
||||
}
|
||||
|
||||
int map_flags_from_native(uint32_t flags)
|
||||
int map_flags_from_native(uint32_t flags_u32)
|
||||
{
|
||||
using wsrep::provider;
|
||||
return (map_one(flags,
|
||||
WSREP_FLAG_TRX_START,
|
||||
provider::flag::start_transaction) |
|
||||
map_one(flags,
|
||||
WSREP_FLAG_TRX_END,
|
||||
provider::flag::commit) |
|
||||
map_one(flags,
|
||||
WSREP_FLAG_ROLLBACK,
|
||||
provider::flag::rollback) |
|
||||
map_one(flags,
|
||||
WSREP_FLAG_ISOLATION,
|
||||
provider::flag::isolation) |
|
||||
map_one(flags,
|
||||
WSREP_FLAG_PA_UNSAFE,
|
||||
provider::flag::pa_unsafe) |
|
||||
// map_one(flags, provider::flag::commutative, WSREP_FLAG_COMMUTATIVE) |
|
||||
// map_one(flags, provider::flag::native, WSREP_FLAG_NATIVE) |
|
||||
map_one(flags,
|
||||
WSREP_FLAG_TRX_PREPARE,
|
||||
provider::flag::prepare) |
|
||||
map_one(flags,
|
||||
WSREP_FLAG_SNAPSHOT,
|
||||
provider::flag::snapshot) |
|
||||
map_one(flags,
|
||||
WSREP_FLAG_IMPLICIT_DEPS,
|
||||
provider::flag::implicit_deps));
|
||||
using wsrep::provider;
|
||||
const int flags(static_cast<int>(flags_u32));
|
||||
return static_cast<int>(
|
||||
map_one(flags, WSREP_FLAG_TRX_START,
|
||||
provider::flag::start_transaction) |
|
||||
map_one(flags, WSREP_FLAG_TRX_END, provider::flag::commit) |
|
||||
map_one(flags, WSREP_FLAG_ROLLBACK, provider::flag::rollback) |
|
||||
map_one(flags, WSREP_FLAG_ISOLATION, provider::flag::isolation) |
|
||||
map_one(flags, WSREP_FLAG_PA_UNSAFE, provider::flag::pa_unsafe) |
|
||||
// map_one(flags, provider::flag::commutative, WSREP_FLAG_COMMUTATIVE)
|
||||
// |
|
||||
// map_one(flags, provider::flag::native, WSREP_FLAG_NATIVE) |
|
||||
map_one(flags, WSREP_FLAG_TRX_PREPARE, provider::flag::prepare) |
|
||||
map_one(flags, WSREP_FLAG_SNAPSHOT, provider::flag::snapshot) |
|
||||
map_one(flags, WSREP_FLAG_IMPLICIT_DEPS,
|
||||
provider::flag::implicit_deps));
|
||||
}
|
||||
|
||||
class mutable_ws_handle
|
||||
@ -288,7 +271,7 @@ namespace
|
||||
* be made explicit. */
|
||||
int map_capabilities_from_native(wsrep_cap_t capabilities)
|
||||
{
|
||||
return capabilities;
|
||||
return static_cast<int>(capabilities);
|
||||
}
|
||||
wsrep::view view_from_native(const wsrep_view_info& view_info,
|
||||
const wsrep::id& own_id)
|
||||
@ -322,7 +305,11 @@ namespace
|
||||
// by the ID.
|
||||
for (size_t i(0); i < members.size(); ++i)
|
||||
{
|
||||
if (own_id == members[i].id()) { own_idx = i; break; }
|
||||
if (own_id == members[i].id())
|
||||
{
|
||||
own_idx = static_cast<int>(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -351,11 +338,18 @@ namespace
|
||||
wsrep::server_state& server_state(
|
||||
*reinterpret_cast<wsrep::server_state*>(app_ctx));
|
||||
wsrep::view view(view_from_native(*view_info, server_state.id()));
|
||||
assert(view.own_index() >= 0);
|
||||
const ssize_t own_index(view.own_index());
|
||||
assert(own_index >= 0);
|
||||
if (own_index < 0)
|
||||
{
|
||||
wsrep::log_error() << "Connected without being in reported view";
|
||||
return WSREP_CB_FAILURE;
|
||||
}
|
||||
assert(// first connect
|
||||
server_state.id().is_undefined() ||
|
||||
// reconnect to primary component
|
||||
server_state.id() == view.members()[view.own_index()].id());
|
||||
server_state.id().is_undefined() ||
|
||||
// reconnect to primary component
|
||||
server_state.id() ==
|
||||
view.members()[static_cast<size_t>(own_index)].id());
|
||||
try
|
||||
{
|
||||
server_state.on_connect(view);
|
||||
@ -661,7 +655,7 @@ int wsrep::wsrep_provider_v26::disconnect()
|
||||
|
||||
int wsrep::wsrep_provider_v26::capabilities() const
|
||||
{
|
||||
return wsrep_->capabilities(wsrep_);
|
||||
return map_capabilities_from_native(wsrep_->capabilities(wsrep_));
|
||||
}
|
||||
int wsrep::wsrep_provider_v26::desync()
|
||||
{
|
||||
|
Reference in New Issue
Block a user