summaryrefslogtreecommitdiffstats
path: root/imap
diff options
context:
space:
mode:
authorThomas Roessler <roessler@does-not-exist.org>1999-12-01 09:28:59 +0000
committerThomas Roessler <roessler@does-not-exist.org>1999-12-01 09:28:59 +0000
commit2fdb0604cf34d35a98e609b039ec11556ec1fb71 (patch)
treed85ac3c3466d1fd0df53380e4a85a13b4dd3f476 /imap
parentbe18f8604edd1ab26bf41d4e08de4b60b30e2173 (diff)
A modified version of Tommi Kommulainen's imap keepalive patch.
Diffstat (limited to 'imap')
-rw-r--r--imap/imap.h2
-rw-r--r--imap/util.c57
2 files changed, 59 insertions, 0 deletions
diff --git a/imap/imap.h b/imap/imap.h
index fd41112d..6f86a1eb 100644
--- a/imap/imap.h
+++ b/imap/imap.h
@@ -52,4 +52,6 @@ int imap_parse_path (char* path, char* host, size_t hlen, int* port,
void imap_qualify_path (char* dest, size_t len, const char* host, int port,
const char* path, const char* name);
+int imap_wait_keepalive (pid_t pid);
+
#endif
diff --git a/imap/util.c b/imap/util.c
index 6bc5d423..4c31b109 100644
--- a/imap/util.c
+++ b/imap/util.c
@@ -26,6 +26,12 @@
#include <stdlib.h>
#include <ctype.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <signal.h>
+
+#include <errno.h>
+
/* imap_continue: display a message and ask the user if she wants to
* go on. */
int imap_continue (const char* msg, const char* resp)
@@ -299,3 +305,54 @@ int imap_wordcasecmp(const char *a, const char *b)
return mutt_strcasecmp(a, tmp);
}
+
+/* imap keepalive: use buffy to poll a remote imap folder
+ * while waiting for an external process
+ */
+
+static RETSIGTYPE alrm_handler (int sig)
+{
+ /* empty */
+}
+
+int imap_wait_keepalive (pid_t pid)
+{
+ struct sigaction oldalrm;
+ struct sigaction act;
+ int rc;
+
+ short imap_passive = option (OPTIMAPPASSIVE);
+
+ set_option (OPTIMAPPASSIVE);
+ set_option (OPTKEEPQUIET);
+
+ sigemptyset (&act.sa_mask);
+ act.sa_handler = alrm_handler;
+#ifdef SA_INTERRUPT
+ act.sa_flags = SA_INTERRUPT;
+#else
+ act.sa_flags = 0;
+#endif
+
+ sigaction (SIGALRM, &act, &oldalrm);
+
+ alarm (ImapCheckTimeout > 0 ? ImapCheckTimeout : 60);
+ while (waitpid (pid, &rc, 0) < 0 && errno == EINTR)
+ {
+ alarm (0);
+
+ if (!option (OPTMSGERR))
+ mutt_buffy_check (0);
+
+ alarm (ImapCheckTimeout > 0 ? ImapCheckTimeout : 60);
+ }
+
+ sigaction (SIGALRM, &oldalrm, NULL);
+
+ unset_option (OPTKEEPQUIET);
+ if (!imap_passive)
+ unset_option (OPTIMAPPASSIVE);
+
+ return rc;
+}
+