Commit c368fbcb authored by Jiri Hruska's avatar Jiri Hruska Committed by Steve Holme
Browse files

imap: Added processing of more than one response when sent in same packet

Added a loop to imap_statemach_act() in which Curl_pp_readresp() is
called until the cache is drained. Without this multiple responses
received in a single packet could result in a hang or delay.
parent b644c471
Loading
Loading
Loading
Loading
+12 −9
Original line number Diff line number Diff line
@@ -1351,6 +1351,7 @@ static CURLcode imap_statemach_act(struct connectdata *conn)
  if(pp->sendleft)
    return Curl_pp_flushsend(pp);

  do {
    /* Read the response from the server */
    result = Curl_pp_readresp(sock, pp, &imapcode, &nread);
    if(result)
@@ -1360,7 +1361,9 @@ static CURLcode imap_statemach_act(struct connectdata *conn)
    if(imapcode == -1)
      return CURLE_FTP_WEIRD_SERVER_REPLY;

  if(imapcode) {
    if(!imapcode)
      break;

    /* We have now received a full IMAP server response */
    switch(imapc->state) {
    case IMAP_SERVERGREET:
@@ -1436,7 +1439,7 @@ static CURLcode imap_statemach_act(struct connectdata *conn)
      state(conn, IMAP_STOP);
      break;
    }
  }
  } while(!result && imapc->state != IMAP_STOP && Curl_pp_moredata(pp));

  return result;
}