if (flags & IMAP_CMD_QUEUE)
return 0;
+ // Allow interruptions, particularly useful if there are network problems.
+ mutt_allow_interrupt (1);
do
rc = imap_cmd_step (idata);
while (rc == IMAP_CMD_CONTINUE);
+ mutt_allow_interrupt (0);
if (rc == IMAP_CMD_NO && (flags & IMAP_CMD_FAIL_OK))
return -2;
{
int rc;
+ mutt_allow_interrupt (1);
if ((rc = read (conn->fd, buf, len)) == -1)
{
mutt_error (_("Error talking to %s (%s)"), conn->account.host,
strerror (errno));
mutt_sleep (2);
- }
+ } else if (errno == EINTR) {
+ rc = -1;
+ mutt_error (_("Error talking to %s (%s)"), conn->account.host,
+ strerror (errno));
+ mutt_sleep (2);
+ }
+ mutt_allow_interrupt (0);
return rc;
}
{
int rc;
+ mutt_allow_interrupt (1);
if ((rc = write (conn->fd, buf, count)) == -1)
{
mutt_error (_("Error talking to %s (%s)"), conn->account.host,
strerror (errno));
mutt_sleep (2);
+ } else if (errno == EINTR) {
+ rc = -1;
+ mutt_error (_("Error talking to %s (%s)"), conn->account.host,
+ strerror (errno));
+ mutt_sleep (2);
}
+ mutt_allow_interrupt (0);
return rc;
}
int rc;
rc = SSL_read (data->ssl, buf, len);
- if (rc <= 0)
+ if (rc <= 0 || errno == EINTR)
{
+ if (errno == EINTR)
+ {
+ rc = -1;
+ }
data->isopen = 0;
ssl_err (data, rc);
}
int rc;
rc = SSL_write (data->ssl, buf, len);
- if (rc <= 0)
+ if (rc <= 0 || errno == EINTR) {
+ if (errno == EINTR)
+ {
+ rc = -1;
+ }
ssl_err (data, rc);
+ }
return rc;
}
do {
ret = gnutls_record_recv (data->state, buf, len);
- if (ret < 0 && gnutls_error_is_fatal(ret) == 1)
+ if ((ret < 0 &&
+ gnutls_error_is_fatal(ret) == 1) ||
+ ret == GNUTLS_E_INTERRUPTED
+ )
{
mutt_error ("tls_socket_read (%s)", gnutls_strerror (ret));
- mutt_sleep (4);
+ mutt_sleep (2);
return -1;
}
- }
- while (ret == GNUTLS_E_AGAIN || ret == GNUTLS_E_INTERRUPTED);
+ } while (ret == GNUTLS_E_AGAIN);
return ret;
}
ret = gnutls_record_send (data->state, buf + sent, len - sent);
if (ret < 0)
{
- if (gnutls_error_is_fatal(ret) == 1)
+ if (gnutls_error_is_fatal(ret) == 1 || ret == GNUTLS_E_INTERRUPTED)
{
mutt_error ("tls_socket_write (%s)", gnutls_strerror (ret));
mutt_sleep (4);
err = gnutls_handshake(data->state);
- while (err == GNUTLS_E_AGAIN || err == GNUTLS_E_INTERRUPTED)
+ while (err == GNUTLS_E_AGAIN)
{
err = gnutls_handshake(data->state);
}
/* check for new mail */
int mx_check_mailbox (CONTEXT *ctx, int *index_hint)
{
- if (!ctx)
+ if (!ctx || ctx->magic == 0)
{
dprint (1, (debugfile, "mx_check_mailbox: null or invalid context.\n"));
return -1;
while ((ch = fgetconv (fc)) != EOF)
{
+ if (SigInt == 1) {
+ SigInt = 0;
+ return;
+ }
if (istext && ch == '\n' && ch1 != '\r')
b64_putc('\r', fout);
b64_putc(ch, fout);
{
int ch;
- while ((ch = fgetconv (fc)) != EOF)
+ while ((ch = fgetconv (fc)) != EOF) {
+ if (SigInt == 1) {
+ SigInt = 0;
+ return;
+ }
fputc (ch, fout);
+ }
}
else
fc = fgetconv_open (fpin, 0, 0, 0);
+ mutt_allow_interrupt (1);
if (a->encoding == ENCQUOTEDPRINTABLE)
encode_quoted (fc, f, write_as_text_part (a));
else if (a->encoding == ENCBASE64)
encode_8bit (fc, f, write_as_text_part (a));
else
mutt_copy_stream (fpin, f);
+ mutt_allow_interrupt (0);
fgetconv_close (&fc);
safe_fclose (&fpin);
+ if (SigInt == 1) {
+ SigInt = 0;
+ return -1;
+ }
return (ferror (f) ? -1 : 0);
}