Skip to content

Send leave message to Tuntox proxy, and ensure session is stopped

Arte Ebrahimi requested to merge artenator/crdt.el:master into master

@jming422 and I encountered a bug that was causing CRDT clients' emacs to get in a bad state.

We found that the way to reproduce this bug was:

  • Create a tuntox-based session
  • Have a client connect
  • Session host terminates the session

After this, the client would no longer be able to invoke any functions that relied on the buffer list, such as switch-to-buffer.

Debugger entered--Lisp error: (wrong-type-argument processp nil)
  process-contact(nil :server)
  crdt--get-buffer-process-advice(#<subr get-buffer-process> #<buffer *CRDT Buffers nil*<2>>)
  apply(crdt--get-buffer-process-advice #<subr get-buffer-process> #<buffer *CRDT Buffers nil*<2>>)
  get-buffer-process(#<buffer *CRDT Buffers nil*<2>>)

After some investigation, we found that it was caused because crdt--client-process-sentinel was encountering an error when sending a string to process. This was causing crdt--stop-session to not get executed

(when (process-get process 'tuntox-process)
  (process-send-string
   process
   (crdt--format-message `(leave ,(crdt--session-local-id session)))))
(crdt--stop-session session)

At this point, process's status is closed, and we thought that it's likely that the leave message was intended for the tuntox process rather than the CRDT client process. So we adjusted this so that the string gets sent to the tuntox process, and also wrapped it in with-demoted-errors so that even if the sending of the message fails, that crdt--stop-session will still get called to ensure the teardown process still occurs and prevents the buffers from getting into the bad state.

Merge request reports

Loading