Commit 858e4b4a authored by Peter Liljenberg's avatar Peter Liljenberg
Browse files

Keep track of keep-alive timers in a global cons list instead of in a buffer...

Keep track of keep-alive timers in a global cons list instead of in a buffer local variable to be able to shut down the timer if the buffer is killed.
parent ee45a027
......@@ -2369,17 +2369,17 @@ This command accepts text number prefix arguments \(see
(def-kom-var lyskom-keep-alive-timers nil
"List of all active keep alive timers"
"List of all active keep alive timers as (buffer . timer) conses.")
(defun lyskom-keep-alive-callback (buffer)
(condition-case nil
(save-current-buffer (set-buffer buffer)
(if (eq (process-status lyskom-proc) 'open)
(initiate-get-time 'keep nil)
(lyskom-stop-keep-alive buffer)
(message "Terminating keep-alive")))
(error (message "ERROR!") (lyskom-stop-keep-alive))))
(error (message "Callback error, terminating keep-alive")
(lyskom-stop-keep-alive buffer))))
(def-kom-command kom-keep-alive ()
"Keep the LysKOM session alive by sending a request every once in a
......@@ -2391,20 +2391,21 @@ too long.
Use `kom-stop-keep-alive' to turn off this mode."
(set-buffer lyskom-buffer)
(lyskom-stop-keep-alive lyskom-buffer)
(lyskom-keep-alive lyskom-buffer)
(unless (eq (current-buffer) lyskom-buffer)
(lyskom-message 'start-keep-alive kom-keep-alive-interval))
(lyskom-format-insert 'start-keep-alive kom-keep-alive-interval)
(lyskom-insert "\n"))
(defun lyskom-keep-alive ()
(defun lyskom-keep-alive (buffer)
(setq lyskom-keep-alive-timers
(add-timeout kom-keep-alive-interval
(cons buffer
(add-timeout kom-keep-alive-interval
(def-kom-command kom-stop-keep-alive ()
......@@ -2412,16 +2413,22 @@ Use `kom-stop-keep-alive' to turn off this mode."
See `kom-keep-alive' for more information."
(lyskom-stop-keep-alive lyskom-buffer)
(unless (eq (current-buffer) lyskom-buffer)
(lyskom-message "%#1s" 'stop-keep-alive))
(lyskom-insert 'stop-keep-alive)
(lyskom-insert "\n"))
(defun lyskom-stop-keep-alive ()
(mapc 'disable-timeout lyskom-keep-alive-timers)
(setq lyskom-keep-alive-timers nil))
(defun lyskom-stop-keep-alive (buffer)
((c (assq buffer lyskom-keep-alive-timers)))
(if c
(disable-timeout (cdr c))
(setq lyskom-keep-alive-timers
(delq c lyskom-keep-alive-timers)))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment