Mercurial > pidgin
changeset 23328:85ca57711e93
merge of 'f7176494034dd112dc3416db787a73b6dc67007b'
and 'fcc768ad62bc878c93d5b88b758d5e17251c9ebe'
author | Kevin Stange <kevin@simguy.net> |
---|---|
date | Sun, 08 Jun 2008 23:00:36 +0000 |
parents | 6595af65ef45 (current diff) 97a01e09a3b4 (diff) |
children | d4f12325e599 |
files | |
diffstat | 1 files changed, 32 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/msn/soap2.c Sun Jun 08 23:00:24 2008 +0000 +++ b/libpurple/protocols/msn/soap2.c Sun Jun 08 23:00:36 2008 +0000 @@ -82,6 +82,7 @@ static void msn_soap_request_destroy(MsnSoapRequest *req); static void msn_soap_connection_sanitize(MsnSoapConnection *conn, gboolean disconnect); +static void msn_soap_process(MsnSoapConnection *conn); static gboolean msn_soap_cleanup_each(gpointer key, gpointer value, gpointer data) @@ -264,45 +265,53 @@ msn_soap_read_cb(gpointer data, gint fd, PurpleInputCondition cond) { MsnSoapConnection *conn = data; - int count = 0, cnt; - char buf[8192]; - char *linebreak; - char *cursor; - gboolean handled = FALSE; + int count = 0, cnt, perrno; + /* This buffer needs to be larger than any packets received from + login.live.com or Adium will fail to receive the packet + (something weird with the login.live.com server). With NSS it works + fine, so I believe it's some bug with OS X */ + char buf[16 * 1024]; if (conn->message == NULL) { conn->message = msn_soap_message_new(NULL, NULL); } + if (conn->buf == NULL) { + conn->buf = g_string_new_len(buf, 0); + } + while ((cnt = purple_ssl_read(conn->ssl, buf, sizeof(buf))) > 0) { purple_debug_info("soap", "read %d bytes\n", cnt); count += cnt; - if (conn->buf == NULL) { - conn->buf = g_string_new_len(buf, cnt); - } else { - g_string_append_len(conn->buf, buf, cnt); - } + g_string_append_len(conn->buf, buf, cnt); } - if (cnt < 0) { - if (errno != EAGAIN) { - purple_debug_info("soap", "read: %s\n", g_strerror(errno)); + /* && count is necessary for Adium, on OS X the last read always + return an error, so we want to proceed anyway. See #5212 for + discussion on this and the above buffer size issues */ + if(cnt < 0 && errno == EAGAIN && count == 0) + return; + + // msn_soap_process could alter errno + perrno = errno; + msn_soap_process(conn); + + if (cnt < 0 && perrno != EAGAIN) { + purple_debug_info("soap", "read: %s\n", g_strerror(perrno)); + // It's possible msn_soap_process closed the ssl connection + if (conn->ssl) { purple_ssl_close(conn->ssl); conn->ssl = NULL; msn_soap_connection_handle_next(conn); - return; - } else if (count == 0) { - return; } } +} - if (cnt == 0 && count == 0) { - purple_debug_info("soap", "msn_soap_read_cb() called, but no data available?\n"); - purple_ssl_close(conn->ssl); - conn->ssl = NULL; - msn_soap_connection_handle_next(conn); - return; - } +static void +msn_soap_process(MsnSoapConnection *conn) { + gboolean handled = FALSE; + char *cursor; + char *linebreak; purple_debug_info("soap", "current %s\n", conn->buf->str);