1
0
mirror of https://github.com/codership/wsrep-lib.git synced 2025-07-28 20:02:00 +03:00

* Unit test for BF abort after after_command_before_result()

* Revised logic for handling BF abort around after command operations
* Added lighweight thread class for runtime thread id checking
This commit is contained in:
Teemu Ollakka
2018-06-11 11:48:07 +03:00
parent e18c9d597f
commit 58ea925dc3
11 changed files with 165 additions and 100 deletions

View File

@ -44,6 +44,7 @@
#include "mutex.hpp"
#include "lock.hpp"
#include "data.hpp"
#include "thread.hpp"
namespace wsrep
{
@ -359,7 +360,8 @@ namespace wsrep
wsrep::server_context& server_context,
const client_id& id,
enum mode mode)
: mutex_(mutex)
: thread_id_(wsrep::this_thread::get_id())
, mutex_(mutex)
, server_context_(server_context)
, id_(id)
, mode_(mode)
@ -473,10 +475,15 @@ namespace wsrep
*/
virtual void abort() const = 0;
public:
/*!
* Set up thread global variables for client connection.
*/
virtual void store_globals() = 0;
virtual void store_globals()
{
thread_id_ = wsrep::this_thread::get_id();
}
private:
/*!
* Enter debug synchronization point.
@ -495,16 +502,9 @@ namespace wsrep
/*!
*
*/
void override_error(enum wsrep::client_error error)
{
if (current_error_ != wsrep::e_success &&
error == wsrep::e_success)
{
throw wsrep::runtime_error("Overriding error with success");
}
current_error_ = error;
}
void override_error(enum wsrep::client_error error);
wsrep::thread::id thread_id_;
wsrep::mutex& mutex_;
wsrep::server_context& server_context_;
client_id id_;

36
include/wsrep/thread.hpp Normal file
View File

@ -0,0 +1,36 @@
//
// Copyright (C) 2018 Codership Oy <info@codership.com>
//
#include <pthread.h>
namespace wsrep
{
class thread
{
public:
class id
{
public:
id() : thread_() { }
explicit id(pthread_t thread) : thread_(thread) { }
private:
friend bool operator==(thread::id left, thread::id right)
{
return (pthread_equal(left.thread_, right.thread_));
}
pthread_t thread_;
};
thread()
: id_(pthread_self())
{ }
private:
id id_;
};
namespace this_thread
{
static inline thread::id get_id() { return thread::id(pthread_self()); }
}
};