fix: Fix shard reconnection issue causing segfault#1608
Conversation
✅ Deploy Preview for dpp-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
there are conflicts in this that have to be resolved. |
|
thanks so much for the pr by the way looking forward to merging it! |
|
I'll look into those conflicts in a bit! |
Glad I could help😁 |
|
Adjusted it for smart pointers, should be fine now |
|
Just caught that exception again and realised I forgot to move an old object back to shards list in case of said exception. It did the full recreation so technically it worked but now it should be able to resume, too. |
|
Actually now that I think about it more and looking at discordclient.cpp, the old shard can be sabotaged by new constructor since it's moving that |
this is already solved by another pr #1606 |
Oh, I missed it. Just checked and I think my changes should be fine as is if git merge won't mess logic up. |
|
Corrected the Title and Description to match guidelines |
|
I have added @Mishura4 and @Neko-Life to this review. |
Neko-Life
left a comment
There was a problem hiding this comment.
Required changes for the missing logic
| log(ll_trace, "Running new connection..."); | ||
| if (resume) { | ||
| /* Start connecting only after the old client is destroyed */ | ||
| shards[shard_id]->start_connecting(); |
There was a problem hiding this comment.
this resume path shouldn't be removed, resume constructor doesn't invoke start_connecting() anymore
There was a problem hiding this comment.
I don't remember removing any resume logic, probably git auto merge shenenigans. I haven't pulled last changes to my branch from the upstream yet so I guess this is the issue. I'm not at my PC right now and next at least two days are pretty busy. I ticked maintainers write access to reconnect-fix branch of my DPP fork, if there's anyone who wants to merge it faster than that, they can push straight to my branch. Otherwise I'll fix it in 2-3 days.
| } | ||
| log(ll_trace, "Installing new connection..."); | ||
| std::unique_lock lk(shards_mutex); | ||
| shards[shard_id] = std::move(cl_new); |
There was a problem hiding this comment.
i think moving the resume path after this line should be correct, including reconnection of the old client's connecting_voice_channels
Closes #1607
This should fix the old shard is not being there if something in network stack has failed during the reconnection stage. Additionally I removed what looks to be a pair of duplicate parameters with unnecessary
std::stringcopying in the reconnect for client constructor, sinceoldis being deleted long after newdiscord_clientbeing constructed, it shouldn't be a problem.Here's traces from my reconnect test:
It's not the actual DNS failure test because it's kinda hard to catch the thing in action, but at least I proved that reconnection mechanism is not broken, my bot still keeps replying to messages after the reconnection.
Code change checklist
Documentation change checklist
doxygen, and testing examples).