Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
* Working arounf for deaf server [DEAF][NNTP][PATCH]
@ 2002-05-11 11:33 Ketanu
  0 siblings, 0 replies; only message in thread
From: Ketanu @ 2002-05-11 11:33 UTC (permalink / raw)


Yo, i experimented a probleme with deaf server, it means, servers that dont'pay
you any attention when you don't talk to them for a few minutes. They keep the
network connection alive but do not respond anymore.

I modified nntp.el in a convenient way and the nntp-connection is automagically
closed when needed, the server is expected to be consistent in the following 
way :

    A deaf server is a server which can be attached a duration d with the
    property : when no exchange took place on the connection for more than
    d, the connection is obsoleted (it is not closed but the server do not pay
    attention to you any more, hewill hence not respond you, making gnus and
    emacs hang up for a few minutes).

Here is a patch, check functions 

`nntp-deaf-cancel-timer'
`nntp-deaf-reset-timer'
`nntp-deaf-run-hook'

and variables

`nntp-deaf-timeout'
`nntp-deaf-hook'
`nntp-deaf-timer'

for getting some more information


i do not really now why it worked when i modified `nntp-wait-for'
if someone knows if it is really bad or if it is convenient, please
tell me.

i did not encounter any error with it, and now connections works great.

---- cut here ----
*** nntp.el	Sat May 11 12:40:28 2002
--- nntp-patched.el	Sat May 11 12:58:33 2002
***************
*** 159,164 ****
--- 159,208 ----
  (defvoo nntp-coding-system-for-write 'binary
    "*Coding system to write to NNTP.")
  
+ (defvar nntp-deaf-timeout 100
+   "*Deaf timeout is for servers becoming deaf 
+   
+ Some server, such as ft server news.wanadoo.fr seems to get deaf when not 
+ being talked after a certain amount of time, thus it is proposed to run a
+ hook a fixed amount after the last characters have been read from the 
+ server, this hook is `nntp-deaf-hook'
+ 
+ non-'nil value should be interpreted with the same
+ 	semantic as with the `run-at-time' fucntion
+ 'nil indicates the server never comes deaf, so the the hook is never run")
+ 
+ (defvar nntp-deaf-timer 'nil
+   "*Holding timer from `run-at-time' for cancelling it") 
+ (defvar nntp-deaf-hook '(nntp-close-server)
+   "*Hook to be run when `nntp-deaf-timeout' is elapsed
+ 
+ This hook is to be run whenever no characters were taken from the
+ nntp-connection for more than `nntp-deaf-timer'
+ 
+ A plausible use of it is to hold the function `nntp-close-server', 
+ so the default value is '(nntp-close-server)")
+ (defun nntp-deaf-run-hook ()
+   "Runs the hook 'nntp-deaf-hook'"
+   (run-hooks 'nntp-deaf-hook))
+ 
+ (defun nntp-deaf-cancel-timer ()
+   "*Cancel the timer `nntp-deaf-timer'
+ 
+ This is to be called when, for example, reading characters, to avoid the timeout
+ blindly shut down the connection when in use"
+   (if (timerp 'nntp-deaf-timer)
+       (cancel-timer 'nntp-deaf-timer))) 
+   
+ (defun nntp-deaf-reset-timer ()
+   "*Reset the timer `nntp-deaf-timer'
+ 
+ This is to be called whenever a character input end, it reset up the timer that
+ may close the nntp-connection when needed."
+   (nntp-deaf-cancel-timer)
+   (setq nntp-deaf-timer 
+ 	(run-at-time nntp-deaf-timeout 'nil 'nntp-deaf-run-hook)))
+   
+ 
  (defcustom nntp-authinfo-file "~/.authinfo"
    ".netrc-like file that holds nntp authinfo passwords."
    :type
***************
*** 257,262 ****
--- 301,307 ----
    (save-excursion
      (set-buffer (process-buffer process))
      (goto-char (point-min))
+     (nntp-deaf-cancel-timer)
      (while (and (or (not (memq (char-after (point)) '(?2 ?3 ?4 ?5)))
  		    (looking-at "480"))
  		(memq (process-status process) '(open run)))
***************
*** 292,297 ****
--- 337,344 ----
  		(setq nntp-have-messaged nil)
  		(nnheader-message 5 ""))
  	      t))))
+       ;;
+       (nntp-deaf-reset-timer)
        (unless discard
  	(erase-buffer)))))
  
---- cut here ----
-- 
Ketanu


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-05-11 11:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-11 11:33 Working arounf for deaf server [DEAF][NNTP][PATCH] Ketanu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).