From 6ba338c8af5d9ca0d3bc5b359e34b9177717e80d Mon Sep 17 00:00:00 2001 From: Krzysztof Jackiewicz Date: Tue, 16 Sep 2014 09:57:45 +0200 Subject: [PATCH] Move SockRAII declaration to header file Change-Id: I968d19db72eaa8677e212a88b5bbb5886163d307 --- src/manager/client/client-common.cpp | 26 ++------------------------ src/manager/client/client-common.h | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/src/manager/client/client-common.cpp b/src/manager/client/client-common.cpp index aeb79cd..a7a183f 100644 --- a/src/manager/client/client-common.cpp +++ b/src/manager/client/client-common.cpp @@ -37,6 +37,8 @@ #include +#include + IMPLEMENT_SAFE_SINGLETON(CKM::Log::LogSystem); namespace { @@ -149,30 +151,6 @@ int connectSocket(int& sock, char const * const interface) { return CKM_API_SUCCESS; } -class SockRAII { -public: - SockRAII() - : m_sock(-1) - {} - - virtual ~SockRAII() { - if (m_sock > -1) - close(m_sock); - } - - int Connect(char const * const interface) { - return CKM::connectSocket(m_sock, interface); - } - - int Get() const { - return m_sock; - } - -private: - int m_sock; -}; - - int sendToServer(char const * const interface, const RawBuffer &send, MessageBuffer &recv) { int ret; SockRAII sock; diff --git a/src/manager/client/client-common.h b/src/manager/client/client-common.h index 8616528..ae25a62 100644 --- a/src/manager/client/client-common.h +++ b/src/manager/client/client-common.h @@ -29,6 +29,7 @@ #include #include +#include #include #define KEY_MANAGER_API __attribute__((visibility("default"))) @@ -43,6 +44,32 @@ int connectSocket(int& sock, char const * const interface); int sendToServer(char const * const interface, const RawBuffer &send, MessageBuffer &recv); + +class SockRAII { +public: + SockRAII() + : m_sock(-1) + {} + + NONCOPYABLE(SockRAII); + + virtual ~SockRAII() { + if (m_sock > -1) + close(m_sock); + } + + int Connect(char const * const interface) { + return CKM::connectSocket(m_sock, interface); + } + + int Get() const { + return m_sock; + } + +private: + int m_sock; +}; + /* * Decorator function that performs frequently repeated exception handling in * SS client API functions. Accepts lambda expression as an argument. -- 2.7.4