summaryrefslogtreecommitdiffstats
path: root/imap
diff options
context:
space:
mode:
authorThomas Roessler <roessler@does-not-exist.org>2001-05-30 23:00:44 +0000
committerThomas Roessler <roessler@does-not-exist.org>2001-05-30 23:00:44 +0000
commite26c1c7e8f3ecb631b0ff4b677ad119c94b236d6 (patch)
tree678dc87e579a4dbda74cffc485faa1b38ebde008 /imap
parent284a9737fd0fa1044f430bbf3d6f0daedc25c6f0 (diff)
Socket API clean-up from Brendan Cully.
Diffstat (limited to 'imap')
-rw-r--r--imap/command.c21
-rw-r--r--imap/imap.c16
2 files changed, 14 insertions, 23 deletions
diff --git a/imap/command.c b/imap/command.c
index 1d7e3cf8..2f90dc48 100644
--- a/imap/command.c
+++ b/imap/command.c
@@ -111,12 +111,11 @@ int imap_cmd_step (IMAP_DATA* idata)
cmd->blen));
}
- if ((c = mutt_socket_readln (cmd->buf + len, cmd->blen - len,
- idata->conn)) < 0)
+ c = mutt_socket_readln (cmd->buf + len, cmd->blen - len, idata->conn);
+ if (c <= 0)
{
- dprint (1, (debugfile, "imap_cmd_step: Error while reading server response, closing connection.\n"));
- mutt_socket_close (idata->conn);
- idata->status = IMAP_FATAL;
+ dprint (1, (debugfile, "imap_cmd_step: Error reading server response.\n"));
+ cmd_handle_fatal (idata);
return IMAP_CMD_BAD;
}
@@ -196,7 +195,10 @@ int imap_exec (IMAP_DATA* idata, const char* cmd, int flags)
safe_free ((void**) &out);
if (rc < 0)
+ {
+ cmd_handle_fatal (idata);
return -1;
+ }
do
rc = imap_cmd_step (idata);
@@ -207,17 +209,10 @@ int imap_exec (IMAP_DATA* idata, const char* cmd, int flags)
if (rc != IMAP_CMD_OK)
{
- char *pc;
-
if (flags & IMAP_CMD_FAIL_OK)
return -2;
dprint (1, (debugfile, "imap_exec: command failed: %s\n", idata->cmd.buf));
- pc = idata->cmd.buf;
- pc = imap_next_word (pc);
- mutt_error ("%s", pc);
- mutt_sleep (2);
-
return -1;
}
@@ -282,7 +277,7 @@ static void cmd_handle_fatal (IMAP_DATA* idata)
(idata->reopen & IMAP_REOPEN_ALLOW) &&
!idata->ctx->closing)
{
- idata->status = IMAP_BYE;
+ idata->status = 0;
idata->state = IMAP_DISCONNECTED;
mx_fastclose_mailbox (idata->ctx);
}
diff --git a/imap/imap.c b/imap/imap.c
index 7d9c9d77..a5a616e2 100644
--- a/imap/imap.c
+++ b/imap/imap.c
@@ -160,6 +160,8 @@ int imap_read_literal (FILE* fp, IMAP_DATA* idata, long bytes)
if (mutt_socket_readchar (idata->conn, &c) != 1)
{
dprint (1, (debugfile, "imap_read_literal: error during read, %ld bytes read\n", pos));
+ idata->status = IMAP_FATAL;
+
return -1;
}
@@ -358,11 +360,7 @@ int imap_open_connection (IMAP_DATA* idata)
int rc;
if (mutt_socket_open (idata->conn) < 0)
- {
- mutt_error (_("Connection to %s failed."), idata->conn->account.host);
- mutt_sleep (1);
return -1;
- }
idata->state = IMAP_CONNECTED;
@@ -380,7 +378,7 @@ int imap_open_connection (IMAP_DATA* idata)
{
if ((rc = query_quadoption (OPT_SSLSTARTTLS,
_("Secure connection with TLS?"))) == -1)
- goto bail;
+ goto err_close_conn;
if (rc == M_YES) {
if ((rc = imap_exec (idata, "STARTTLS", IMAP_CMD_FAIL_OK)) == -1)
goto bail;
@@ -425,9 +423,10 @@ int imap_open_connection (IMAP_DATA* idata)
imap_get_delim (idata);
return 0;
+ err_close_conn:
+ mutt_socket_close (idata->conn);
bail:
FREE (&idata->capstr);
- mutt_socket_close (idata->conn);
idata->state = IMAP_DISCONNECTED;
return -1;
}
@@ -1041,7 +1040,7 @@ void imap_close_mailbox (CONTEXT* ctx)
(ctx == idata->ctx))
{
if (!(idata->noclose) && imap_exec (idata, "CLOSE", 0))
- imap_error ("CLOSE failed", idata->cmd.buf);
+ mutt_error (_("CLOSE failed"));
idata->reopen &= IMAP_REOPEN_ALLOW;
idata->state = IMAP_AUTHENTICATED;
@@ -1086,10 +1085,7 @@ int imap_check_mailbox (CONTEXT *ctx, int *index_hint)
ImapLastCheck = now;
if (imap_exec (idata, "NOOP", 0) != 0)
- {
- imap_error ("imap_check_mailbox", idata->cmd.buf);
return -1;
- }
}
if (idata->check_status & IMAP_NEWMAIL_PENDING)