Mercurial > pidgin
changeset 23327:97a01e09a3b4
merge of '832388016fc893f5c5d8569130fe34914c3c4cb0'
and 'adf65a0a97c9fc089e408fff1b80abe063adcf2f'
author | Kevin Stange <kevin@simguy.net> |
---|---|
date | Sun, 08 Jun 2008 22:59:32 +0000 |
parents | aec041e8f3e0 (current diff) f06adc198c1d (diff) |
children | 85ca57711e93 |
files | |
diffstat | 1 files changed, 32 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/msn/soap2.c Sun Jun 08 22:51:29 2008 +0000 +++ b/libpurple/protocols/msn/soap2.c Sun Jun 08 22:59:32 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);