Commit fee0bdaa75ff77800284f24e12270f6c513260d6
1 parent
e4daceb6
Correctly handle reference attribution
Showing
1 changed file
with
18 additions
and
1 deletions
src/vo/GVOHub.cpp
| @@ -545,9 +545,26 @@ void GVOHub::request_register(const GXml& xml, const socklen_t& sock) | @@ -545,9 +545,26 @@ void GVOHub::request_register(const GXml& xml, const socklen_t& sock) | ||
| 545 | std::cout << "GVOHub::request_register" << std::endl; | 545 | std::cout << "GVOHub::request_register" << std::endl; |
| 546 | #endif | 546 | #endif |
| 547 | 547 | ||
| 548 | + // Set client reference | ||
| 549 | + int counter = 0; | ||
| 550 | + std::string reference; | ||
| 551 | + do { | ||
| 552 | + reference = "c"+gammalib::str(counter); | ||
| 553 | + int i = 0; | ||
| 554 | + for (; i < m_clients.size(); ++i) { | ||
| 555 | + if (m_clients[i].reference == reference) { | ||
| 556 | + counter++; | ||
| 557 | + break; | ||
| 558 | + } | ||
| 559 | + } | ||
| 560 | + if (i >= m_clients.size()) { | ||
| 561 | + break; | ||
| 562 | + } | ||
| 563 | + } while (true); | ||
| 564 | + | ||
| 548 | // Create a new client | 565 | // Create a new client |
| 549 | struct client voclient; | 566 | struct client voclient; |
| 550 | - voclient.reference = "c"+gammalib::str(m_clients.size()); | 567 | + voclient.reference = reference; |
| 551 | voclient.private_key = random_string(15); | 568 | voclient.private_key = random_string(15); |
| 552 | 569 | ||
| 553 | // Attached client | 570 | // Attached client |