client fix Channel reconnect

This commit is contained in:
Michael Davidsaver
2020-03-02 09:11:44 -08:00
parent c404c5f425
commit a3ffbd2a9b
3 changed files with 29 additions and 8 deletions
+11
View File
@@ -94,6 +94,17 @@ void Channel::createOperations()
}
}
void Channel::disconnect(const std::shared_ptr<Channel>& self)
{
self->state = Channel::Searching;
self->sid = 0xdeadbeef; // spoil
context->searchBuckets[context->currentBucket].push_back(self);
log_debug_printf(io, "Server %s detach channel '%s' to re-search\n",
conn ? conn->peerName.c_str() : "<disconnected>",
self->name.c_str());
}
OperationBase::OperationBase(operation_t op, const std::shared_ptr<Channel>& chan)
:Operation(op)
+14 -5
View File
@@ -128,12 +128,21 @@ void Connection::cleanup()
if(!chan)
continue;
chan->state = Channel::Searching;
chan->sid = 0xdeadbeef; // spoil
self = std::move(chan->conn);
context->searchBuckets[context->currentBucket].push_back(chan);
chan->disconnect(chan);
}
for(auto& pair : chanBySID) {
auto chan = pair.second.lock();
if(!chan)
continue;
log_debug_printf(io, "Server %s detach channel '%s' to re-search\n", peerName.c_str(), chan->name.c_str());
chan->disconnect(chan);
}
for(auto& pair : creatingByCID) {
auto chan = pair.second.lock();
if(!chan)
continue;
chan->disconnect(chan);
}
auto ops = std::move(opByIOID);
+4 -3
View File
@@ -53,11 +53,11 @@ struct Connection : public ConnBase, public std::enable_shared_from_this<Connect
bool ready = false;
// channels to be created on this Connection
// channels to be created on this Connection (in state==Connecting
std::list<std::weak_ptr<Channel>> pending;
std::map<uint32_t, std::weak_ptr<Channel>> creatingByCID,
chanBySID;
std::map<uint32_t, std::weak_ptr<Channel>> creatingByCID, // in state==Creating
chanBySID; // in state==Active
// entries always have matching entry in a Channel::opByIOID
std::map<uint32_t, RequestInfo> opByIOID;
@@ -130,6 +130,7 @@ struct Channel {
~Channel();
void createOperations();
void disconnect(const std::shared_ptr<Channel>& self);
static
std::shared_ptr<Channel> build(const std::shared_ptr<Context::Pvt>& context, const std::string &name);