diff --git a/WORKSPACE b/WORKSPACE index 734ebd5..9b5f033 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -68,9 +68,9 @@ http_archive( http_archive( name = "toolbelt", - urls = ["https://github.com/dallison/cpp_toolbelt/archive/refs/tags/1.0.8.tar.gz"], - strip_prefix = "cpp_toolbelt-1.0.8", - sha256 = "286a7c76b107c69f289c5f91838fa9ac9d403966f13737b6d2a7161d62727aa3" + urls = ["https://github.com/dallison/cpp_toolbelt/archive/refs/tags/1.0.9.tar.gz"], + strip_prefix = "cpp_toolbelt-1.0.9", + sha256 = "e5ce4a2634e01819875614a842c37cc2c8aad25d60dad1ac116614cf092ff3bc" ) # For local debugging of toolbelt coroutine library. diff --git a/server/client_handler.cc b/server/client_handler.cc index 0ede02b..1a53c0f 100644 --- a/server/client_handler.cc +++ b/server/client_handler.cc @@ -149,7 +149,7 @@ void ClientHandler::HandleCreatePublisher( } // Check capacity of channel. - absl::Status cap_ok = channel->HasSufficientCapacity(); + absl::Status cap_ok = channel->HasSufficientCapacity(0); if (!cap_ok.ok()) { response->set_error(absl::StrFormat( "Insufficient capcacity to add a new publisher to channel %s: %s", @@ -270,7 +270,7 @@ void ClientHandler::HandleCreateSubscriber( } sub = static_cast(*user); } else { - absl::Status cap_ok = channel->HasSufficientCapacity(); + absl::Status cap_ok = channel->HasSufficientCapacity(req.max_shared_ptrs()); if (!cap_ok.ok()) { response->set_error(absl::StrFormat( "Insufficient capcacity to add a new subscriber to channel %s: %s", diff --git a/server/server_channel.cc b/server/server_channel.cc index c1b4931..56c6973 100644 --- a/server/server_channel.cc +++ b/server/server_channel.cc @@ -212,7 +212,7 @@ bool ServerChannel::IsBridgeSubscriber() const { return num_subs == num_bridge_subs; } -absl::Status ServerChannel::HasSufficientCapacity() const { +absl::Status ServerChannel::HasSufficientCapacity(int new_max_ptrs) const { if (NumSlots() == 0) { return absl::OkStatus(); } @@ -221,7 +221,7 @@ absl::Status ServerChannel::HasSufficientCapacity() const { CountUsers(num_pubs, num_subs); // Add in the total shared ptr maximums. - int max_shared_ptrs = 0; + int max_shared_ptrs = new_max_ptrs; for (auto &user : users_) { if (user == nullptr) { continue; diff --git a/server/server_channel.h b/server/server_channel.h index 295f125..c4fea59 100644 --- a/server/server_channel.h +++ b/server/server_channel.h @@ -154,7 +154,7 @@ class ServerChannel : public Channel { void RemoveUser(int user_id); void RemoveAllUsersFor(ClientHandler *handler); bool IsEmpty() const { return user_ids_.IsEmpty(); } - absl::Status HasSufficientCapacity() const; + absl::Status HasSufficientCapacity(int new_max_ptrs) const; void CountUsers(int &num_pubs, int &num_subs) const; void GetChannelInfo(subspace::ChannelInfo *info); void GetChannelStats(subspace::ChannelStats *stats);