Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
From: Ketanu <ketanu@wanadoo.fr>
Subject: Working arounf for deaf server [DEAF][NNTP][PATCH]
Date: 11 May 2002 13:33:17 +0200	[thread overview]
Message-ID: <873cwyvs02.fsf@ketanu.dyndns.org> (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


                 reply	other threads:[~2002-05-11 11:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=873cwyvs02.fsf@ketanu.dyndns.org \
    --to=ketanu@wanadoo.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).