Skip to content

Distant chat: closing a conversation left its contact behind, and always reported success - #378

Open
jolavillette wants to merge 1 commit into
RetroShare:masterfrom
jolavillette:fix/distant-chat-close-keeps-contact
Open

Distant chat: closing a conversation left its contact behind, and always reported success#378
jolavillette wants to merge 1 commit into
RetroShare:masterfrom
jolavillette:fix/distant-chat-close-keeps-contact

Conversation

@jolavillette

Copy link
Copy Markdown
Contributor

DistantChatService::closeDistantChatConnexion() closes the GXS tunnel and
stops there, on a comment wondering whether the contact should go with it:

mGxsTunnels->closeExistingTunnel(RsGxsTunnelId(tunnel_id), DISTANT_CHAT_GXS_TUNNEL_SERVICE_ID) ;

// also remove contact. Or do we wait for the notification?

return true ;

It should. handleRecvDataItem() drops an incoming item only for tunnels it
finds no contact for, so the entry left in mDistantChatContacts keeps
accepting data for a conversation the user has just left: a peer who carries on
writing re-digs the tunnel and the chat comes back.
markDistantChatAsClosed(), which runs when the remote end closes, has always
removed it — closing it ourselves now means the same thing, and that function
becomes the same call.

The return value was the constant true, so every caller — the chat window, the
web UI, any JSON API client — was told the conversation had been closed even
when there was nothing to close. That is not a rare case:
closeExistingTunnel() answers false and logs

(EE) Cannot close distant tunnel connection. No connection openned for tunnel id 7dfee99a...

whenever the tunnel died on its own first, which is the normal state of a
conversation left open for a while. It now answers whether anything was actually
released, so a client can tell the user which of the two happened instead of
claiming a close that never took place.

Found from the web UI, where "Leave Chat" reported a closed tunnel and the
conversation kept coming back. Built and run on Linux/Qt5.

🤖 Generated with Claude Code

…ays said it worked

closeDistantChatConnexion() closes the GXS tunnel and stops there, on a comment
wondering whether the contact should go too ("also remove contact. Or do we wait
for the notification?"). It should: handleRecvDataItem() drops incoming items
only for tunnels it finds no contact for, so the entry left in
mDistantChatContacts keeps accepting data for a conversation the user has just
left. A peer that keeps writing re-digs the tunnel and the chat comes back.
markDistantChatAsClosed(), which runs when the *remote* end closes, has always
removed it; closing it ourselves now means the same thing, and that function
becomes the same call.

The return value was the constant true, so every caller -- the chat window, the
web UI, any JSON API client -- was told the conversation had been closed even
when there was nothing to close: closeExistingTunnel() answers false and logs
"Cannot close distant tunnel connection. No connection openned for tunnel id"
when the tunnel had already died on its own, which is the normal state of a
conversation left open for a while. It now answers whether anything was actually
released, so a client can tell the user which of the two happened.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant