summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--alpine/confscroll.c12
-rw-r--r--alpine/imap.c9
-rw-r--r--pith/conf.c11
-rw-r--r--pith/conf.h5
-rw-r--r--pith/conftype.h1
-rw-r--r--pith/pine.hlp6
-rw-r--r--pith/state.h3
-rw-r--r--pith/stream.c5
8 files changed, 52 insertions, 0 deletions
diff --git a/alpine/confscroll.c b/alpine/confscroll.c
index 0d932f4c..ff8841fe 100644
--- a/alpine/confscroll.c
+++ b/alpine/confscroll.c
@@ -350,6 +350,7 @@ exclude_config_var(struct pine *ps, struct variable *var, int allow_hard_to_conf
case V_TCPREADWARNTIMEO :
case V_TCPWRITEWARNTIMEO :
case V_TCPQUERYTIMEO :
+ case V_QUITQUERYTIMEO :
case V_RSHCMD :
case V_RSHPATH :
case V_RSHOPENTIMEO :
@@ -1608,6 +1609,10 @@ text_toolit(struct pine *ps, int cmd, CONF_S **cl, unsigned int flags, int look_
lowrange = 5;
hirange = 1000;
}
+ else if((*cl)->var == &ps->vars[V_QUITQUERYTIMEO]){
+ lowrange = 0;
+ hirange = 1000;
+ }
else if((*cl)->var == &ps->vars[V_TCPWRITEWARNTIMEO] ||
(*cl)->var == &ps->vars[V_RSHOPENTIMEO] ||
(*cl)->var == &ps->vars[V_SSHOPENTIMEO] ||
@@ -5432,6 +5437,12 @@ fix_side_effects(struct pine *ps, struct variable *var, int revert)
if(ps->VAR_TCPQUERYTIMEO && SVAR_TCP_QUERY(ps, val, tmp_20k_buf, SIZEOF_20KBUF))
q_status_message(SM_ORDER, 3, 5, tmp_20k_buf);
}
+ else if(var == &ps->vars[V_QUITQUERYTIMEO]){
+ val = 0;
+ if(!revert)
+ if(ps->VAR_QUITQUERYTIMEO && SVAR_QUIT_QUERY_TIMEO(ps, val, tmp_20k_buf, SIZEOF_20KBUF))
+ q_status_message(SM_ORDER, 3, 5, tmp_20k_buf);
+ }
else if(var == &ps->vars[V_RSHOPENTIMEO]){
val = 15;
if(!revert)
@@ -5769,6 +5780,7 @@ fix_side_effects(struct pine *ps, struct variable *var, int revert)
var == &ps->vars[V_TCPREADWARNTIMEO] ||
var == &ps->vars[V_TCPWRITEWARNTIMEO] ||
var == &ps->vars[V_TCPQUERYTIMEO] ||
+ var == &ps->vars[V_QUITQUERYTIMEO] ||
var == &ps->vars[V_RSHOPENTIMEO] ||
var == &ps->vars[V_SSHOPENTIMEO]))
q_status_message(SM_ASYNC, 0, 3,
diff --git a/alpine/imap.c b/alpine/imap.c
index 48ee3606..54e6b253 100644
--- a/alpine/imap.c
+++ b/alpine/imap.c
@@ -1259,6 +1259,15 @@ pine_tcptimeout(long int elapsed, long int sincelast, char *host)
if(ps_global->noshow_timeout)
return(rv);
+ if(ps_global->can_interrupt
+ && ps_global->close_connection_timeout > 0L
+ && elapsed >= (long)ps_global->tcp_query_timeout
+ && elapsed >= (long)ps_global->close_connection_timeout){
+ ps_global->read_bail = 0;
+ ps_global->user_says_cancel = 1;
+ return 0;
+ }
+
if(!ps_global->ttyo)
return(pine_tcptimeout_noscreen(elapsed, sincelast, host));
diff --git a/pith/conf.c b/pith/conf.c
index 2c7ac77b..b75d8891 100644
--- a/pith/conf.c
+++ b/pith/conf.c
@@ -390,6 +390,8 @@ CONF_TXT_T cf_text_tcp_write_timeo[] = "Network write warning timeout. The defau
CONF_TXT_T cf_text_tcp_query_timeo[] = "If this much time has elapsed at the time of a tcp read or write\n# timeout, Alpine will ask if you want to break the connection.\n# Default is 60 seconds, minimum is 5, maximum is 1000.";
+CONF_TXT_T cf_text_close_connection_timeo[] = "If this much time has elapsed at the time of a tcp read or write timeout,\n# Alpine will close the connection automatically without user intervention.\n# Setting this value to zero (the default) disables this. Setting this variable\n# to a smaller value than tcp-query-timeout will close the connection\n# automatically, and you will never be asked if you want to wait.";
+
CONF_TXT_T cf_text_rsh_open_timeo[] = "Sets the time in seconds that Alpine will attempt to open a UNIX remote\n# shell connection. The default is 15, min is 5, and max is unlimited.\n# Zero disables rsh altogether.";
CONF_TXT_T cf_text_rsh_path[] = "Sets the name of the command used to open a UNIX remote shell connection.\n# The default is typically /usr/ucb/rsh.";
@@ -721,6 +723,8 @@ static struct variable variables[] = {
"TCP Write Warning Timeout", cf_text_tcp_write_timeo},
{"tcp-query-timeout", 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0,
"TCP Query Timeout", cf_text_tcp_query_timeo},
+{"close-connection-timeout", 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0,
+ NULL, cf_text_close_connection_timeo},
{"rsh-command", 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0,
NULL, cf_text_rsh_command},
{"rsh-path", 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0,
@@ -2287,6 +2291,13 @@ init_vars(struct pine *ps, void (*cmds_f) (struct pine *, char **))
else
ps->tcp_query_timeout = i;
+ set_current_val(&vars[V_QUITQUERYTIMEO], TRUE, TRUE);
+ ps->close_connection_timeout = i = 0;
+ if(VAR_QUITQUERYTIMEO && SVAR_QUIT_QUERY_TIMEO(ps, i, tmp_20k_buf, SIZEOF_20KBUF))
+ init_error(ps, SM_ORDER | SM_DING, 3, 5, tmp_20k_buf);
+ else
+ ps->close_connection_timeout = i;
+
set_current_val(&vars[V_NEWSRC_PATH], TRUE, TRUE);
if(VAR_NEWSRC_PATH && VAR_NEWSRC_PATH[0])
mail_parameters(NULL, SET_NEWSRC, (void *)VAR_NEWSRC_PATH);
diff --git a/pith/conf.h b/pith/conf.h
index 144b7059..7648e355 100644
--- a/pith/conf.h
+++ b/pith/conf.h
@@ -310,6 +310,7 @@
#define VAR_TCPREADWARNTIMEO vars[V_TCPREADWARNTIMEO].current_val.p
#define VAR_TCPWRITEWARNTIMEO vars[V_TCPWRITEWARNTIMEO].current_val.p
#define VAR_TCPQUERYTIMEO vars[V_TCPQUERYTIMEO].current_val.p
+#define VAR_QUITQUERYTIMEO vars[V_QUITQUERYTIMEO].current_val.p
#define VAR_RSHOPENTIMEO vars[V_RSHOPENTIMEO].current_val.p
#define VAR_RSHPATH vars[V_RSHPATH].current_val.p
#define VAR_RSHCMD vars[V_RSHCMD].current_val.p
@@ -751,6 +752,10 @@
&(n), 5, 30000, 0, (e), \
(el), \
"Tcp-Query-Timeout")
+#define SVAR_QUIT_QUERY_TIMEO(ps,n,e,el) strtoval((ps)->VAR_QUITQUERYTIMEO, \
+ &(n), 0, 30000, 0, (e), \
+ (el), \
+ "Reopen-Folder-Timeout")
#define SVAR_RSH_OPEN(ps,n,e,el) strtoval((ps)->VAR_RSHOPENTIMEO, \
&(n), 5, 30000, 0, (e), \
(el), \
diff --git a/pith/conftype.h b/pith/conftype.h
index 668bfaa4..e70c5276 100644
--- a/pith/conftype.h
+++ b/pith/conftype.h
@@ -161,6 +161,7 @@ typedef enum { V_PERSONAL_NAME = 0
, V_TCPREADWARNTIMEO
, V_TCPWRITEWARNTIMEO
, V_TCPQUERYTIMEO
+ , V_QUITQUERYTIMEO
, V_RSHCMD
, V_RSHPATH
, V_RSHOPENTIMEO
diff --git a/pith/pine.hlp b/pith/pine.hlp
index 104ffa73..ebf8b7fb 100644
--- a/pith/pine.hlp
+++ b/pith/pine.hlp
@@ -200,6 +200,12 @@ without entering a master password.
servers that implement the X-GM-EXT-1 capability (such as the one offered
by Gmail.) This allows users to do selection in Alpine as if they were
doing a search in the web interface for Gmail.
+
+<LI> New variable close-connection-timeout, which tells Alpine to close
+a connection that is having problems being kept alive after the number
+of seconds configured in this variable, if the connection has not
+recovered. The default is 0, which means to keep the connection alive
+and wait for the connection to recover.
</UL>
<P>
diff --git a/pith/state.h b/pith/state.h
index d0f76cbc..30c45527 100644
--- a/pith/state.h
+++ b/pith/state.h
@@ -207,6 +207,9 @@ struct pine {
unsigned beginning_of_month:1;
unsigned beginning_of_year:1;
+ unsigned can_interrupt:1;
+ long int close_connection_timeout;
+
unsigned viewer_overlap:8;
unsigned scroll_margin:8;
unsigned remote_abook_history:8;
diff --git a/pith/stream.c b/pith/stream.c
index 92322d38..cae8dc62 100644
--- a/pith/stream.c
+++ b/pith/stream.c
@@ -2285,6 +2285,8 @@ pine_imap_cmd_happened(MAILSTREAM *stream, char *cmd, long int flags)
if(cmd && !strucmp(cmd, "CHECK"))
reset_check_point(stream);
+ ps_global->can_interrupt = 0; /* never interrupt anything */
+
if(is_imap_stream(stream)){
time_t now;
@@ -2293,6 +2295,9 @@ pine_imap_cmd_happened(MAILSTREAM *stream, char *cmd, long int flags)
sp_set_last_activity(stream, now);
if(!(flags & SC_EXPUNGEDEFERRED))
sp_set_last_expunged_reaper(stream, now);
+
+ if(cmd && !strucmp(cmd, "NOOP")) /* but can interrupt this one */
+ ps_global->can_interrupt = 1;
}
}