Commit 79d5ff64 authored by Otto Kekäläinen's avatar Otto Kekäläinen

Imported Upstream version 25.3.13

parent 16e50dce
###################################################################
#
# Copyright (C) 2010-2014 Codership Oy <info@codership.com>
# Copyright (C) 2010-2015 Codership Oy <info@codership.com>
#
# SCons build script to build galera libraries
#
# How to control the build with environment variables:
# Set CC to specify C compiler
# Set CXX to specify C++ compiler
# Set CPPFLAGS to add non-standard include paths and preprocessor macros
# Set CCFLAGS to *override* optimization and architecture-specific options
# Set CFLAGS to supply C compiler options
# Set CXXFLAGS to supply C++ compiler options
# Set LDFLAGS to *override* linking flags
# Set LIBPATH to add non-standard linker paths
#
# Script structure:
# - Help message
# - Default parameters
......@@ -23,7 +33,7 @@ machine = platform.machine()
bits = ARGUMENTS.get('bits', platform.architecture()[0])
print 'Host: ' + sysname + ' ' + machine + ' ' + bits
x86 = any(arch in machine for arch in [ 'x86', 'i686', 'i386' ])
x86 = any(arch in machine for arch in [ 'x86', 'amd64', 'i686', 'i386' ])
if bits == '32bit':
bits = 32
......@@ -89,27 +99,23 @@ if dbug:
if sysname == 'sunos':
compile_arch = ' -mtune=native'
link_arch = ''
elif x86:
if bits == 32:
compile_arch = ' -m32 -march=i686'
link_arch = compile_arch
if sysname == 'linux':
link_arch = link_arch + ' -Wl,-melf_i386'
if machine == 'x86_64':
compile_arch = ' -mx32'
else:
compile_arch = ' -m32 -march=i686'
if sysname == 'linux':
link_arch = ' -Wl,-melf_i386'
else:
compile_arch = ' -m64'
link_arch = compile_arch
if sysname == 'linux':
link_arch = link_arch + ' -Wl,-melf_x86_64'
link_arch = ' -Wl,-melf_x86_64'
link_arch = compile_arch + link_arch
elif machine == 's390x':
compile_arch = ' -mzarch -march=z196 -mtune=zEC12'
link_arch = ''
if bits == 32:
compile_arch += ' -m32'
else:
compile_arch = ' -mtune=native'
link_arch = ''
boost = int(ARGUMENTS.get('boost', 1))
boost_pool = int(ARGUMENTS.get('boost_pool', 0))
......@@ -118,7 +124,7 @@ tests = int(ARGUMENTS.get('tests', 1))
strict_build_flags = int(ARGUMENTS.get('strict_build_flags', 1))
GALERA_VER = ARGUMENTS.get('version', '3.12')
GALERA_VER = ARGUMENTS.get('version', '3.13')
GALERA_REV = ARGUMENTS.get('revno', 'XXXX')
# Attempt to read from file if not given
......@@ -160,12 +166,16 @@ if link != 'default':
env.Replace(LINK = link)
# Initialize CPPFLAGS and LIBPATH from environment to get user preferences
env.Replace(CPPFLAGS = os.getenv('CPPFLAGS', ''))
env.Replace(LIBPATH = [os.getenv('LIBPATH', '')])
env.Replace(CPPFLAGS = os.getenv('CPPFLAGS', ''))
env.Replace(CCFLAGS = os.getenv('CCFLAGS', opt_flags + compile_arch))
env.Replace(CFLAGS = os.getenv('CFLAGS', ''))
env.Replace(CXXFLAGS = os.getenv('CXXFLAGS', ''))
env.Replace(LINKFLAGS = os.getenv('LDFLAGS', link_arch))
env.Replace(LIBPATH = [os.getenv('LIBPATH', '')])
# Set -pthread flag explicitly to make sure that pthreads are
# enabled on all platforms.
env.Append(CPPFLAGS = ' -pthread')
env.Append(CCFLAGS = ' -pthread')
# Freebsd ports are installed under /usr/local
if sysname == 'freebsd' or sysname == 'sunos':
......@@ -199,25 +209,24 @@ env.Append(CPPFLAGS = ' -DHAVE_COMMON_H')
# Common C/CXX flags
# These should be kept minimal as they are appended after C/CXX specific flags
env.Replace(CCFLAGS = opt_flags + compile_arch +
' -Wall -Wextra -Wno-unused-parameter')
env.Append(CCFLAGS = ' -Wall -Wextra -Wno-unused-parameter')
# C-specific flags
env.Replace(CFLAGS = ' -std=c99 -fno-strict-aliasing -pipe')
env.Append(CFLAGS = ' -std=c99 -fno-strict-aliasing -pipe')
# CXX-specific flags
# Note: not all 3rd-party libs like '-Wold-style-cast -Weffc++'
# adding those after checks
env.Replace(CXXFLAGS = ' -Wno-long-long -Wno-deprecated -ansi')
env.Append(CXXFLAGS = ' -Wno-long-long -Wno-deprecated -ansi')
if sysname != 'sunos':
env.Append(CXXFLAGS = ' -pipe')
# Linker flags
# TODO: enable '-Wl,--warn-common -Wl,--fatal-warnings' after warnings from
# TODO: enable ' -Wl,--warn-common -Wl,--fatal-warnings' after warnings from
# static linking have beed addressed
#
env.Append(LINKFLAGS = link_arch)
#env.Append(LINKFLAGS = ' -Wl,--warn-common -Wl,--fatal-warnings')
#
# Check required headers and libraries (autoconf functionality)
......@@ -273,6 +282,9 @@ elif sysname != 'darwin':
print 'can\'t find byte order information'
Exit(1)
if conf.CheckHeader('execinfo.h'):
conf.env.Append(CPPFLAGS = ' -DHAVE_EXECINFO_H')
# Additional C headers and libraries
# boost headers
......@@ -394,14 +406,13 @@ conf.env['CPPPATH'] = cpppath_saved
# these will be used only with our softaware
if strict_build_flags == 1:
conf.env.Append(CPPFLAGS = ' -Werror')
conf.env.Append(CCFLAGS = ' -pedantic')
conf.env.Append(CCFLAGS = ' -Werror -pedantic')
if 'clang' not in conf.env['CXX']:
conf.env.Append(CXXFLAGS = ' -Weffc++ -Wold-style-cast')
else:
conf.env.Append(CPPFLAGS = ' -Wno-self-assign')
conf.env.Append(CCFLAGS = ' -Wno-self-assign')
if 'ccache' in conf.env['CXX']:
conf.env.Append(CPPFLAGS = ' -Qunused-arguments')
conf.env.Append(CCFLAGS = ' -Qunused-arguments')
env = conf.Finish()
......@@ -438,6 +449,9 @@ if not conf.CheckLib('m'):
print 'Error: math library not found or not usable'
Exit(1)
# potential check dependency, link if present
conf.CheckLib('subunit')
if sysname != 'darwin':
if not conf.CheckLib('rt'):
print 'Error: realtime library not found or not usable'
......
......@@ -75,7 +75,6 @@ public:
case context_base::sslv2_server:
impl = ::SSL_CTX_new(::SSLv2_server_method());
break;
*/
case context_base::sslv3:
impl = ::SSL_CTX_new(::SSLv3_method());
break;
......@@ -85,6 +84,7 @@ public:
case context_base::sslv3_server:
impl = ::SSL_CTX_new(::SSLv3_server_method());
break;
*/
case context_base::tlsv1:
impl = ::SSL_CTX_new(::TLSv1_method());
break;
......
......@@ -34,7 +34,6 @@
#ifndef BASE_MEMORY_ALIGNED_MEMORY_H_
#define BASE_MEMORY_ALIGNED_MEMORY_H_
//#include "base/basictypes.h"
#include "compile_assert.h"
#include "compiler_specific.h"
......
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file adds defines about the platform we're currently building on.
// Operating System:
// OS_WIN / OS_MACOSX / OS_LINUX / OS_POSIX (MACOSX or LINUX)
......@@ -10,72 +9,13 @@
// Processor:
// ARCH_CPU_X86 / ARCH_CPU_X86_64 / ARCH_CPU_X86_FAMILY (X86 or X86_64)
// ARCH_CPU_32_BITS / ARCH_CPU_64_BITS
#ifndef BUILD_BUILD_CONFIG_H_
#define BUILD_BUILD_CONFIG_H_
#if defined(__APPLE__)
#include <TargetConditionals.h>
#endif
// A set of macros to use for platform detection.
#if defined(ANDROID)
#define OS_ANDROID 1
#elif defined(__APPLE__)
#define OS_MACOSX 1
#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
#define OS_IOS 1
#endif // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
#elif defined(__native_client__)
#if defined(__native_client__)
#define OS_NACL 1
#elif defined(__linux__)
#define OS_LINUX 1
// Use TOOLKIT_GTK on linux if TOOLKIT_VIEWS isn't defined.
#if !defined(TOOLKIT_VIEWS) && defined(USE_X11)
#define TOOLKIT_GTK
#endif
#elif defined(_WIN32)
#define OS_WIN 1
#define TOOLKIT_VIEWS 1
#elif defined(__FreeBSD__)
#define OS_FREEBSD 1
#define TOOLKIT_GTK
#elif defined(__OpenBSD__)
#define OS_OPENBSD 1
#define TOOLKIT_GTK
#elif defined(__sun)
#define OS_SOLARIS 1
#define TOOLKIT_GTK
#else
#error Please add support for your platform in build/build_config.h
#endif
#if defined(USE_OPENSSL) && defined(USE_NSS)
#error Cannot use both OpenSSL and NSS
#endif
// For access to standard BSD features, use OS_BSD instead of a
// more specific macro.
#if defined(OS_FREEBSD) || defined(OS_OPENBSD)
#define OS_BSD 1
#endif
// For access to standard POSIXish features, use OS_POSIX instead of a
// more specific macro.
#if defined(OS_MACOSX) || defined(OS_LINUX) || defined(OS_FREEBSD) || \
defined(OS_OPENBSD) || defined(OS_SOLARIS) || defined(OS_ANDROID) || \
defined(OS_NACL)
#define OS_POSIX 1
#endif
#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) && \
!defined(OS_NACL) && !defined(USE_MESSAGEPUMP_LINUX)
#define USE_X11 1 // Use X for graphics.
#endif
// Use tcmalloc
#if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(NO_TCMALLOC)
#define USE_TCMALLOC 1
#elif defined(__ANDROID__)
#define OS_ANDROID 1
#endif
// Compiler detection.
......@@ -91,83 +31,8 @@
// http://msdn.microsoft.com/en-us/library/b0084kay.aspx
// http://www.agner.org/optimize/calling_conventions.pdf
// or with gcc, run: "echo | gcc -E -dM -"
#if defined(_M_X64) || defined(__x86_64__)
#if defined(_M_X64) || defined(__x86_64__) || defined(_M_IX86) || defined(__i386__)
#define ARCH_CPU_X86_FAMILY 1
#define ARCH_CPU_X86_64 1
#define ARCH_CPU_64_BITS 1
#define ARCH_CPU_LITTLE_ENDIAN 1
#elif defined(_M_IX86) || defined(__i386__)
#define ARCH_CPU_X86_FAMILY 1
#define ARCH_CPU_X86 1
#define ARCH_CPU_32_BITS 1
#define ARCH_CPU_LITTLE_ENDIAN 1
#elif defined(__ARMEL__)
#define ARCH_CPU_ARM_FAMILY 1
#define ARCH_CPU_ARMEL 1
#define ARCH_CPU_32_BITS 1
#define ARCH_CPU_LITTLE_ENDIAN 1
#elif defined(__aarch64__)
#define ARCH_CPU_ARM_FAMILY 1
#define ARCH_CPU_ARMEL 1
#define ARCH_CPU_64_BITS 1
#define ARCH_CPU_LITTLE_ENDIAN 1
#elif defined(__pnacl__)
#define ARCH_CPU_32_BITS 1
#elif defined(__MIPSEL__)
#define ARCH_CPU_MIPS_FAMILY 1
#define ARCH_CPU_MIPSEL 1
#define ARCH_CPU_32_BITS 1
#define ARCH_CPU_LITTLE_ENDIAN 1
#elif defined(__PPC__)
#if defined(__PPC64__)
#define ARCH_CPU_64_BITS 1
#else
#define ARCH_CPU_32_BITS 1
#endif
#define ARCH_CPU_BIG_ENDIAN 1
#elif defined(__s390__)
#if defined(__s390x__)
#define ARCH_CPU_64_BITS 1
#else
#define ARCH_CPU_32_BITS 1
#endif
#define ARCH_CPU_BIG_ENDIAN 1
#else
#error Please add support for your architecture in build/build_config.h
#endif
// Type detection for wchar_t.
#if defined(OS_WIN)
#define WCHAR_T_IS_UTF16
#elif defined(OS_POSIX) && defined(COMPILER_GCC) && \
defined(__WCHAR_MAX__) && \
(__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff)
#define WCHAR_T_IS_UTF32
#elif defined(OS_POSIX) && defined(COMPILER_GCC) && \
defined(__WCHAR_MAX__) && \
(__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff)
// On Posix, we'll detect short wchar_t, but projects aren't guaranteed to
// compile in this mode (in particular, Chrome doesn't). This is intended for
// other projects using base who manage their own dependencies and make sure
// short wchar works for them.
#define WCHAR_T_IS_UTF16
#else
#error Please add support for your compiler in build/build_config.h
#endif
#if defined(__ARMEL__) && !defined(OS_IOS)
#define WCHAR_T_IS_UNSIGNED 1
#elif defined(__MIPSEL__)
#define WCHAR_T_IS_UNSIGNED 0
#endif
#if defined(OS_ANDROID)
// The compiler thinks std::string::const_iterator and "const char*" are
// equivalent types.
#define STD_STRING_ITERATOR_IS_CHAR_POINTER
// The compiler thinks base::string16::const_iterator and "char16*" are
// equivalent types.
#define BASE_STRING16_ITERATOR_IS_CHAR16_POINTER
#endif
#endif // BUILD_BUILD_CONFIG_H_
......@@ -653,7 +653,7 @@ cert_fail:
// Clean up cert_index_ from entries which were added by this trx
CertIndexNG::iterator ci(cert_index_ng_.find(&ke));
if (ci != cert_index_ng_.end())
if (gu_likely(ci != cert_index_ng_.end()))
{
KeyEntryNG* kep(*ci);
......@@ -670,13 +670,14 @@ cert_fail:
delete kep;
}
else
else if(ke.key().shared())
{
assert(0); // we actually should never be here, the key should
// be either added to cert_index_ or be there already
log_warn << "could not find key '"
log_warn << "could not find shared key '"
<< ke.key() << "' from cert index";
}
else { /* exclusive can duplicate shared */ }
}
assert(cert_index_.size() == prev_cert_index_size);
}
......
......@@ -33,7 +33,7 @@ static size_t version_to_hash_size (KeySet::Version const ver)
case KeySet::FLAT16A: return 16;
case KeySet::FLAT8: fail ("FLAT8 is not supported by test");
case KeySet::FLAT8A: return 8;
default: fail ("Unsupported KeySet verison: %d", ver);
default: fail ("Unsupported KeySet verison: %d", ver);
}
abort();
......
......@@ -20,7 +20,7 @@ using namespace galera;
static void*
thread_routine (void* arg)
{
SavedState* st(reinterpret_cast<SavedState*>(arg));
SavedState* st(static_cast<SavedState*>(arg));
do
{
......
......@@ -3,7 +3,7 @@
#include "gu_backtrace.h"
#include "gu_log.h"
#ifdef __GNUC__
#if defined(HAVE_EXECINFO_H) && defined(__GNUC__)
#include <execinfo.h>
#include <stdlib.h>
......
......@@ -55,8 +55,9 @@ static inline size_t gu_avphys_bytes()
#define GU_ULONG_MAX ULONG_MAX
#define GU_LONG_MAX LONG_MAX
#define GU_LONG_MIN LONG_MIN
#define GU_ULONG_LONG_MAX ULLONG_MAX
#define GU_LONG_LONG_MAX LLONG_MAX
#define GU_LONG_LONG_MIN LLONG_MIN
#define GU_ULONG_LONG_MAX 0xffffffffffffffffULL
#define GU_LONG_LONG_MAX 0x7fffffffffffffffLL
#define GU_LONG_LONG_MIN (-GU_LONG_LONG_MAX - 1)
#endif /* _gu_limits_h_ */
/*
* Copyright (C) 2009-2013 Codership Oy <info@codership.com>
* Copyright (C) 2009-2015 Codership Oy <info@codership.com>
*
* $Id$
*/
......@@ -12,6 +12,10 @@
#include <cerrno>
#include <sys/mman.h>
#ifndef MAP_NORESERVE
#define MAP_NORESERVE 0
#endif
// to avoid -Wold-style-cast
extern "C" { static const void* const GU_MAP_FAILED = MAP_FAILED; }
......@@ -30,8 +34,7 @@ namespace gu
<< "' failed";
}
#if !defined(__sun__) && !defined(__APPLE__) && !defined(__FreeBSD__)
/* Solaris, Darwin, and FreeBSD do not have MADV_DONTFORK */
#if defined(MADV_DONTFORK)
if (posix_madvise (ptr, size, MADV_DONTFORK))
{
int const err(errno);
......
// Copyright (C) 2013 Codership Oy <info@codership.com>
// Copyright (C) 2013-2015 Codership Oy <info@codership.com>
/**
* @file routines to generate "random" seeds for RNGs by collecting some easy
......@@ -16,13 +16,14 @@
/*! Structure to hold entropy data.
* Should be at least 20 bytes on 32-bit systems and 28 bytes on 64-bit */
/* Packed to avoid uninitialized data warnings when passed to hash */
struct gu_rse
{
long long time;
const void* heap_ptr;
const void* stack_ptr;
long pid;
};
}__attribute__((packed));
typedef struct gu_rse gu_rse_t;
......
......@@ -20,7 +20,7 @@ extern "C" {
static inline double
gu_timeval_diff (struct timeval* left, struct timeval* right)
{
register long long diff = left->tv_sec;
long long diff = left->tv_sec;
diff = ((diff - right->tv_sec)*1000000LL) + left->tv_usec - right->tv_usec;
return (((double)diff) * 1.0e-06);
}
......
......@@ -20,7 +20,7 @@ namespace gcache
/* although size value passed to GCache should be representable by
* a signed integer type, internally the buffer allocated will also
* incur header overhead, so it has to be represented by unsigned int.
* However the difference between to internal sizes should never exceed
* However the difference between two internal sizes should never exceed
* signed representation. */
typedef int ssize_type; // size passed to GCache
typedef unsigned int size_type; // internal size representation
......
......@@ -42,8 +42,7 @@ namespace gcache
size_t used () const { return used_; }
size_t size () const /* total page size */
{ return mmap_.size - sizeof(BufferHeader); }
size_t size() const { return fd_.size(); } /* size on storage */
const std::string& name() const { return fd_.name(); }
......
......@@ -134,7 +134,7 @@ gcache::PageStore::new_page (size_type size)
Page* const page(new Page(this, make_page_name (base_name_, count_), size));
pages_.push_back (page);
total_size_ += size;
total_size_ += page->size();
current_ = page;
count_++;
}
......
......@@ -46,12 +46,15 @@ namespace gcache
void reset();
size_t count() const { return count_; } // for unit tests
void set_page_size (size_t size) { page_size_ = size; }
void set_keep_size (size_t size) { keep_size_ = size; }
/* for unit tests */
size_t count() const { return count_; }
size_t total_pages() const { return pages_.size(); }
size_t total_size() const { return total_size_; }
private:
std::string const base_name_; /* /.../.../gcache.page. */
......
......@@ -146,9 +146,9 @@ namespace gcache
assert (ret <= first_);
if (first_ >= ret + size_next) { assert(size_free_ >= size); }
if (size_t(first_ - ret) >= size_next) { assert(size_free_ >= size); }
while (first_ < ret + size_next) {
while (size_t(first_ - ret) < size_next) {
// try to discard first buffer to get more space
BufferHeader* bh = BH_cast(first_);
......@@ -178,7 +178,7 @@ namespace gcache
first_ = start_;
assert_size_free();
if (end_ >= ret + size_next)
if (size_t(end_ - ret) >= size_next)
{
assert(size_free_ >= size);
size_trail_ = 0;
......@@ -194,8 +194,10 @@ namespace gcache
assert(ret <= first_);
}
assert (ret <= first_);
#ifndef NDEBUG
if (first_ < ret + size_next) {
if (size_t(first_ - ret) < size_next) {
log_fatal << "Assertion ((first - ret) >= size_next) failed: "
<< std::endl
<< "first offt = " << (first_ - start_) << std::endl
......
/*
* Copyright (C) 2010-2014 Codership Oy <info@codership.com>
* Copyright (C) 2010-2015 Codership Oy <info@codership.com>
*
* $Id$
*/
......@@ -26,23 +26,35 @@ START_TEST(test1)
gcache::PageStore ps (dir_name, keep_size, page_size, false);
mark_point();
fail_if(ps.count() != 0,"expected count 0, got %zu",ps.count());
fail_if(ps.total_pages() != 0,"expected 0 pages, got %zu",ps.total_pages());
fail_if(ps.total_size() != 0,"expected size 0, got %zu", ps.total_size());
void* buf = ps.malloc (3 + bh_size);
fail_if (0 == buf);
fail_if(ps.count() != 1,"expected count 1, got %zu",ps.count());
fail_if(ps.total_pages() != 1,"expected 1 pages, got %zu",ps.total_pages());
void* tmp = ps.realloc (buf, 2 + bh_size);
fail_if (buf != tmp);
fail_if(ps.count() != 1,"expected count 1, got %zu",ps.count());
fail_if(ps.total_pages() != 1,"expected 1 pages, got %zu",ps.total_pages());
tmp = ps.realloc (buf, 4 + bh_size); // here new page should be allocated
fail_if (0 == tmp);
fail_if (buf == tmp);
fail_if(ps.count() != 2,"expected count 2, got %zu",ps.count());
fail_if(ps.total_pages() != 1,"expected 1 pages, got %zu",ps.total_pages());
ps_free(tmp);
ps.discard (ptr2BH(tmp));
fail_if(ps.count() != 2,"expected count 2, got %zu",ps.count());
fail_if(ps.total_pages() != 0,"expected 0 pages, got %zu",ps.total_pages());
fail_if(ps.total_size() != 0,"expected size 0, got %zu", ps.total_size());
}
END_TEST
......
......@@ -119,9 +119,7 @@ gcomm::evs::InputMap::InputMap() :
aru_seq_ (-1),
node_index_ (new InputMapNodeIndex()),
msg_index_ (new InputMapMsgIndex()),
recovery_index_ (new InputMapMsgIndex()),
n_msgs_ (O_SAFE + 1),
max_droppable_ (16)
recovery_index_ (new InputMapMsgIndex())
{ }
......@@ -145,8 +143,7 @@ gcomm::evs::InputMap::~InputMap()
void gcomm::evs::InputMap::reset(const size_t nodes, const seqno_t window)
{
gcomm_assert(msg_index_->empty() == true &&
recovery_index_->empty() == true &&
accumulate(n_msgs_.begin(), n_msgs_.end(), 0) == 0);
recovery_index_->empty() == true);
node_index_->clear();
window_ = window;
......@@ -231,7 +228,6 @@ void gcomm::evs::InputMap::clear()
node_index_->clear();
aru_seq_ = -1;
safe_seq_ = -1;
fill(n_msgs_.begin(), n_msgs_.end(), 0);
}
......@@ -305,7 +301,6 @@ gcomm::evs::InputMap::insert(const size_t uuid,
msg.aru_seq(),
0,
O_DROP)), ins_dg))));
++n_msgs_[msg.order()];
}
// Update highest seen
......@@ -340,8 +335,6 @@ gcomm::evs::InputMap::insert(const size_t uuid,
void gcomm::evs::InputMap::erase(iterator i)
{
const UserMessage& msg(InputMapMsgIndex::value(i).msg());
--n_msgs_[msg.order()];
gu_trace(recovery_index_->insert_unique(*i));
gu_trace(msg_index_->erase(i));
}
......
......@@ -269,26 +269,6 @@ public:
return (node.range().lu() > seq);
}
bool has_deliverables() const
{
if (msg_index_->empty() == false)
{
if (n_msgs_[O_FIFO] > 0 && is_fifo(msg_index_->begin()))
return true;
else if (n_msgs_[O_AGREED] > 0 && is_agreed(msg_index_->begin()))
return true;
else if (n_msgs_[O_SAFE] > 0 && is_safe(msg_index_->begin()))
return true;
else if (n_msgs_[O_DROP] > max_droppable_)
return true;
return false;
}
else
{
return false;
}
}
/*!
* Insert new message into input map.
*
......@@ -373,9 +353,6 @@ private:
InputMapNodeIndex* node_index_; /*!< Index of nodes */
InputMapMsgIndex* msg_index_; /*!< Index of messages */
InputMapMsgIndex* recovery_index_; /*!< Recovery index */
std::vector<size_t> n_msgs_;
size_t max_droppable_;
};
#endif // EVS_INPUT_MAP2_HPP
......@@ -1566,11 +1566,12 @@ int gcomm::evs::Proto::send_user(Datagram& dg,
gu_trace(pop_header(msg, dg));
sent_msgs_[Message::T_USER]++;
if (delivering_ == false && input_map_->has_deliverables() == true)
if (delivering_ == false)
{
gu_trace(deliver());
gu_trace(deliver_local());
}
gu_trace(deliver_local());
return 0;
}
......@@ -2074,10 +2075,22 @@ void gcomm::evs::Proto::resend(const UUID& gap_source, const Range range)
seqno_t seq(range.lu());
while (seq <= range.hs())
{
InputMap::iterator msg_i = input_map_->find(NodeMap::value(self_i_).index(), seq);
InputMap::iterator msg_i = input_map_->find(
NodeMap::value(self_i_).index(), seq);
if (msg_i == input_map_->end())
{
gu_trace(msg_i = input_map_->recover(NodeMap::value(self_i_).index(), seq));
try
{
gu_trace(msg_i = input_map_->recover(
NodeMap::value(self_i_).index(), seq));
}
catch (...)
{
evs_log_debug(D_RETRANS) << "could not recover message "
<< gap_source << ":" << seq;
seq = seq + 1;
continue;
}
}
const UserMessage& msg(InputMapMsgIndex::value(msg_i).msg());
......@@ -2537,6 +2550,31 @@ int gcomm::evs::Proto::handle_down(Datagram& wb, const ProtoDownMeta& dm)
causal_keepalive_period_ > gu::datetime::Period(0) &&
last_causal_keepalive_ + causal_keepalive_period_ > now)
{
assert(last_sent_ == input_map_->aru_seq());
// Input map should either be empty (all messages
// delivered) or the undelivered messages have higher
// seqno than safe_seq. Even if the delivry is
// done below if needed, this assertion should stay
// to catch errors in logic elsewhere in the code.
assert(input_map_->begin() == input_map_->end() ||
input_map_->is_safe(input_map_->begin()) == false);