summaryrefslogtreecommitdiff
path: root/pith
diff options
context:
space:
mode:
authorEduardo Chappa <chappa@washington.edu>2018-05-27 15:48:21 -0600
committerEduardo Chappa <chappa@washington.edu>2018-05-27 15:48:21 -0600
commit2e72300b0d571c2b319e0e5c827ddc45f011f964 (patch)
tree1ab904e5965602e4565497dd51bc3af2a46681da /pith
parentae67ebf820817f01e77471b5bc7da9885b159bba (diff)
downloadalpine-2e72300b0d571c2b319e0e5c827ddc45f011f964.tar.xz
* Add 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.
Diffstat (limited to 'pith')
-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
6 files changed, 31 insertions, 0 deletions
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;
}
}