aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJiri Hruska <jirka@fud.cz>2013-02-28 19:42:42 +0100
committerSteve Holme <steve_holme@hotmail.com>2013-02-28 21:00:11 +0000
commitcdea86ff679989a1fb5422d401135064749b9921 (patch)
tree2a7c41fdcf776899700e2437b6c63e0c64da82ed /lib
parent974c663471c15721082d9bdc50d90dd6843467b0 (diff)
imap: Added processing of the final FETCH responses
Not processing the final FETCH responses was not optimal, not only because the response code would be ignored but it would also leave data unread on the socket which would prohibit connection reuse.
Diffstat (limited to 'lib')
-rw-r--r--lib/imap.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/imap.c b/lib/imap.c
index 8f6aad7c6..a834c4e5f 100644
--- a/lib/imap.c
+++ b/lib/imap.c
@@ -1337,6 +1337,26 @@ static CURLcode imap_state_fetch_resp(struct connectdata *conn, int imapcode,
return result;
}
+/* For the final response to the FETCH command */
+static CURLcode imap_state_fetch_final_resp(struct connectdata *conn,
+ int imapcode,
+ imapstate instate)
+{
+ CURLcode result = CURLE_OK;
+
+ (void)instate; /* No use for this yet */
+
+ if('O' != imapcode)
+ result = CURLE_FTP_WEIRD_SERVER_REPLY; /* TODO: Fix error code */
+ else
+ result = CURLE_OK;
+
+ /* End of do phase */
+ state(conn, IMAP_STOP);
+
+ return result;
+}
+
static CURLcode imap_statemach_act(struct connectdata *conn)
{
CURLcode result = CURLE_OK;
@@ -1435,6 +1455,10 @@ static CURLcode imap_statemach_act(struct connectdata *conn)
result = imap_state_fetch_resp(conn, imapcode, imapc->state);
break;
+ case IMAP_FETCH_FINAL:
+ result = imap_state_fetch_final_resp(conn, imapcode, imapc->state);
+ break;
+
case IMAP_LOGOUT:
/* fallthrough, just stop! */
default:
@@ -1578,6 +1602,18 @@ static CURLcode imap_done(struct connectdata *conn, CURLcode status,
conn->bits.close = TRUE; /* marked for closure */
result = status; /* use the already set error code */
}
+ else if(!data->set.connect_only) {
+ state(conn, IMAP_FETCH_FINAL);
+
+ /* Run the state-machine
+
+ TODO: when the multi interface is used, this _really_ should be using
+ the imap_multi_statemach function but we have no general support for
+ non-blocking DONE operations, not in the multi state machine and with
+ Curl_done() invokes on several places in the code!
+ */
+ result = imap_block_statemach(conn);
+ }
/* Cleanup our per-request based variables */
Curl_safefree(imap->mailbox);