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 | 545 | std::cout << "GVOHub::request_register" << std::endl; |
| 546 | 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 | 565 | // Create a new client |
| 549 | 566 | struct client voclient; |
| 550 | - voclient.reference = "c"+gammalib::str(m_clients.size()); | |
| 567 | + voclient.reference = reference; | |
| 551 | 568 | voclient.private_key = random_string(15); |
| 552 | 569 | |
| 553 | 570 | // Attached client | ... | ... |