Thread View: news.software.readers
1 messages
1 total messages
Started by Tom J Parry
Sun, 30 May 1993 01:51
Tin 1.2 Patch
Author: Tom J Parry
Date: Sun, 30 May 1993 01:51
Date: Sun, 30 May 1993 01:51
139 lines
5565 bytes
5565 bytes
As I mentioned yesterday, I have here a patch to make Tin 1.2 attempt to
reconnect to your NNTP server if it loses the connection. I find this
happens to me often as I leave Tin running in a window overnight and the
NNTP server decides to lose me in that time.
What I have done is put a check in open.c when it issues a LIST command
(read active file) and a "GROUP" command (enter a group). If it loses the
connection at either of these points, it will try once connect to the
server. In the second case, it rereads the active file after exiting that
group.
The solution is not perfect because it does not work if you lose connection
while reading an article. The reason for this is that when reading the
active file or entering a group, you know where you are and it's easy to
just reissue the command. In the case of reading an article, you need to
issue a GROUP command after reconnecting before you can find the article
again. So given the complications of all the different states you could be
in when you lost connection, I decided to just play with the two easy ones.
Given the situation in which the connection loss occurs (for me anyway), this
solution is more than adequate. If you leave Tin for a long time, leave it
at the group selection level for safety.
Below are context diffs for open.c, extern.h and lang.c Use them or lose
them as you wish.
diff -c3 tin1.2.orig/open.c tin1.2.patched/open.c
*** tin1.2.orig/open.c Wed May 26 23:22:28 1993
--- tin1.2.patched/open.c Sat May 29 20:26:40 1993
***************
*** 164,174 ****
if (read_news_via_nntp) {
#ifdef NNTP_ABLE
! put_server ("list");
! if ((respcode = get_respcode ()) != OK_GROUPS) {
! debug_nntp ("open_news_active_fp", "NOT_OK");
! error_message ("%s", nntp_respcode (respcode));
! return (FILE *) 0;
}
debug_nntp ("open_news_active_fp", "OK");
return nntp_to_fp ();
--- 164,184 ----
if (read_news_via_nntp) {
#ifdef NNTP_ABLE
! int try = 2;
! while (try) {
! try--;
! put_server ("list");
! if ((respcode = get_respcode ()) != OK_GROUPS) {
! debug_nntp ("open_news_active_fp", "NOT_OK");
! error_message ("%s", nntp_respcode (respcode));
! if (try) {
! wait_message (txt_attempting_reconnect);
! nntp_close ();
! nntp_open ();
! } else
! return (FILE *) 0;
! } else
! try = 0;
}
debug_nntp ("open_news_active_fp", "OK");
return nntp_to_fp ();
***************
*** 541,555 ****
if (read_news_via_nntp && active[i].type == GROUP_TYPE_NEWS) {
#ifdef NNTP_ABLE
sprintf (buf, "group %s", group);
debug_nntp ("setup_base", buf);
! put_server (buf);
! if (get_server (line, NNTP_STRLEN) == -1) {
! error_message (txt_connection_to_server_broken, "");
! tin_done (1);
}
if (atoi(line) != OK_GROUP) {
--- 551,577 ----
if (read_news_via_nntp && active[i].type == GROUP_TYPE_NEWS) {
#ifdef NNTP_ABLE
+ int try = 2;
+
sprintf (buf, "group %s", group);
debug_nntp ("setup_base", buf);
! while (try) {
! put_server (buf);
! try--;
! if (get_server (line, NNTP_STRLEN) == -1) {
! if (try) {
! wait_message (txt_attempting_reconnect);
! nntp_close ();
! nntp_open ();
! } else {
! error_message (txt_connection_to_server_broken, "");
! tin_done (1);
! }
! } else
! try = 0;
}
if (atoi(line) != OK_GROUP) {
diff -c3 tin1.2.orig/lang.c tin1.2.patched/lang.c
*** tin1.2.orig/lang.c Wed May 26 23:22:14 1993
--- tin1.2.patched/lang.c Sat May 29 20:15:08 1993
***************
*** 278,283 ****
--- 278,284 ----
char txt_cannot_get_nntp_server_name[] = "Cannot find NNTP server name";
char txt_server_name_in_file_env_var[] = "Put the server name in the file %s,\nor set the environment variable NNTPSERVER";
char txt_failed_to_connect_to_server[] = "Failed to connect to NNTP server %s. Exiting...";
+ char txt_attempting_reconnect[] = "Attempting to reconnect...";
char txt_rejected_by_nntpserver[] = "Rejected by server, nntp error %d";
char txt_connection_to_server_broken[] = "Connection to server broken";
char txt_stuff_nntp_cannot_open[] = "stuff_nntp: can't open %s: ";
diff -c3 tin1.2.orig/extern.h tin1.2.patched/extern.h
*** tin1.2.orig/extern.h Wed May 26 23:21:34 1993
--- tin1.2.patched/extern.h Sat May 29 20:15:37 1993
***************
*** 155,160 ****
--- 155,161 ----
extern char txt_art_saved_to[];
extern char txt_art_thread_regex_tag[];
extern char txt_art_unavailable[];
+ extern char txt_attempting_reconnect[];
extern char txt_author_search_backwards[];
extern char txt_author_search_forwards[];
extern char txt_bad_active_file[];
--
Tom J Parry.
Your reality is a figment of my imagination.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads