From: Ricardo Dias Date: Thu, 21 Feb 2019 16:01:22 +0000 (+0000) Subject: msg/async: guard protocol Interceptor with preprocessor variable X-Git-Tag: v14.1.0~14^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1920d3a8b2a043033c91e722ee96d6c78bc3eb4d;p=ceph.git msg/async: guard protocol Interceptor with preprocessor variable Signed-off-by: Ricardo Dias --- diff --git a/src/msg/Connection.h b/src/msg/Connection.h index 7c8d6dc15fa..20148749c8c 100644 --- a/src/msg/Connection.h +++ b/src/msg/Connection.h @@ -37,7 +37,10 @@ // abstract Connection, for keeping per-connection state class Messenger; + +#ifdef UNIT_TESTS_BUILT class Interceptor; +#endif struct Connection : public RefCountedObject { mutable Mutex lock; @@ -62,7 +65,9 @@ public: EntityName peer_name; uint64_t peer_global_id = 0; +#ifdef UNIT_TESTS_BUILT Interceptor *interceptor; +#endif friend class boost::intrusive_ptr; friend class PipeConnection; diff --git a/src/msg/Messenger.h b/src/msg/Messenger.h index 432efb5fd73..2602765cf44 100644 --- a/src/msg/Messenger.h +++ b/src/msg/Messenger.h @@ -49,6 +49,8 @@ class Timer; class AuthClient; class AuthServer; +#ifdef UNIT_TESTS_BUILT + struct Interceptor { std::mutex lock; std::condition_variable cond_var; @@ -63,6 +65,8 @@ struct Interceptor { virtual ACTION intercept(Connection *conn, uint32_t step) = 0; }; +#endif + class Messenger { private: std::deque dispatchers; @@ -89,7 +93,10 @@ protected: public: AuthClient *auth_client = 0; AuthServer *auth_server = 0; + +#ifdef UNIT_TESTS_BUILT Interceptor *interceptor = nullptr; +#endif /** * Various Messenger conditional config/type flags to allow diff --git a/src/msg/async/AsyncConnection.cc b/src/msg/async/AsyncConnection.cc index 6e4991b4058..18a9c00c4d1 100644 --- a/src/msg/async/AsyncConnection.cc +++ b/src/msg/async/AsyncConnection.cc @@ -123,7 +123,9 @@ AsyncConnection::AsyncConnection(CephContext *cct, AsyncMessenger *m, DispatchQu msgr2(m2), state_offset(0), worker(w), center(&w->center),read_buffer(nullptr) { +#ifdef UNIT_TESTS_BUILT this->interceptor = m->interceptor; +#endif read_handler = new C_handle_read(this); write_handler = new C_handle_write(this); write_callback_handler = new C_handle_write_callback(this); diff --git a/src/msg/async/ProtocolV2.cc b/src/msg/async/ProtocolV2.cc index c523e3635ae..062d53bf910 100644 --- a/src/msg/async/ProtocolV2.cc +++ b/src/msg/async/ProtocolV2.cc @@ -96,6 +96,8 @@ const int SIGNATURE_BLOCK_SIZE = CEPH_CRYPTO_HMACSHA256_DIGESTSIZE; #define READB(L, B, C) read(CONTINUATION(C), L, B) +#ifdef UNIT_TESTS_BUILT + #define INTERCEPT(S) { \ if(connection->interceptor) { \ auto a = connection->interceptor->intercept(connection, (S)); \ @@ -106,6 +108,10 @@ if(connection->interceptor) { \ connection->dispatch_queue->queue_reset(connection); \ return nullptr; \ }}} + +#else +#define INTERCEPT(S) +#endif static void alloc_aligned_buffer(bufferlist &data, unsigned len, unsigned off) { // create a buffer to read into that matches the data alignment