Skip to content

Commit

Permalink
Merge branch 'release/v1.1.14'
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikolay Suboch committed Nov 23, 2021
2 parents 6314120 + 7c69580 commit c9f3cbb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.1.14 (2021-11-23)

### Bug Fixes

* connection_pool: Fix wrong error message "Too many open descriptors"

## 1.1.13 (2021-11-17)

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0 FATAL_ERROR)

set(STREAMCLIENT_VERSION_MAJOR "1")
set(STREAMCLIENT_VERSION_MINOR "1")
set(STREAMCLIENT_VERSION_RELEASE "13")
set(STREAMCLIENT_VERSION_RELEASE "14")
set(STREAMCLIENT_SUMMARY "C++ library")
set(STREAMCLIENT_REPOSITORY_URL "https://github.com/TinkoffCreditSystems/stream-client")
set(STREAMCLIENT_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
Expand Down
4 changes: 2 additions & 2 deletions include/stream-client/connector/impl/connection_pool.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ base_connection_pool<Connector>::get_session(boost::system::error_code& ec, cons
}
if (sesson_pool_.empty() && !pool_cv_.wait_until(pool_lk, deadline, [this] { return !sesson_pool_.empty(); })) {
// session pool is still empty
ec = boost::asio::error::no_descriptors;
ec = boost::asio::error::not_found;
return nullptr;
}

Expand All @@ -64,7 +64,7 @@ base_connection_pool<Connector>::try_get_session(boost::system::error_code& ec,
}
if (sesson_pool_.empty()) {
// session pool is empty
ec = boost::asio::error::no_descriptors;
ec = boost::asio::error::not_found;
return nullptr;
}

Expand Down
19 changes: 14 additions & 5 deletions tests/pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ TYPED_TEST(PoolServerEnv, PoolConnect)
{
using server_session_type = typename TestFixture::session_type;
using client_pool_type = typename TestFixture::client_pool_type;
using protocol_type = typename TestFixture::protocol_type;
using client_type = typename TestFixture::client_type;

const size_t pool_size = 1;
const size_t pool_size = 10;
std::vector<std::future<server_session_type>> future_sessions;
for (size_t i = 0; i < pool_size; ++i) {
future_sessions.emplace_back(this->server.get_session());
Expand All @@ -30,18 +31,26 @@ TYPED_TEST(PoolServerEnv, PoolConnect)
EXPECT_TRUE(clients_pool->is_connected(error));
EXPECT_CODE(error, boost::system::errc::success);

// pool should have a pool_size of different opened sessions
// pool should have pool_size of different opened sessions
std::unordered_set<client_type*> clients;
for (size_t i = 0; i < pool_size; ++i) {
boost::system::error_code error;
for (size_t i = 0; i < pool_size * 5; ++i) {
auto client_handle = clients_pool->get_session(error);
ASSERT_CODE(error, boost::system::errc::success);
EXPECT_TRUE(client_handle->is_open());

clients.insert(client_handle.get());
clients_pool->return_session(std::move(client_handle));
}
EXPECT_EQ(clients.size(), pool_size);

if (typeid(protocol_type) == typeid(boost::asio::ip::udp)) {
// udp will have at least one session
EXPECT_GE(clients.size(), 1);
EXPECT_LE(clients.size(), pool_size);
} else {
// tcp may overshoot or undershoot with one session
EXPECT_GE(clients.size(), pool_size - 1);
EXPECT_LE(clients.size(), pool_size + 1);
}
}

int main(int argc, char** argv)
Expand Down

0 comments on commit c9f3cbb

Please sign in to comment.