Просмотр исходного кода

* fixed bug: check connection status before closing channel

master
bergmann 7 лет назад
Родитель
Сommit
eeafb28e4d
3 измененных файлов: 6 добавлений и 1 удалений
  1. +2
    -0
      include/cppamqp/connection.h
  2. +3
    -0
      include/cppamqp/connection.inl
  3. +1
    -1
      src/cppamqp/channel.cpp

+ 2
- 0
include/cppamqp/connection.h Просмотреть файл

@@ -34,6 +34,8 @@ namespace cppamqp
std::unique_ptr<internal> _internal; std::unique_ptr<internal> _internal;


public: public:
inline operator bool() const;

inline amqp_connection_state_t& handle (); inline amqp_connection_state_t& handle ();
inline const amqp_connection_state_t& handle () const; inline const amqp_connection_state_t& handle () const;




+ 3
- 0
include/cppamqp/connection.inl Просмотреть файл

@@ -35,6 +35,9 @@ namespace cppamqp
return value; return value;
} }


connection::operator bool() const
{ return static_cast<bool>(_internal); }

amqp_connection_state_t& connection::handle() amqp_connection_state_t& connection::handle()
{ {
if (!_internal) if (!_internal)


+ 1
- 1
src/cppamqp/channel.cpp Просмотреть файл

@@ -20,7 +20,7 @@ channel::internal::internal(const cppamqp::connection& p_connection, channel_num


channel::internal::~internal() channel::internal::~internal()
{ {
if (handle <= 0)
if (handle <= 0 || !static_cast<bool>(connection))
return; return;
__impl::check_and_raise( __impl::check_and_raise(
amqp_channel_close(connection.handle(), handle, AMQP_REPLY_SUCCESS), amqp_channel_close(connection.handle(), handle, AMQP_REPLY_SUCCESS),


Загрузка…
Отмена
Сохранить