Skip to content

Commit 2b3ffc6

Browse files
committed
Actually increment next client id just in case
1 parent 697d5d8 commit 2b3ffc6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/application/setups/server/server_setup.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ class webrtc_server_detail {
128128

129129
/* We need this since yojimbo can only identify clients by slot (port) */
130130
std::unordered_map<std::string, client_id> id_map;
131+
client_id next_client_id = 0;
131132

132133
auto set_this_server_id(const std::string& new_id) {
133134
std::scoped_lock lk(this_server_id_lk);
@@ -142,8 +143,11 @@ class webrtc_server_detail {
142143

143144
client_id assign_client_id() {
144145
for (client_id i = 0; i < max_clients; ++i) {
145-
if (pcs.find(i) == pcs.end()) {
146-
return i;
146+
const auto id = (next_client_id + i) % max_clients;
147+
148+
if (pcs.find(id) == pcs.end()) {
149+
next_client_id = (id + 1) % max_clients;
150+
return id;
147151
}
148152
}
149153

0 commit comments

Comments
 (0)